Skip to content

Conversation

@cjihrig
Copy link
Contributor

Opening as a draft. Some of this logic is from #53921. I also still need to finish docs and tests. I've added @MoLow as a co-author because the work in #51579 was very helpful.

This commit introduces a new --experimental-test-isolation flag that, when set to 'none', causes the test runner to execute all tests in the same process. By default, this is the main test runner process, but if watch mode is enabled, it spawns a separate process that runs all of the tests.

The default value of the new flag is 'process', which uses the existing behavior of running each test file in its own child process.

It is worth noting that when the isolation mode is 'none', globals and all other top level logic (such as top level hooks) is shared among all files.

Fixes: #51548

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-botnodejs-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 Jul 18, 2024
@matthewp
Copy link

Has there been discussion about changing the default in a future major or is that off the table?

@cjihrig
Copy link
ContributorAuthor

There has not been any discussion and it is not off the table.

@jsumners
Copy link
Contributor

Please never make this the default.

@cjihrigcjihrig added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 18, 2024
@github-actionsgithub-actionsbot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 18, 2024
@nodejs-github-bot
Copy link
Collaborator

@cjihrigcjihrigforce-pushed the isolation branch 5 times, most recently from 395ddf1 to 6fa5bf3CompareAugust 18, 2024 20:36
@cjihrigcjihrig marked this pull request as ready for review August 18, 2024 20:39
@cjihrig
Copy link
ContributorAuthor

Marking as ready for review. I still want to rebase this on #54423 when it lands (hopefully tomorrow). From some quick testing, the performance appears to be on par with node:test (no --test) flag.

@codecov
Copy link

codecovbot commented Aug 18, 2024

Codecov Report

Attention: Patch coverage is 76.88679% with 49 lines in your changes missing coverage. Please review.

Project coverage is 87.34%. Comparing base (5376e69) to head (c96455c).
Report is 335 commits behind head on main.

Files with missing linesPatch %Lines
lib/internal/test_runner/runner.js73.33%40 Missing ⚠️
lib/internal/test_runner/utils.js76.00%6 Missing ⚠️
src/node_options.cc57.14%2 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #53927 +/- ## ========================================== + Coverage 87.31% 87.34% +0.02%  ========================================== Files 648 649 +1 Lines 182365 182544 +179 Branches 34985 35033 +48 ========================================== + Hits 159232 159438 +206 + Misses 16399 16371 -28 - Partials 6734 6735 +1 
Files with missing linesCoverage Δ
lib/internal/main/test_runner.js100.00% <100.00%> (ø)
lib/internal/test_runner/harness.js92.30% <100.00%> (+2.39%)⬆️
lib/internal/test_runner/test.js98.36% <100.00%> (+0.01%)⬆️
src/env-inl.h96.55% <100.00%> (-0.24%)⬇️
src/node_options.h98.18% <100.00%> (+0.01%)⬆️
src/node_options.cc87.82% <57.14%> (-0.32%)⬇️
lib/internal/test_runner/utils.js62.77% <76.00%> (+1.66%)⬆️
lib/internal/test_runner/runner.js88.41% <73.33%> (+3.97%)⬆️

... and 28 files with indirect coverage changes

Copy link
Member

@mcollinamcollina left a comment

Choose a reason for hiding this comment

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

lgtm

This commit updates the way the test runner computes inherited hooks. Instead of computing them when the Test/Suite is constructed, they are now computed just prior to running the Test/Suite. The reason is because when multiple test files are run in the same process, it is possible for the inherited hooks to change as more files are loaded.
@cjihrigcjihrig added the commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. label Aug 21, 2024
@cjihrig
Copy link
ContributorAuthor

CI is green. This just needs a reapproval.

Copy link
Member

@mcollinamcollina left a comment

Choose a reason for hiding this comment

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

lgtm

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

Landed in 821ffab...cc26951

nodejs-github-bot pushed a commit that referenced this pull request Aug 21, 2024
This commit updates the way the test runner computes inherited hooks. Instead of computing them when the Test/Suite is constructed, they are now computed just prior to running the Test/Suite. The reason is because when multiple test files are run in the same process, it is possible for the inherited hooks to change as more files are loaded. PR-URL: #53927Fixes: #51548 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
nodejs-github-bot pushed a commit that referenced this pull request Aug 21, 2024
This commit introduces a new --experimental-test-isolation flag that, when set to 'none', causes the test runner to execute all tests in the same process. By default, this is the main test runner process, but if watch mode is enabled, it spawns a separate process that runs all of the tests. The default value of the new flag is 'process', which uses the existing behavior of running each test file in its own child process. It is worth noting that when the isolation mode is 'none', globals and all other top level logic (such as top level before() and after() hooks) is shared among all files. Co-authored-by: Moshe Atlow <[email protected]> PR-URL: #53927Fixes: #51548 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
@cjihrigcjihrig deleted the isolation branch August 21, 2024 13:39
RafaelGSS pushed a commit that referenced this pull request Aug 25, 2024
This commit updates the way the test runner computes inherited hooks. Instead of computing them when the Test/Suite is constructed, they are now computed just prior to running the Test/Suite. The reason is because when multiple test files are run in the same process, it is possible for the inherited hooks to change as more files are loaded. PR-URL: #53927Fixes: #51548 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
RafaelGSS pushed a commit that referenced this pull request Aug 25, 2024
This commit introduces a new --experimental-test-isolation flag that, when set to 'none', causes the test runner to execute all tests in the same process. By default, this is the main test runner process, but if watch mode is enabled, it spawns a separate process that runs all of the tests. The default value of the new flag is 'process', which uses the existing behavior of running each test file in its own child process. It is worth noting that when the isolation mode is 'none', globals and all other top level logic (such as top level before() and after() hooks) is shared among all files. Co-authored-by: Moshe Atlow <[email protected]> PR-URL: #53927Fixes: #51548 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
RafaelGSS added a commit that referenced this pull request Aug 25, 2024
Notable changes: net: * (SEMVER-MINOR) exclude ipv6 loopback addresses from server.listen (Giovanni Bucci) #54264 test_runner: * (SEMVER-MINOR) add support for coverage thresholds (Aviv Keller) #54429 * (SEMVER-MINOR) support running tests in process (Colin Ihrig) #53927 * (SEMVER-MINOR) defer inheriting hooks until run() (Colin Ihrig) #53927 PR-URL: TODO
@RafaelGSSRafaelGSS mentioned this pull request Aug 25, 2024
RafaelGSS added a commit that referenced this pull request Aug 25, 2024
Notable changes: net: * (SEMVER-MINOR) exclude ipv6 loopback addresses from server.listen (Giovanni Bucci) #54264 test_runner: * (SEMVER-MINOR) add support for coverage thresholds (Aviv Keller) #54429 * (SEMVER-MINOR) support running tests in process (Colin Ihrig) #53927 * (SEMVER-MINOR) defer inheriting hooks until run() (Colin Ihrig) #53927 PR-URL: #54560
RafaelGSS pushed a commit that referenced this pull request Aug 30, 2024
This commit introduces a new --experimental-test-isolation flag that, when set to 'none', causes the test runner to execute all tests in the same process. By default, this is the main test runner process, but if watch mode is enabled, it spawns a separate process that runs all of the tests. The default value of the new flag is 'process', which uses the existing behavior of running each test file in its own child process. It is worth noting that when the isolation mode is 'none', globals and all other top level logic (such as top level before() and after() hooks) is shared among all files. Co-authored-by: Moshe Atlow <[email protected]> PR-URL: #53927Fixes: #51548 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
RafaelGSS added a commit that referenced this pull request Aug 30, 2024
Notable changes: net: * (SEMVER-MINOR) exclude ipv6 loopback addresses from server.listen (Giovanni Bucci) #54264 src: * (SEMVER-MINOR) add JS APIs for compile cache and NODE_DISABLE_COMPILE_CACHE (Joyee Cheung) #54501 src,lib: * (SEMVER-MINOR) add performance.uvMetricsInfo (Rafael Gonzaga) #54413 test_runner: * (SEMVER-MINOR) add support for coverage thresholds (Aviv Keller) #54429 * (SEMVER-MINOR) support running tests in process (Colin Ihrig) #53927 * (SEMVER-MINOR) defer inheriting hooks until run() (Colin Ihrig) #53927 vm: * (SEMVER-MINOR) introduce vanilla contexts via vm.constants.DONT_CONTEXTIFY (Joyee Cheung) #54394 PR-URL: #54560
RafaelGSS added a commit that referenced this pull request Aug 30, 2024
Notable changes: net: * (SEMVER-MINOR) exclude ipv6 loopback addresses from server.listen (Giovanni Bucci) #54264 src: * (SEMVER-MINOR) add JS APIs for compile cache and NODE_DISABLE_COMPILE_CACHE (Joyee Cheung) #54501 src,lib: * (SEMVER-MINOR) add performance.uvMetricsInfo (Rafael Gonzaga) #54413 test_runner: * (SEMVER-MINOR) add support for coverage thresholds (Aviv Keller) #54429 * (SEMVER-MINOR) support running tests in process (Colin Ihrig) #53927 * (SEMVER-MINOR) defer inheriting hooks until run() (Colin Ihrig) #53927 vm: * (SEMVER-MINOR) introduce vanilla contexts via vm.constants.DONT_CONTEXTIFY (Joyee Cheung) #54394 PR-URL: #54560
RafaelGSS added a commit that referenced this pull request Aug 31, 2024
Notable changes: net: * (SEMVER-MINOR) exclude ipv6 loopback addresses from server.listen (Giovanni Bucci) #54264 src: * (SEMVER-MINOR) add JS APIs for compile cache and NODE_DISABLE_COMPILE_CACHE (Joyee Cheung) #54501 src,lib: * (SEMVER-MINOR) add performance.uvMetricsInfo (Rafael Gonzaga) #54413 test_runner: * (SEMVER-MINOR) add support for coverage thresholds (Aviv Keller) #54429 * (SEMVER-MINOR) support running tests in process (Colin Ihrig) #53927 * (SEMVER-MINOR) defer inheriting hooks until run() (Colin Ihrig) #53927 vm: * (SEMVER-MINOR) introduce vanilla contexts via vm.constants.DONT_CONTEXTIFY (Joyee Cheung) #54394 PR-URL: #54560
RafaelGSS added a commit that referenced this pull request Aug 31, 2024
Notable changes: net: * (SEMVER-MINOR) exclude ipv6 loopback addresses from server.listen (Giovanni Bucci) #54264 src: * (SEMVER-MINOR) add JS APIs for compile cache and NODE_DISABLE_COMPILE_CACHE (Joyee Cheung) #54501 src,lib: * (SEMVER-MINOR) add performance.uvMetricsInfo (Rafael Gonzaga) #54413 test_runner: * (SEMVER-MINOR) add support for coverage thresholds (Aviv Keller) #54429 * (SEMVER-MINOR) support running tests in process (Colin Ihrig) #53927 * (SEMVER-MINOR) defer inheriting hooks until run() (Colin Ihrig) #53927 vm: * (SEMVER-MINOR) introduce vanilla contexts via vm.constants.DONT_CONTEXTIFY (Joyee Cheung) #54394 PR-URL: #54560
RafaelGSS added a commit that referenced this pull request Sep 1, 2024
Notable changes: net: * (SEMVER-MINOR) exclude ipv6 loopback addresses from server.listen (Giovanni Bucci) #54264 src: * (SEMVER-MINOR) add JS APIs for compile cache and NODE_DISABLE_COMPILE_CACHE (Joyee Cheung) #54501 src,lib: * (SEMVER-MINOR) add performance.uvMetricsInfo (Rafael Gonzaga) #54413 test_runner: * (SEMVER-MINOR) add support for coverage thresholds (Aviv Keller) #54429 * (SEMVER-MINOR) support running tests in process (Colin Ihrig) #53927 * (SEMVER-MINOR) defer inheriting hooks until run() (Colin Ihrig) #53927 vm: * (SEMVER-MINOR) introduce vanilla contexts via vm.constants.DONT_CONTEXTIFY (Joyee Cheung) #54394 PR-URL: #54560
RafaelGSS added a commit that referenced this pull request Sep 2, 2024
Notable changes: net: * (SEMVER-MINOR) exclude ipv6 loopback addresses from server.listen (Giovanni Bucci) #54264 src: * (SEMVER-MINOR) add JS APIs for compile cache and NODE_DISABLE_COMPILE_CACHE (Joyee Cheung) #54501 src,lib: * (SEMVER-MINOR) add performance.uvMetricsInfo (Rafael Gonzaga) #54413 test_runner: * (SEMVER-MINOR) add support for coverage thresholds (Aviv Keller) #54429 * (SEMVER-MINOR) support running tests in process (Colin Ihrig) #53927 * (SEMVER-MINOR) defer inheriting hooks until run() (Colin Ihrig) #53927 vm: * (SEMVER-MINOR) introduce vanilla contexts via vm.constants.DONT_CONTEXTIFY (Joyee Cheung) #54394 PR-URL: #54560
RafaelGSS added a commit that referenced this pull request Sep 3, 2024
Notable changes: net: * (SEMVER-MINOR) exclude ipv6 loopback addresses from server.listen (Giovanni Bucci) #54264 src: * (SEMVER-MINOR) add JS APIs for compile cache and NODE_DISABLE_COMPILE_CACHE (Joyee Cheung) #54501 src,lib: * (SEMVER-MINOR) add performance.uvMetricsInfo (Rafael Gonzaga) #54413 test_runner: * (SEMVER-MINOR) add support for coverage thresholds (Aviv Keller) #54429 * (SEMVER-MINOR) support running tests in process (Colin Ihrig) #53927 * (SEMVER-MINOR) defer inheriting hooks until run() (Colin Ihrig) #53927 vm: * (SEMVER-MINOR) introduce vanilla contexts via vm.constants.DONT_CONTEXTIFY (Joyee Cheung) #54394 PR-URL: #54560
RafaelGSS added a commit that referenced this pull request Sep 3, 2024
Notable changes: net: * (SEMVER-MINOR) exclude ipv6 loopback addresses from server.listen (Giovanni Bucci) #54264 src: * (SEMVER-MINOR) add JS APIs for compile cache and NODE_DISABLE_COMPILE_CACHE (Joyee Cheung) #54501 src,lib: * (SEMVER-MINOR) add performance.uvMetricsInfo (Rafael Gonzaga) #54413 test_runner: * (SEMVER-MINOR) add support for coverage thresholds (Aviv Keller) #54429 * (SEMVER-MINOR) support running tests in process (Colin Ihrig) #53927 * (SEMVER-MINOR) defer inheriting hooks until run() (Colin Ihrig) #53927 vm: * (SEMVER-MINOR) introduce vanilla contexts via vm.constants.DONT_CONTEXTIFY (Joyee Cheung) #54394 PR-URL: #54560
@targostargos 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
louwers pushed a commit to louwers/node that referenced this pull request Nov 2, 2024
Notable changes: net: * (SEMVER-MINOR) exclude ipv6 loopback addresses from server.listen (Giovanni Bucci) nodejs#54264 src: * (SEMVER-MINOR) add JS APIs for compile cache and NODE_DISABLE_COMPILE_CACHE (Joyee Cheung) nodejs#54501 src,lib: * (SEMVER-MINOR) add performance.uvMetricsInfo (Rafael Gonzaga) nodejs#54413 test_runner: * (SEMVER-MINOR) add support for coverage thresholds (Aviv Keller) nodejs#54429 * (SEMVER-MINOR) support running tests in process (Colin Ihrig) nodejs#53927 * (SEMVER-MINOR) defer inheriting hooks until run() (Colin Ihrig) nodejs#53927 vm: * (SEMVER-MINOR) introduce vanilla contexts via vm.constants.DONT_CONTEXTIFY (Joyee Cheung) nodejs#54394 PR-URL: nodejs#54560
tpoisseau pushed a commit to tpoisseau/node that referenced this pull request Nov 21, 2024
Notable changes: net: * (SEMVER-MINOR) exclude ipv6 loopback addresses from server.listen (Giovanni Bucci) nodejs#54264 src: * (SEMVER-MINOR) add JS APIs for compile cache and NODE_DISABLE_COMPILE_CACHE (Joyee Cheung) nodejs#54501 src,lib: * (SEMVER-MINOR) add performance.uvMetricsInfo (Rafael Gonzaga) nodejs#54413 test_runner: * (SEMVER-MINOR) add support for coverage thresholds (Aviv Keller) nodejs#54429 * (SEMVER-MINOR) support running tests in process (Colin Ihrig) nodejs#53927 * (SEMVER-MINOR) defer inheriting hooks until run() (Colin Ihrig) nodejs#53927 vm: * (SEMVER-MINOR) introduce vanilla contexts via vm.constants.DONT_CONTEXTIFY (Joyee Cheung) nodejs#54394 PR-URL: nodejs#54560
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.commit-queue-rebaseAdd this label to allow the Commit Queue to land a PR in several commits.dont-land-on-v20.xPRs that should not land on the v20.x-staging branch and should not be released in v20.x.lib / srcIssues and PRs related to general changes in the lib or src directory.semver-minorPRs that contain new features and should be released in the next minor version.test_runnerIssues and PRs related to the test runner subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow to run tests in the main process

9 participants

@cjihrig@nodejs-github-bot@matthewp@jsumners@mcollina@benjamingr@MoLow@avivkeller@targos