-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: support defining test reporter in NODE_OPTIONS #46688
test_runner: support defining test reporter in NODE_OPTIONS #46688
Conversation
Review requested:
|
e9fb4e2
to
15803a0
Compare
doc/api/cli.md
Outdated
@@ -1272,6 +1272,12 @@ added: v19.6.0 | |||
The destination for the corresponding test reporter. See the documentation on | |||
[test reporters][] for more details. | |||
|
|||
### `--test-child-process` |
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 am -1 on this implementation,
CLI flags which are a public API should not be added to solve an internal node core issue
I would prefer to add an environment variable instead.
in addition, @cjihrig has expressed in the past a concern regarding introducing big differences between node test.js
and node --test test.js
- which I agree with, but this case might justify it - it makes more sense to me than parsing CLI flags out of NODE_OPTIONS
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.
You're right, an environment variable makes more sense, since this flag would only be used for the specific case of a parent test process spawning a child, there's no reason to add extra options to the CLI. I'll do a quick update.
Adds --test-reporter and --test-reporter-destination as allowable options in NODE_OPTIONS. Also adds the CLI flag --test-child-process to allow forcing the default test-reporter for inter-process communication. Fixes: nodejs#46484
678bb49
to
c2edafb
Compare
doc/api/cli.md
Outdated
### `--test-child-process` | ||
|
||
A flag to identify the process as a child of another test process to ensure | ||
that test reporting is formatted correctly to be parsed by a parent test | ||
process. | ||
|
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.
### `--test-child-process` | |
A flag to identify the process as a child of another test process to ensure | |
that test reporting is formatted correctly to be parsed by a parent test | |
process. |
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.
We would need to document TEST_CONTEXT
in
Line 1933 in 00c2225
## Environment variables |
Also, consider renaming it to e.g. NODE_TEST_CONTEXT
.
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 with some small comments.
lib/internal/test_runner/utils.js
Outdated
let destinations = getOptionValue('--test-reporter-destination'); | ||
let reporters = getOptionValue('--test-reporter'); |
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 you move the getOptionValue()
calls to the else
branch on line 185.
doc/api/cli.md
Outdated
output will be sent to stdout in the TAP format. This is intended to facilitate | ||
parsing and aggregating test output by a parent process that spawns one or more | ||
children. |
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 last sentence reads a bit like an implementation detail that users shouldn't need to worry about. If others feel it's valuable to include, then you can disregard this comment.
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.
+1 on removing
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 with a preference to both Colin's comments being fixed but lgtm either way
Please fix lint issue |
Commit Queue failed- Loading data for nodejs/node/pull/46688 ✔ Done loading data for nodejs/node/pull/46688 ----------------------------------- PR info ------------------------------------ Title test_runner: support defining test reporter in NODE_OPTIONS (#46688) ⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile! Branch SRHerzog:node-options-test-reporter -> nodejs:main Labels c++, author ready, needs-ci, dont-land-on-v14.x, test_runner Commits 7 - test_runner: support defining test reporter in NODE_OPTIONS - fix lint errors - replace CLI flag with environment variable - remove --test-child-process from CLI doc - rename env var and clean up docs - minor code and doc cleanup - fix lint error Committers 1 - Steve Herzog PR-URL: https://github.com/nodejs/node/pull/46688 Fixes: https://github.com/nodejs/node/issues/46484 Reviewed-By: Moshe Atlow Reviewed-By: Colin Ihrig Reviewed-By: Benjamin Gruenbaum ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/46688 Fixes: https://github.com/nodejs/node/issues/46484 Reviewed-By: Moshe Atlow Reviewed-By: Colin Ihrig Reviewed-By: Benjamin Gruenbaum -------------------------------------------------------------------------------- ℹ This PR was created on Thu, 16 Feb 2023 20:01:26 GMT ✔ Approvals: 3 ✔ - Moshe Atlow (@MoLow): https://github.com/nodejs/node/pull/46688#pullrequestreview-1337613800 ✔ - Colin Ihrig (@cjihrig) (TSC): https://github.com/nodejs/node/pull/46688#pullrequestreview-1336142617 ✔ - Benjamin Gruenbaum (@benjamingr): https://github.com/nodejs/node/pull/46688#pullrequestreview-1336867851 ✔ Last GitHub CI successful ℹ Last Full PR CI on 2023-03-14T10:52:38Z: https://ci.nodejs.org/job/node-test-pull-request/50376/ - Querying data for job/node-test-pull-request/50376/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ No git cherry-pick in progress ✔ No git am in progress ✔ No git rebase in progress -------------------------------------------------------------------------------- - Bringing origin/main up to date... From https://github.com/nodejs/node * branch main -> FETCH_HEAD ✔ origin/main is now up-to-date - Downloading patch for 46688 From https://github.com/nodejs/node * branch refs/pull/46688/merge -> FETCH_HEAD ✔ Fetched commits as 4ae7c7a00258..588f6eadd8c9 -------------------------------------------------------------------------------- Auto-merging doc/api/cli.md Auto-merging lib/internal/test_runner/runner.js Auto-merging lib/internal/test_runner/utils.js [main 9571984ed6] test_runner: support defining test reporter in NODE_OPTIONS Author: Steve Herzog Date: Thu Feb 16 12:53:18 2023 -0600 5 files changed, 38 insertions(+), 16 deletions(-) Auto-merging lib/internal/test_runner/runner.js [main 23116dc8af] fix lint errors Author: Steve Herzog Date: Thu Feb 23 10:05:23 2023 -0600 2 files changed, 2 insertions(+), 2 deletions(-) Auto-merging lib/internal/test_runner/runner.js Auto-merging lib/internal/test_runner/utils.js [main 38d41acac0] replace CLI flag with environment variable Author: Steve Herzog Date: Fri Mar 3 14:36:43 2023 -0600 3 files changed, 3 insertions(+), 6 deletions(-) Auto-merging doc/api/cli.md [main 4613283ba6] remove --test-child-process from CLI doc Author: Steve Herzog Date: Tue Mar 7 09:49:27 2023 -0600 1 file changed, 6 deletions(-) Auto-merging doc/api/cli.md Auto-merging lib/internal/test_runner/runner.js Auto-merging lib/internal/test_runner/utils.js [main 779484a634] rename env var and clean up docs Author: Steve Herzog Date: Fri Mar 10 12:47:12 2023 -0600 4 files changed, 9 insertions(+), 3 deletions(-) Auto-merging doc/api/cli.md Auto-merging lib/internal/test_runner/utils.js [main 7f73305c57] minor code and doc cleanup Author: Steve Herzog Date: Mon Mar 13 11:30:02 2023 -0500 2 files changed, 5 insertions(+), 5 deletions(-) Auto-merging lib/internal/test_runner/utils.js [main 21a3d72501] fix lint error Author: Steve Herzog Date: Mon Mar 13 11:47:18 2023 -0500 1 file changed, 1 insertion(+), 1 deletion(-) ✔ Patches applied There are 7 commits in the PR. Attempting autorebase. Rebasing (2/14)https://github.com/nodejs/node/actions/runs/4418134815 |
Landed in 334bb17 |
Adds --test-reporter and --test-reporter-destination as allowable options in NODE_OPTIONS. Also adds the CLI flag --test-child-process to allow forcing the default test-reporter for inter-process communication. Fixes: #46484 PR-URL: #46688 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
Adds --test-reporter and --test-reporter-destination as allowable options in NODE_OPTIONS. Also adds the CLI flag --test-child-process to allow forcing the default test-reporter for inter-process communication. Fixes: #46484 PR-URL: #46688 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
Adds --test-reporter and --test-reporter-destination as allowable options in NODE_OPTIONS.
Fixes: #46484