-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
test_runner: bail #48919
test_runner: bail #48919
Conversation
Review requested:
|
this seems to run tests without reporting them after the bail |
Exactly, as I mentioned the problem at the moment is to identify when a test is failing, I think we should use ipc to increase a global counter and abort running test when bail is hit, I wanted to understand if there are other ways to achieve this. |
I don't think this is the right approach. I don't think we need a counter or IPC. If you're adding a new Each individual file will bail out if it encounters an error, and send that information back to the main process. The main process would then be responsible for terminating all of the other worker processes. |
The problem of this approach is that if you enter a value of 3, it will only bail if a single test file fails 3 times while I would expect to be global(?) i should check how other libraries handle it. If its per file it should be waay easier |
Oh. I didn't read your docs. It seems strange to have a bail out limit of any value other than 1. That also complicates the implementation because you need to count failures in the test runner and each test file (to support with and without EDIT: Actually, we already have |
I think I will go for the easy route, as Ive seen other libraries (eg vitest) when flagged with |
@marco-ippolito A simple implementation for this solution exists in @MoLow's Perhaps we could add a new reporter and that keeps track of the amount of failed tests (by the amount of |
as @cjihrig has written we already keep track of that, even when using |
0d6a381
to
41aa463
Compare
I was thinking for a first implementation I'd leave the flag boolean, and exit at first failure, I could use 0 and 1 but doesn't make much difference at the moment |
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 think we should allow setting bail
in the options
for coded version as well
https://github.com/atlowChemi/node/blob/4b3d964a8c01c4b541fc85d3a419b58524806f04/lib/internal/test_runner/runner.js#L428
If you're planning to iterate and change the design, you'll need to make this an experimental feature. The test runner is stable now, so we won't be breaking things without a good reason. |
I think it depends, if we will ever want to implement bailout as integer value bigger than 1, probably not. |
IMHO numeric bail will never be needed. Boolean as you already coded is the way to go. |
10098ba
to
fe9b46f
Compare
This comment was marked as resolved.
This comment was marked as resolved.
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 think there should also be an additional test validating that tests fail with the expected error type
It would be nice if we could better leverage the existing cancellation logic. |
4535de4
to
6678a3b
Compare
@@ -32,6 +33,8 @@ async function * tapReporter(source) { | |||
for await (const { type, data } of source) { | |||
switch (type) { | |||
case 'test:fail': { | |||
// If test bailed out do not report |
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.
so a test can run without us reporting it? I am not sure this is good
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.
The test has error kBailedOut
because has been canceled, I dont want to see canceled tests in the reporter because they bailedout
I have some concerns about this implementation which seems indeterministic and unpredictable:
|
Tests that have already started are canceled by |
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.
lgtm
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.
Blocking this since it has an approval now.
I share @MoLow's concerns in #48919 (comment). Looking at, for example, test/fixtures/test-runner/output/bail-error.snapshot
the output looks wrong outside of the context of this PR.
Sorry maybe this is harder than I thought, I can't dedicate more time on it, feel free to take over. |
@nodejs/test_runner I think we should decide if we want to support bailing out, and if so, what the experience looks like? My opinion is that we should support it. This is how I would implement it, but I'm open to input from others:
Thoughts? |
@cjihrig Maybe open a new issue and we can discuss it there? |
@cjihrig I generally agree, but I think we also need to decide on the expected behavior of the combination of |
@atlowChemi I agree. Off the top of my head I'm not 100% sure what the best way to implement that would be, but I agree with that behavior. |
doing that within a single file is trivial, but canceling running files might not always work if we use signals and they are caught by userland code
I think in that case opon test failure we should cancel all tests, empty the tests queue as, emit |
What do you mean "caught by userland code"? Are you referring to userland calling |
I mean listening to |
Oh different kind of signals, got you now, thanks 👍🏽 |
This is a first (ugly) implementation of the bail mechanism, I still wanted to open this draft pr to discuss it.
I'd love to hear your opinion 😃