GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — test_runner: avoid reading process state directly in run() by murataslan1 · Pull Request #62377 · nodejs/node ConversationRefs: #53867 SummaryThe PR #54705 added Changes
Test plan
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsRefs: nodejs#53867 The run() function is exposed as a public API via node:test module. Previously, it accessed process.argv, process.execArgv, process.cwd(), and process.env directly, which meant programmatic API users could not fully control the test runner behavior. This change: - Captures process.argv, process.cwd(), process.env, and process.execArgv in the CLI entry point (main/test_runner.js) and passes them explicitly to run() as options - Adds a processExecArgv option for V8 flag propagation - Replaces process.env fallback in runTestFile() with opts.env - Replaces process.argv usage in getRunArgs() with globPatterns - Replaces process.env.NODE_TEST_CONTEXT check with env option - Maintains backwards compatibility: when options are not provided, run() falls back to process state as before
Collaborator
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pull request overviewThis PR updates the Node.js test runner so the public Changes:
Reviewed changesCopilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)lib/internal/test_runner/runner.js:787
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Comment on lines
170
to
172
|
| // Capture process state explicitly so run() does not need to access it. | ||
| options.globPatterns = ArrayPrototypeSlice(process.argv, 1); | ||
| options.cwd = process.cwd(); | ||
| options.env = process.env; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
options.env is being set unconditionally, which makes run() think the caller explicitly provided an env option. With --test-isolation=none, run() currently rejects options.env, so this change will break node --test --test-isolation=none. Consider only setting/passing options.env in the CLI when isolation='process' (or update run() to treat this captured env as non-user-provided).
| options.env = process.env; | |
| if (options.isolation === 'process') { | |
| options.env = process.env; | |
| } |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| argv = [], | ||
| cwd = process.cwd(), | ||
| cwd, | ||
| processExecArgv, | ||
| rerunFailuresFilePath, |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
processExecArgv is consumed by getRunArgs() as an array (it is filtered and iterated), but there is no validation for the options.processExecArgv type. If a public API caller passes a non-array value, this will fail at runtime in less obvious ways. Consider validating it (e.g., validateStringArray(processExecArgv, 'options.processExecArgv')) when it is explicitly provided.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Blocking as this needs documentation and tests |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
- Remove processExecArgv option: process.execArgv is runtime state that should not be a public API option. Keep reading it directly in getRunArgs() as before. - Fix env with isolation=none: only set options.env from CLI entry point when isolation is not 'none', preventing ERR_INVALID_ARG_VALUE when using --test-isolation=none. - Add documentation for the env option in doc/api/test.md. - Add tests for env option acceptance and env+isolation=none rejection.
There was an error while loading. Please reload this page.
|
Pushed fixes based on the feedback:
Let me know if anything else needs changing! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
tightened globPatterns validation — now uses validateStringArray for consistency with argv/execArgv. the env+isolation=none edge case was already handled in the earlier commits (cli only sets env when isolation isn't none, and runner.js tracks userProvidedEnv separately). think this should be good to go now, lmk if anything else needs attention |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
this doc change needs a history entry like other changes.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Requested changes must be addressed to merge this pull request.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.