-
Notifications
You must be signed in to change notification settings - Fork 30k
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: emit start event when subtest starts #47797
Conversation
Review requested:
|
@MoLow I request your review. |
If code changes look fine, can proceed with doc changes and tests (a file pointer would be helpful in this case) |
lib/internal/test_runner/test.js
Outdated
@@ -514,6 +514,7 @@ class Test extends AsyncResource { | |||
} | |||
|
|||
async run() { | |||
|
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.
please revert unrelated change
@@ -27,6 +27,10 @@ class TestsStream extends Readable { | |||
} | |||
} | |||
|
|||
begin(nesting, file, testNumber, name, details, directive) { |
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.
does anything call this method?
I would start by adding this method to this test file, then make sure it passes
assert.match(stdout, /{"test:start":4,"test:pass":2,"test:fail":2,"test:plan":2,"test:diagnostic":\d+}$/); |
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.
no this is the new event so, not called anywhere yet.
@@ -27,6 +27,10 @@ class TestsStream extends Readable { | |||
} | |||
} | |||
|
|||
begin(nesting, file, testNumber, name, details, directive) { | |||
this.#emit('test:begin', { __proto__: null, name, nesting, file, testNumber, details, ...directive }); |
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.
Just throwing an idea out there: having both begin
and start
is confusing. I could also picture people asking for more of these lifecycle events. I would namespace this event further and name it test:lifecycle:run
, where lifecycle
can be used to indicate what is happening in the test runner and is less about reporting results.
@sankalp1999 are you still working on this? |
@cjihrig apologise, got busy with other stuff. Getting back to try this next. |
@@ -27,6 +27,10 @@ class TestsStream extends Readable { | |||
} | |||
} | |||
|
|||
begin(nesting, file, testNumber, name, details, directive) { | |||
this.#emit('test:lifecycle:run', { __proto__: null, name, nesting, file, testNumber, details, ...directive }); | |||
} |
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.
can remove ...directive I guess
Ok I saw upstream has changed significantly. |
emit a start event to show message just after a test/subtest start Fixes: nodejs#46727
This commit implements the start event in tests_stream.js and removes the code that was altering TAP output in test.js
ee93ebc
to
d4b38f6
Compare
@@ -29,6 +29,10 @@ class TestsStream extends Readable { | |||
} | |||
} | |||
|
|||
begin(nesting, file, testNumber, name, details) { |
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.
begin(nesting, file, testNumber, name, details) { | |
lifecycleRun(nesting, file, testNumber, name, details) { |
@@ -97,7 +97,7 @@ describe('node:test reporters', { concurrency: true }, () => { | |||
testFile]); | |||
assert.strictEqual(child.stderr.toString(), ''); | |||
const stdout = child.stdout.toString(); | |||
assert.match(stdout, /{"test:start":4,"test:pass":2,"test:fail":2,"test:plan":2,"test:diagnostic":\d+}$/); | |||
assert.match(stdout, /{"test:lifecycle:run":\d+,"test:start":4,"test:pass":2,"test:fail":2,"test:plan":2,"test:diagnostic":\d+}$/); |
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.
assert.match(stdout, /{"test:lifecycle:run":\d+,"test:start":4,"test:pass":2,"test:fail":2,"test:plan":2,"test:diagnostic":\d+}$/); | |
assert.match(stdout, /{"test:lifecycle:run":4,"test:start":4,"test:pass":2,"test:fail":2,"test:plan":2,"test:diagnostic":\d+}$/); |
there should be a deterministic number of tests running
there seem to be related test failures |
lib/internal/test_runner/test.js
Outdated
@@ -189,7 +189,7 @@ class Test extends AsyncResource { | |||
this.nesting = 0; | |||
this.only = testOnlyFlag; | |||
this.reporter = new TestsStream(); | |||
this.reporter.begin(this.nesting, kFilename, this.testNumber, this.name, 'starting', 'starting'); | |||
// this.reporter.lifecycleRun(this.nesting, kFilename, this.testNumber, this.name, 'starting', 'starting'); |
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.
will remove comments in next commit if CI passes.
CI was passing. Removed the comments. I think I can proceed with the doc changes as well. |
85a46a4
to
f7dbe8a
Compare
@@ -782,6 +782,8 @@ class Suite extends Test { | |||
} | |||
|
|||
async run() { | |||
|
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.
please revert
@@ -478,7 +478,7 @@ class Test extends AsyncResource { | |||
this.parent.addPendingSubtest(deferred); | |||
return deferred.promise; | |||
} | |||
|
|||
this.reporter.lifecycleRun(this.nesting, kFilename, this.testNumber, this.name, 'starting', 'starting'); |
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 this should be emitted before the if
@@ -29,6 +29,10 @@ class TestsStream extends Readable { | |||
} | |||
} | |||
|
|||
lifecycleRun(nesting, file, testNumber, name, details) { | |||
this[kEmitMessage]('test:lifecycle:run', { __proto__: null, name, nesting, file, testNumber, details }); |
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 test:enqueue
is a better name, @cjihrig WDYT?
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 don't feel too strongly, but I wouldn't say "enqueue" just rolls off the tongue.
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 agree, but in terms of distinction from test:start
I think it is much better than test:lifecycle:run
emit a start event to show message just after a test/subtest start
Fixes: #46727