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

test_runner: differentiate test types in enqueue dequeue events #54049

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

EddieAbbondanzio
Copy link
Contributor

The test:enqueue and test:dequeue events now include a type in details to allow reporters to distinguish if it was a suite or test.

Fixes #51235

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels Jul 26, 2024
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

Thanks for opening a PR! Can you please add a unit test?

@EddieAbbondanzio
Copy link
Contributor Author

Sure, I added one.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 27, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 27, 2024
@nodejs-github-bot
Copy link
Collaborator

doc/api/test.md Outdated
@@ -2850,6 +2850,7 @@ The corresponding declaration ordered events are `'test:pass'` and `'test:fail'`
`undefined` if the test was run through the REPL.
* `name` {string} The test name.
* `nesting` {number} The nesting level of the test.
* `type` {string} The test type.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think these docs are currently descriptive enough. Since there are only two possible values, maybe we should list them out.

Copy link
Contributor Author

@EddieAbbondanzio EddieAbbondanzio Jul 29, 2024

Choose a reason for hiding this comment

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

I updated the docs, but I had some trouble thinking of how to phrase it.

@@ -570,7 +570,8 @@ class Test extends AsyncResource {
while (this.pendingSubtests.length > 0 && this.hasConcurrency()) {
const deferred = ArrayPrototypeShift(this.pendingSubtests);
const test = deferred.test;
test.reporter.dequeue(test.nesting, test.loc, test.name);
const type = test.reportedType ?? 'test';
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should make reportedType a property on Test like it is on Suite and drop this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you think we should also a reported type on the TestHook class since it extends Test? I don't think it'll cause any issues, but could lead to future confusion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I set reportedType on TestHook to 'hook'.


stream.on('test:enqueue', common.mustCall((data) => {
if (data.name === 'this is a suite') {
assert.strictEqual(data.type, 'suite');
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no guarantee that any of these assertions will run, even with the common.mustCall() (for example, if the test fixture was changed in the future). I would suggest adding a test plan.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, but I'm not familiar with what a test plan is. Is there an example I could reference?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, you meant this: https://nodejs.org/api/test.html#contextplancount

Good call. I added a plan and it uncovered two of the assertions weren't working due to a leading space in the name.

@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 29, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 29, 2024
@nodejs-github-bot
Copy link
Collaborator

@EddieAbbondanzio EddieAbbondanzio requested a review from cjihrig July 30, 2024 02:22
@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 30, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 30, 2024
@nodejs-github-bot
Copy link
Collaborator

@EddieAbbondanzio
Copy link
Contributor Author

EddieAbbondanzio commented Aug 6, 2024

This PR seems like it may have stagnated. Is there anything needed to get it merged?

@nodejs-github-bot
Copy link
Collaborator

@pmarchini
Copy link
Member

Hey @EddieAbbondanzio, I noticed this PR has been stale since August and some files now have conflicts.
Could you please resolve them?

@EddieAbbondanzio
Copy link
Contributor Author

Hey @pmarchini, I can work on bring it back but do you know why it went stale? Was there something else I needed to do to get it merged after all the approvals it got back in July?

@pmarchini
Copy link
Member

Hey @EddieAbbondanzio, honestly, I can't see any reason why this PR should remain stalled.
I would suggest fixing the conflicts and then landing it 😊

@EddieAbbondanzio EddieAbbondanzio force-pushed the differentiate-test-types-in-events branch from 32c6955 to 56c63e1 Compare January 1, 2025 16:20
Copy link

codecov bot commented Jan 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.54%. Comparing base (35742a2) to head (214b59e).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #54049      +/-   ##
==========================================
- Coverage   88.54%   88.54%   -0.01%     
==========================================
  Files         657      657              
  Lines      190742   190746       +4     
  Branches    36606    36603       -3     
==========================================
- Hits       168901   168888      -13     
- Misses      15027    15039      +12     
- Partials     6814     6819       +5     
Files with missing lines Coverage Δ
lib/internal/test_runner/test.js 96.96% <100.00%> (+<0.01%) ⬆️
lib/internal/test_runner/tests_stream.js 91.71% <100.00%> (+0.09%) ⬆️

... and 23 files with indirect coverage changes

@pmarchini pmarchini added the request-ci Add this label to start a Jenkins CI on a PR. label Jan 2, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jan 2, 2025
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@EddieAbbondanzio
Copy link
Contributor Author

Hey @pmarchini, is there anything on my end I need to do to merge this?

I'm still new to contributing to Node and don't have permissions to add the merge-queue label (seems like that's what this PR needs based on the docs) but I'm also not 100% certain why some of the CI jobs are intermittently failing. Appreciate your help!

@nodejs-github-bot
Copy link
Collaborator

@pmarchini
Copy link
Member

pmarchini commented Jan 3, 2025

Hey @EddieAbbondanzio, you can't do anything else on your side atm 😁
We have some problems with flaky tests, and that's the reason why the CI keeps failing.
I'm restarting it again now!

As soon as the CI is green, and if @cjihrig and @MoLow are still okay with this change, we will land it 🚀

Thank you very much for your patience and your support to Node 🚀

MakotoGew

This comment was marked as spam.

@pmarchini pmarchini added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test_runner: differentiate describe from it in event:enqueue so we can have a total test count
9 participants