Skip to content
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

WIP: Better errors from t.fail, t.notThrows, t.notThrowsAsync #701

Closed
wants to merge 2 commits into from

Conversation

erights
Copy link
Contributor

@erights erights commented Apr 28, 2021

DO NOT MERGE: Still based on an ancient master

Draft until demo-tests. But by using yarn link to link agoric-sdk to ses-ava, I see that it already improved the error reporting problem reported today by @Chris-Hibbert . This improvement is merely that these three methods also report the error to our console, where we have more control. What it not yet addressed is actually reporting deep stacks.

@erights erights self-assigned this Apr 28, 2021
@erights
Copy link
Contributor Author

erights commented Apr 28, 2021

@michaelfig there is a typing mystery here clearly marked with a TODO. Your advice appreciated!

@erights
Copy link
Contributor Author

erights commented Apr 28, 2021

@dckc my intention is for this PR to also work with xs-ses, but I don't yet know how to test that.

@dckc
Copy link
Contributor

dckc commented Apr 28, 2021

@dckc my intention is for this PR to also work with xs-ses, but I don't yet know how to test that.

I'm not sure what you mean. If by xs-ses you mean ava-xs, then I'm not sure integration is feasible or sensible. ava-xs doesn't do the console tricks that ava does, so I don't think ses-ava is relevant.

In case it's useful: the main uses of ava-xs are yarn test:xs-unit in packages/ERTP or in packages/zoe.

@erights
Copy link
Contributor Author

erights commented Apr 28, 2021

I'm not sure what you mean. If by xs-ses you mean ava-xs,

yes

then I'm not sure integration is feasible or sensible. ava-xs doesn't do the console tricks that ava does, so I don't think ses-ava is relevant.

I'm not sure I understand. ava-xs already uses our console, since it is the one left as the global console in the start compartment? Then yes, ses-ava does not add value to ava-xs. The whole point of ses-ava is to use our console in addition to whatever ava does for its console-ish output. So yes, let's not worry about testing this on ava-xs.

@dckc
Copy link
Contributor

dckc commented Apr 28, 2021

... ava-xs already uses our console, since it is the one left as the global console in the start compartment?

Yes.

Recall there are SES tests that assert that the console in a compartment is distinct from the one in the start compartment and we agreed it wasn't worthwhile to get ava-xs to satisfy these assertions.

Apr 10 notes:
#508 (comment)

@erights
Copy link
Contributor Author

erights commented Apr 28, 2021

See also Agoric/agoric-sdk#2991 which is more directly about the missing deep stacks.

@erights
Copy link
Contributor Author

erights commented Apr 28, 2021

Provoked by, and helps some with Agoric/agoric-sdk#2992

Copy link
Contributor

@Chris-Hibbert Chris-Hibbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um. I don't understand how this change achieves its affect.

I wanted to try the change out so I could at least report that it improved the situation, but don't see how to do that. What would I do after cloning the repo to reproduce?

Copy link
Member

@kriskowal kriskowal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we losing the context of the error when we log to console.error instead of t.log? Ava captures messages in the context of a particular test so it can associate them in the final report. Console messages get unconditionally spammed to the console, without that context.

@@ -29,7 +27,7 @@ const isPromise = maybePromise =>
const logErrorFirst = (func, args, name, logger = defaultLogger) => {
let result;
try {
result = apply(func, undefined, args);
result = func(...args);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What’s the motivation for this simplification, or what was the motive for the complication? (I like the simplification)

packages/ses-ava/src/ses-ava-test.js Show resolved Hide resolved
fail(message) {
const err = new Error(message);
logger('FAILED by t.fail', err);
return super.fail(message);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Today I learned that super works without the enclosing class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually makes it more E-like, even though E did not provoke the idea. But still, E did help corroborate that it is a good idea.

@erights
Copy link
Contributor Author

erights commented May 17, 2021

Are we losing the context of the error when we log to console.error instead of t.log? Ava captures messages in the context of a particular test so it can associate them in the final report. Console messages get unconditionally spammed to the console, without that context.

There's an interesting tension here. Also, in some other PR where @dckc (IIRC) suggested that I switch from console.log to t.log. I still need to get back to that one as well. In both cases, the tension is that Ava's t.log does not wrap the start compartment's console, and therefore does not employ the enhanced console that lockdown installs on the start compartment's global. It is only this enhanced console that is properly entangled with our assert and error taming. Going the other way, it would be awkward to have our enhanced console wrap t.log because there is not a single static t.log. Rather, there's is a t per call to test, but our console is created once per lockdown.

IIUC, none of this should be a problem on XS as ava-xs already logs through the console of the start compartment. Yes? attn @dckc

@dckc
Copy link
Contributor

dckc commented May 17, 2021

IIUC, none of this should be a problem on XS as ava-xs already logs through the console of the start compartment. Yes?

yes.

@erights
Copy link
Contributor Author

erights commented Sep 14, 2021

As author, I cannot be a reviewer. But please ask me to review anyway.

Copy link
Contributor

@dckc dckc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just telling the robots that this is not currently awaiting my review

@erights erights changed the title Better errors from t.fail, t.notThrows, t.notThrowsAsync WIP: Better errors from t.fail, t.notThrows, t.notThrowsAsync May 20, 2023
@erights
Copy link
Contributor Author

erights commented Jun 6, 2023

If we try to do this again, we should start a new PR. Closing this one as fatally stale.

@erights erights closed this Jun 6, 2023
@erights
Copy link
Contributor Author

erights commented Mar 1, 2024

If we try to do this again, we should start a new PR. Closing this one as fatally stale.

We may want to redo this as part of #2109. It would be a natural fit.

@erights erights mentioned this pull request Mar 1, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants