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: support defining test reporter in NODE_OPTIONS #46688

Merged
merged 7 commits into from
Mar 14, 2023

Conversation

SRHerzog
Copy link
Contributor

Adds --test-reporter and --test-reporter-destination as allowable options in NODE_OPTIONS.

Fixes: #46484

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. dont-land-on-v14.x needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels Feb 16, 2023
lib/internal/test_runner/runner.js Outdated Show resolved Hide resolved
@SRHerzog SRHerzog marked this pull request as ready for review February 23, 2023 14:43
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`
Copy link
Member

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

Copy link
Contributor Author

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
doc/api/cli.md Outdated
Comment on lines 1437 to 1442
### `--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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
### `--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.

Copy link
Contributor

@aduh95 aduh95 left a 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

## Environment variables

Also, consider renaming it to e.g. NODE_TEST_CONTEXT.

src/node_options.h Outdated Show resolved Hide resolved
@MoLow MoLow requested a review from cjihrig March 12, 2023 06:44
Copy link
Contributor

@cjihrig cjihrig left a 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.

Comment on lines 176 to 177
let destinations = getOptionValue('--test-reporter-destination');
let reporters = getOptionValue('--test-reporter');
Copy link
Contributor

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
Comment on lines 2268 to 2270
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.
Copy link
Contributor

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.

Copy link
Member

Choose a reason for hiding this comment

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

+1 on removing

Copy link
Member

@benjamingr benjamingr left a 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

@MoLow
Copy link
Member

MoLow commented Mar 13, 2023

Please fix lint issue

@MoLow MoLow added the request-ci Add this label to start a Jenkins CI on a PR. label Mar 13, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 13, 2023
@nodejs-github-bot
Copy link
Collaborator

@MoLow MoLow added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 13, 2023
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@MoLow MoLow added the commit-queue Add this label to land a pull request using GitHub Actions. label Mar 14, 2023
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Mar 14, 2023
@nodejs-github-bot
Copy link
Collaborator

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)

Executing: git node land --amend --yes
⚠ Found Fixes: #46484, skipping..
--------------------------------- New Message ----------------------------------
test_runner: support defining test reporter in NODE_OPTIONS

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]

[detached HEAD 2edb1a293e] test_runner: support defining test reporter in NODE_OPTIONS
Author: Steve Herzog [email protected]
Date: Thu Feb 16 12:53:18 2023 -0600
5 files changed, 38 insertions(+), 16 deletions(-)
Rebasing (3/14)
Rebasing (4/14)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
fix lint errors

PR-URL: #46688
Fixes: #46484
Reviewed-By: Moshe Atlow [email protected]
Reviewed-By: Colin Ihrig [email protected]
Reviewed-By: Benjamin Gruenbaum [email protected]

[detached HEAD f4efd8f31a] fix lint errors
Author: Steve Herzog [email protected]
Date: Thu Feb 23 10:05:23 2023 -0600
2 files changed, 2 insertions(+), 2 deletions(-)
Rebasing (5/14)
Rebasing (6/14)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
replace CLI flag with environment variable

PR-URL: #46688
Fixes: #46484
Reviewed-By: Moshe Atlow [email protected]
Reviewed-By: Colin Ihrig [email protected]
Reviewed-By: Benjamin Gruenbaum [email protected]

[detached HEAD 10a716a067] replace CLI flag with environment variable
Author: Steve Herzog [email protected]
Date: Fri Mar 3 14:36:43 2023 -0600
3 files changed, 3 insertions(+), 6 deletions(-)
Rebasing (7/14)
Rebasing (8/14)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
remove --test-child-process from CLI doc

PR-URL: #46688
Fixes: #46484
Reviewed-By: Moshe Atlow [email protected]
Reviewed-By: Colin Ihrig [email protected]
Reviewed-By: Benjamin Gruenbaum [email protected]

[detached HEAD 8ade1e3b8b] remove --test-child-process from CLI doc
Author: Steve Herzog [email protected]
Date: Tue Mar 7 09:49:27 2023 -0600
1 file changed, 6 deletions(-)
Rebasing (9/14)
Rebasing (10/14)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
rename env var and clean up docs

PR-URL: #46688
Fixes: #46484
Reviewed-By: Moshe Atlow [email protected]
Reviewed-By: Colin Ihrig [email protected]
Reviewed-By: Benjamin Gruenbaum [email protected]

[detached HEAD f6c671172c] rename env var and clean up docs
Author: Steve Herzog [email protected]
Date: Fri Mar 10 12:47:12 2023 -0600
4 files changed, 9 insertions(+), 3 deletions(-)
Rebasing (11/14)
Rebasing (12/14)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
minor code and doc cleanup

PR-URL: #46688
Fixes: #46484
Reviewed-By: Moshe Atlow [email protected]
Reviewed-By: Colin Ihrig [email protected]
Reviewed-By: Benjamin Gruenbaum [email protected]

[detached HEAD 8bb5268926] minor code and doc cleanup
Author: Steve Herzog [email protected]
Date: Mon Mar 13 11:30:02 2023 -0500
2 files changed, 5 insertions(+), 5 deletions(-)
Rebasing (13/14)
Rebasing (14/14)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
fix lint error

PR-URL: #46688
Fixes: #46484
Reviewed-By: Moshe Atlow [email protected]
Reviewed-By: Colin Ihrig [email protected]
Reviewed-By: Benjamin Gruenbaum [email protected]

[detached HEAD 95d0360654] fix lint error
Author: Steve Herzog [email protected]
Date: Mon Mar 13 11:47:18 2023 -0500
1 file changed, 1 insertion(+), 1 deletion(-)

Successfully rebased and updated refs/heads/main.

ℹ Add commit-queue-squash label to land the PR as one commit, or commit-queue-rebase to land as separate commits.

https://github.com/nodejs/node/actions/runs/4418134815

@MoLow MoLow added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Mar 14, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Mar 14, 2023
@nodejs-github-bot nodejs-github-bot merged commit 334bb17 into nodejs:main Mar 14, 2023
@nodejs-github-bot
Copy link
Collaborator

Landed in 334bb17

targos pushed a commit that referenced this pull request Mar 18, 2023
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]>
danielleadams pushed a commit that referenced this pull request Jul 6, 2023
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]>
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. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. 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.

Support defining test reporter using environment variable
7 participants