-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrap ava test function to log failures to actual console #555
Conversation
What else do I need to do so this is pleasantly importable by other tests not in this monorepo? |
On the monkey testing... At line 739 of https://github.com/Agoric/agoric-sdk/pull/2159/checks?check_run_id=1632858610#step:7:739 we see
also with deep stack traces All this is extremely valuable debugging info we weren't seeing despite all our error/console/assert engineering. Hidden by ava. |
It would be good to see this side-by-side with intended internal usage. I don’t think we want to entrain this in the SES public API. Since this is a mitigation against Ava specifically, we would ideally package this with a name like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To answer your question regarding making this public API, we have options.
Publishing from the SES package would imply some Ava coupling I’d rather avoid.
I’d suggest creating a thing ses-ava
package in ses-shim
and publishing it to npm so it can be used in other projects. If we also need to use the test wrapper for our own SES tests, let’s do that in this change, using ses-ava
as a development dependency.
Good plan! Will do. |
70f14e6
to
2885eed
Compare
Hi @kriskowal, When you have time, please look at this. I started with your repackage script and tried to adjust from there blindly using other packages for examples. When I
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the error is because Rollup needs a plugin to treat CommonJS dependencies (ava
) properly. Only packages that have CommonJS dependencies of Rollup artifacts require this plugin. The plugin is already in the dependencies, just was not in the template Rollup configuration.
All suggestions applied. Now
|
62ed696
to
bf260a7
Compare
See #579 |
9945d8e
to
edbf3a1
Compare
The state of this PR is that the new source files and test files are all working and ready for review. However... The first commit is the pristine state resulting from @kriskowal 's Since the point of this PR is to change what happen when ava reports failure, we can't code this in ava directly as passing tests. To do this correctly, we need #579 which I don't know how to do. Instead, the substantive tests are all commented out of that this package passes CI. If you're inclined to fix this by doing #579 first, that would be great! @dckc I'm out tomorrow (Friday) but will be back Saturday. Please proceed towards making all these improvements. @kriskowal please help @dckc , especially with the changes I made to the files left behind by Thanks! |
bcda0b8
to
376711f
Compare
376711f
to
2cd6ec9
Compare
`@callback` doesn't seem to mix with spread syntax, so we use `@typedef` instead for Logger.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and fixed any -> unknown.
My other comments are not critical.
packages/ses-ava/package.json
Outdated
"lint-fix": "eslint --fix '**/*.js'", | ||
"prepublish": "yarn clean && yarn build", | ||
"test": "yarn build && yarn ava", | ||
"qt": "yarn ava" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having yarn test
run yarn build
was surprising. I did eventually discover qt
... but I ran scripts/repackage.sh skel
and discovers it produces just "test": "ava"
.
Thoughts, @kriskowal ?
I don't suppose it's critical.
"scripts": { | ||
"build": "rollup --config rollup.config.js", | ||
"clean": "rm -rf dist", | ||
"lint": "yarn lint:types && yarn lint:js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scripts/repackage.sh
produces build:types
rather than lint:types
. I consider that a bug in scripts/repackage.sh
.
"@rollup/plugin-commonjs": "^13.0.0", | ||
"@rollup/plugin-node-resolve": "^6.1.0", | ||
"@rollup/plugin-json": "^4.1.0", | ||
"@agoric/eslint-config": "^0.1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scripts/repackage.sh
seems to be out of date on eslint config too.
"target": "es2020", | ||
"module": "esnext", | ||
"noEmit": true, | ||
"downlevelIteration": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
downlevelIteration seems to be deprecated, but I see it in lots of other jsconfig.json
files, so it's pretty clearly harmless
packages/ses-ava/src/ses-ava-test.js
Outdated
/** | ||
* Just forwards to global `console.error`. | ||
* | ||
* @type {import('./types').Logger} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
odd... we have import './types.js'
above. Why doesn't {Logger}
suffice? (I verified that it does not). @michaelfig ?
packages/ses-ava/src/ses-ava-test.js
Outdated
* Determine if the argument is a Promise. | ||
* (Approximately copied from promiseKit.js) | ||
* | ||
* @param {any} maybePromise The value to examine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/any/unknown/ . Don't use any
in a type annotation without very good reason.
(just added to https://github.com/Agoric/agoric-sdk/wiki/Code-Review-Checklist)
packages/ses-ava/src/types.js
Outdated
|
||
/** | ||
* @callback Logger | ||
* @param {...any} args |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use of any
here masked a bug: spead syntax doesn't work here.
@kriskowal please (auto) merge this if you approve it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve submitted my feedback in the form of a commit. I fixed the TypeSciprt imports for types.js by removing import 'ses'
from types.js
. The evident behavior is that any JS file containing only TS in JSDoc is implicitly imported by all other files in the same directory.
packages/ses-ava/src/types.js
Outdated
@@ -0,0 +1,68 @@ | |||
// @ts-check | |||
import 'ses'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps try /// <reference types="ses"/>
instead. I believe types.js is magical and only does its magic if it does nothing except declare types in JSDoc.
When a test case
test(title, func)
fails becausefunc
threw an error or returned a promise that eventually rejects, ava prints the stack in what looks like console output but is not. This bypasses all of our fancy error support --- the error details and all the deep stack support -- which made it extremely unpleasant to debug failing tests.This PR provides a
testWrapper
function that acts like ava'stest
function, except that when a test fails, the failure is also reported to the actual console. When used under SES, this is the fancy console that SES installs.Since this only does something when the ava test fails, there's no easy way to include an automated test. However I have monkey tested it (in Agoric/agoric-sdk#2159 ) and it seems to work.
fixes #577