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: remove problematic uses of parseCommandLine() #54353

Closed
wants to merge 6 commits into from

Conversation

cjihrig
Copy link
Contributor

@cjihrig cjihrig commented Aug 13, 2024

This PR removes uses of parseCommandLine() throughout the test runner. This work is related to #53867, as it reduces the use of process global state in the test runner where it should not be used.

test_runner: use run() argument names in parseCommandLine()

This commit updates parseCommandLine() to use the names supported
by run(). This removes some unnecessary renaming code, and allows
node:test and run() to more easily share code.

test_runner: pass harness object as option to root test

This commit initializes the root harness object before the root
test and passes the harness as an option to the root test
constructor. This commit also attaches the global configuration
to the harness. This will allow the parseCommandLine() call in
test.js to be removed, as those values are now available via
the root test.

test_runner: pass global options to createTestTree()

The global configuration should already be known when
createTestTree() is called. This commit updates that function
to take the global configuration as an input.

test_runner: return setup() from parseCommandLine()

Now that parseCommandLine() returns run() compatible arguments,
it makes sense to return setupTestReporters() as the setup()
argument to run(). This also removes another problematic use of
parseCommandLine() in setupTestReporters().

test_runner: refactor hook creation

This commit makes hook creation more consistent by always
passing in a reference to the test that owns the hook. It also
removes some unnecessary validation on internal API.

test_runner: remove parseCommandLine() from test.js

The lib/internal/test_runner/test.js file should not use the
parseCommandLine() function. This commit refactors the code to
avoid doing so.

This commit updates parseCommandLine() to use the names supported
by run(). This removes some unnecessary renaming code, and allows
node:test and run() to more easily share code.
This commit initializes the root harness object before the root
test and passes the harness as an option to the root test
constructor. This commit also attaches the global configuration
to the harness. This will allow the parseCommandLine() call in
test.js to be removed, as those values are now available via
the root test.
The global configuration should already be known when
createTestTree() is called. This commit updates that function
to take the global configuration as an input.
Now that parseCommandLine() returns run() compatible arguments,
it makes sense to return setupTestReporters() as the setup()
argument to run(). This also removes another problematic use of
parseCommandLine() in setupTestReporters().
This commit makes hook creation more consistent by always
passing in a reference to the test that owns the hook. It also
removes some unnecessary validation on internal API.
The lib/internal/test_runner/test.js should not use the
parseCommandLine() function. This commit refactors the code to
avoid doing so.
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Aug 13, 2024
Copy link

codecov bot commented Aug 13, 2024

Codecov Report

Attention: Patch coverage is 96.55172% with 5 lines in your changes missing coverage. Please review.

Project coverage is 87.10%. Comparing base (d0f5943) to head (44bfa3b).
Report is 409 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/test_runner/utils.js 88.88% 3 Missing ⚠️
lib/internal/test_runner/test.js 96.77% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #54353      +/-   ##
==========================================
+ Coverage   87.09%   87.10%   +0.01%     
==========================================
  Files         648      648              
  Lines      182213   182244      +31     
  Branches    34961    34958       -3     
==========================================
+ Hits       158703   158751      +48     
+ Misses      16794    16784      -10     
+ Partials     6716     6709       -7     
Files with missing lines Coverage Δ
lib/internal/test_runner/harness.js 89.13% <100.00%> (+1.07%) ⬆️
lib/internal/test_runner/runner.js 85.76% <100.00%> (+0.20%) ⬆️
lib/internal/test_runner/test.js 98.35% <96.77%> (+0.18%) ⬆️
lib/internal/test_runner/utils.js 61.11% <88.88%> (ø)

... and 23 files with indirect coverage changes

@RedYetiDev RedYetiDev added the test_runner Issues and PRs related to the test runner subsystem. label Aug 13, 2024
@benjamingr benjamingr added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 13, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 13, 2024
@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Aug 13, 2024

@cjihrig cjihrig added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. and removed needs-ci PRs that need a full CI run. labels Aug 13, 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.

lgtm

@cjihrig cjihrig added the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 15, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Aug 15, 2024
@nodejs-github-bot
Copy link
Collaborator

Landed in e020dd8...48d63c4

nodejs-github-bot pushed a commit that referenced this pull request Aug 15, 2024
This commit updates parseCommandLine() to use the names supported
by run(). This removes some unnecessary renaming code, and allows
node:test and run() to more easily share code.

PR-URL: #54353
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
nodejs-github-bot pushed a commit that referenced this pull request Aug 15, 2024
This commit initializes the root harness object before the root
test and passes the harness as an option to the root test
constructor. This commit also attaches the global configuration
to the harness. This will allow the parseCommandLine() call in
test.js to be removed, as those values are now available via
the root test.

PR-URL: #54353
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
nodejs-github-bot pushed a commit that referenced this pull request Aug 15, 2024
The global configuration should already be known when
createTestTree() is called. This commit updates that function
to take the global configuration as an input.

PR-URL: #54353
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
nodejs-github-bot pushed a commit that referenced this pull request Aug 15, 2024
Now that parseCommandLine() returns run() compatible arguments,
it makes sense to return setupTestReporters() as the setup()
argument to run(). This also removes another problematic use of
parseCommandLine() in setupTestReporters().

PR-URL: #54353
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
nodejs-github-bot pushed a commit that referenced this pull request Aug 15, 2024
This commit makes hook creation more consistent by always
passing in a reference to the test that owns the hook. It also
removes some unnecessary validation on internal API.

PR-URL: #54353
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
nodejs-github-bot pushed a commit that referenced this pull request Aug 15, 2024
The lib/internal/test_runner/test.js should not use the
parseCommandLine() function. This commit refactors the code to
avoid doing so.

PR-URL: #54353
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
@cjihrig cjihrig deleted the test-options branch August 15, 2024 15:32
@MoLow
Copy link
Member

MoLow commented Aug 16, 2024

Nice 👍🏻 thanks for the effort

RafaelGSS pushed a commit that referenced this pull request Aug 19, 2024
This commit updates parseCommandLine() to use the names supported
by run(). This removes some unnecessary renaming code, and allows
node:test and run() to more easily share code.

PR-URL: #54353
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
RafaelGSS pushed a commit that referenced this pull request Aug 19, 2024
This commit initializes the root harness object before the root
test and passes the harness as an option to the root test
constructor. This commit also attaches the global configuration
to the harness. This will allow the parseCommandLine() call in
test.js to be removed, as those values are now available via
the root test.

PR-URL: #54353
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
RafaelGSS pushed a commit that referenced this pull request Aug 19, 2024
The global configuration should already be known when
createTestTree() is called. This commit updates that function
to take the global configuration as an input.

PR-URL: #54353
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
RafaelGSS pushed a commit that referenced this pull request Aug 19, 2024
Now that parseCommandLine() returns run() compatible arguments,
it makes sense to return setupTestReporters() as the setup()
argument to run(). This also removes another problematic use of
parseCommandLine() in setupTestReporters().

PR-URL: #54353
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
RafaelGSS pushed a commit that referenced this pull request Aug 19, 2024
This commit makes hook creation more consistent by always
passing in a reference to the test that owns the hook. It also
removes some unnecessary validation on internal API.

PR-URL: #54353
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
RafaelGSS pushed a commit that referenced this pull request Aug 19, 2024
The lib/internal/test_runner/test.js should not use the
parseCommandLine() function. This commit refactors the code to
avoid doing so.

PR-URL: #54353
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
@RafaelGSS RafaelGSS mentioned this pull request Aug 19, 2024
RafaelGSS pushed a commit that referenced this pull request Aug 21, 2024
This commit updates parseCommandLine() to use the names supported
by run(). This removes some unnecessary renaming code, and allows
node:test and run() to more easily share code.

PR-URL: #54353
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
RafaelGSS pushed a commit that referenced this pull request Aug 21, 2024
This commit initializes the root harness object before the root
test and passes the harness as an option to the root test
constructor. This commit also attaches the global configuration
to the harness. This will allow the parseCommandLine() call in
test.js to be removed, as those values are now available via
the root test.

PR-URL: #54353
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
RafaelGSS pushed a commit that referenced this pull request Aug 21, 2024
The global configuration should already be known when
createTestTree() is called. This commit updates that function
to take the global configuration as an input.

PR-URL: #54353
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
RafaelGSS pushed a commit that referenced this pull request Aug 21, 2024
Now that parseCommandLine() returns run() compatible arguments,
it makes sense to return setupTestReporters() as the setup()
argument to run(). This also removes another problematic use of
parseCommandLine() in setupTestReporters().

PR-URL: #54353
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
RafaelGSS pushed a commit that referenced this pull request Aug 21, 2024
This commit makes hook creation more consistent by always
passing in a reference to the test that owns the hook. It also
removes some unnecessary validation on internal API.

PR-URL: #54353
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
RafaelGSS pushed a commit that referenced this pull request Aug 21, 2024
The lib/internal/test_runner/test.js should not use the
parseCommandLine() function. This commit refactors the code to
avoid doing so.

PR-URL: #54353
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
@targos targos added the dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. label Sep 21, 2024
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. commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. lib / src Issues and PRs related to general changes in the lib or src directory. test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants