-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
test_runner: propagate --experimental-config-file to child processes #59047
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
base: main
Are you sure you want to change the base?
Conversation
Allow --experimental-config-file to be passed to child test processes while preventing duplicate coverage reports by disabling coverage collection in child processes through NODE_TEST_DISABLE_COVERAGE environment variable. This fixes config file options not being applied in child processes while maintaining the fix for duplicate coverage reports. Fixes: nodejs#59021
Review requested:
|
…sses Use the existing NODE_TEST_CONTEXT environment variable to prevent duplicate coverage reports in child processes instead of introducing a new NODE_TEST_DISABLE_COVERAGE variable. This approach is more consistent with the existing codebase patterns. The NODE_TEST_CONTEXT variable is already used to identify when running in a child process context, making it the appropriate mechanism for controlling coverage collection behavior. Fixes: nodejs#59021
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #59047 +/- ##
==========================================
- Coverage 90.06% 90.05% -0.01%
==========================================
Files 645 645
Lines 189130 189130
Branches 37094 37098 +4
==========================================
- Hits 170339 170323 -16
- Misses 11511 11516 +5
- Partials 7280 7291 +11
🚀 New features to boost your workflow:
|
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.
Awesome, thanks for tackling this!
I think though that we need more end to end tests related to config propagation so we end the musical chairs.
Ordinarily, I would say tackle in a follow-up PR, but we've already broken one thing fixing another a couple times now.
Perhaps those tests could be added in a separate PR, and the ones that fail we mark "expected to fail", and land that first. Then, in this PR unmark the addressed failures. If any remain in "expected to fail", we create tickets to subsequently fix.
@JakobJingleheimer Thanks for the feedback! I'd like to create a comprehensive test suite to prevent Could you provide more specific guidance on what end-to-end tests you'd like to see? I'm thinking of Config file propagation scenarios:
|
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'm temporarily blocking the PR to better discuss this matter.
One important note: we deliberately removed this flag, as it could lead to side effects — for example, the duplicated report we saw with @JakobJingleheimer.
Reintroducing it could cause potential issues, such as the one described here: #58828.
I believe we might address this problem by supporting a new way to filter options, regardless of whether a config file is present.
From my perspective, we should be able to define user-defined options without requiring the runner to know the source of the option (flag or configuration file).
I'm still considering a potential solution that avoids hardcoding logic in conjunction with configurations.
Edit: We might end up deciding that we're fine with filtering via NODE_TEST_CONTEXT. The reason I removed this from propagation was that my initial intention, when I first introduced the testRunner namespace in the config file, was to avoid propagation.
I don't have strong opinions against using the environment variable, but I want to highlight that this creates a mismatch between how the config file options are filtered compared to the default approach.
cc @nodejs/test_runner
I think maybe the approach we want is to explicitly allow and disallow test-runner options to propagate. In that case, we'd want to have a test that checks the full list of test-runner config options and fails when any option are not explicitly allowed/disallowed; this will catch when a new option is added but wasn't accounted for (which I imagine will be very easy to occur). I think what should happen is to compose the list of config options for the main thread, and then compose a subset for runner that allows/disallows specific ones, and then merges those into the These are the test-runner config options I found (there my be others, but this looks like all of 'em): Caution
Maaaaybe we need to expand the full list to all options though?
|
Hey @JakobJingleheimer,
This is already happening with one exception: the configuration file. At the moment, the biggest issue is that we're filtering specific flags based on the node/lib/internal/test_runner/runner.js Lines 139 to 142 in 35e599b
This wasn't a problem until we introduced the config file, which is passed as a single flag. For this reason, I agree with you regarding the behaviour. I was thinking about reusing: // getCLIOptionsValues() would serialize the option values from C++ land.
// It would error if the values are queried before bootstrap is
// complete so that we don't accidentally include runtime-dependent
// states into a runtime-independent snapshot.
function getCLIOptionsFromBinding() {
return optionsDict ??= getCLIOptionsValues();
} (from options.js) But this function retrieves all the options, not only the user input. Line 40 in 35e599b
WDYT? |
Yes, that's what I meant 🙂 But actually, maybe this util is broadly useful? Now that I think of it, does |
Summary
This PR fixes an issue where
--experimental-config-file
was not being propagated to child test processes, causing experimental features defined in the config file to not work in test isolation mode.The solution implements a more nuanced approach that:
--experimental-config-file
to be propagated to child processesPrevents duplicate coverage reports by disabling coverage in child processes viaNODE_TEST_DISABLE_COVERAGE
environment variableNODE_TEST_CONTEXT
environment variable to disablecoverage in child processes
Changes
lib/internal/test_runner/runner.js:
--experimental-config-file
fromkFilterArgValues
to allow propagationAddedNODE_TEST_DISABLE_COVERAGE=1
to child process environmentlib/internal/test_runner/utils.js:
Modified coverage detection to checkNODE_TEST_DISABLE_COVERAGE
environment variableNODE_TEST_CONTEXT
environment variable (which is already set for child processes)test/parallel/test-runner-cli.js:
test/fixtures/test-runner/options-propagation/experimental-config-file.test.mjs:
Fixes: #59021