Skip to content

test_runner: pass processExecArgv and globPatterns to run() instead of reading process directly#63580

Open
AliMahmoudDev wants to merge 2 commits into
nodejs:mainfrom
AliMahmoudDev:fix/test-runner-process-reads
Open

test_runner: pass processExecArgv and globPatterns to run() instead of reading process directly#63580
AliMahmoudDev wants to merge 2 commits into
nodejs:mainfrom
AliMahmoudDev:fix/test-runner-process-reads

Conversation

@AliMahmoudDev
Copy link
Copy Markdown

@AliMahmoudDev AliMahmoudDev commented May 26, 2026

Summary

Captures process.execArgv and process.argv at the CLI entry point (lib/internal/main/test_runner.js) and passes them through as explicit options to run(). This reduces the coupling between the public run() API and global process state.

Refs: #53867

Changes

lib/internal/main/test_runner.js

  • Captures process.execArgv at CLI startup and passes it as options.processExecArgv to run()
  • globPatterns (from process.argv[1:]) is already passed to run() (unchanged)

lib/internal/test_runner/runner.js

  • Adds processExecArgv option to run() with process.execArgv as backward-compatible default
  • Passes processExecArgv through the opts object to runTestFile() and getRunArgs()
  • Replaces direct process.execArgv read in getRunArgs() with the passed parameter
  • Replaces direct process.argv[1:] read in getRunArgs() with globPatterns

test/parallel/test-runner-run.mjs

  • Adds test that processExecArgv defaults to process.execArgv for backward compatibility
  • Adds test that an empty processExecArgv array works correctly

Backward Compatibility

The processExecArgv option defaults to process.execArgv, so existing programmatic callers of run() that don't pass this option will continue to work identically.

Related

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels May 26, 2026
…gv directly

Captures process.execArgv at the CLI entry point (main/test_runner.js)
and passes it through as an explicit option to run(). This removes
direct reads of process.execArgv and process.argv inside getRunArgs()
in the test runner.

Changes:
- Add processExecArgv option to run() (defaults to process.execArgv
  for backward compatibility)
- Pass processExecArgv from main/test_runner.js to run()
- Replace process.execArgv read in getRunArgs() with the passed option
- Replace process.argv read in getRunArgs() with globPatterns

Refs: nodejs#53867
Signed-off-by: AliMahmoudDev <123aliactionx5@gmail.com>
@AliMahmoudDev AliMahmoudDev force-pushed the fix/test-runner-process-reads branch from f20c005 to 2717a31 Compare May 26, 2026 08:30
Adds two tests to verify the new processExecArgv option:
- Test that processExecArgv defaults to process.execArgv for backward compat
- Test that an empty processExecArgv array works correctly

Refs: nodejs#53867
Signed-off-by: AliMahmoudDev <123aliactionx5@gmail.com>
@AliMahmoudDev AliMahmoudDev changed the title test: pass processExecArgv to run() instead of reading process.execArgv directly test_runner: pass processExecArgv and globPatterns to run() instead of reading process directly May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants