GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test_runner: pass global options to createTestTree() · nodejs/node@ed1ede8

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/test_runner
    • harness.js
    • runner.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/test_runner/harness.js‎

Copy file name to clipboardExpand all lines: lib/internal/test_runner/harness.js
+7-6Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ const {
1717
},
1818
} = require('internal/errors');
1919
const { exitCodes: { kGenericUserError } } = internalBinding('errors');
20-
21-
const { kEmptyObject } = require('internal/util');
2220
const { kCancelledByParent, Test, Suite } = require('internal/test_runner/test');
2321
const {
2422
parseCommandLine,
@@ -34,8 +32,7 @@ let globalRoot;
3432

3533
testResources.set(reporterScope.asyncId(), reporterScope);
3634

37-
function createTestTree(options = kEmptyObject) {
38-
const globalOptions = parseCommandLine();
35+
function createTestTree(rootTestOptions, globalOptions) {
3936
const harness = {
4037
__proto__: null,
4138
allowTestsToRun: false,
@@ -65,7 +62,7 @@ function createTestTree(options = kEmptyObject) {
6562
harness.resetCounters();
6663
globalRoot = new Test({
6764
__proto__: null,
68-
...options,
65+
...rootTestOptions,
6966
harness,
7067
name: '<root>',
7168
});
@@ -230,7 +227,11 @@ function lazyBootstrapRoot() {
230227
if (!globalRoot) {
231228
// This is where the test runner is bootstrapped when node:test is used
232229
// without the --test flag or the run() API.
233-
createTestTree({ __proto__: null, entryFile: process.argv?.[1] });
230+
const rootTestOptions = {
231+
__proto__: null,
232+
entryFile: process.argv?.[1],
233+
};
234+
createTestTree(rootTestOptions, parseCommandLine());
234235
globalRoot.reporter.on('test:fail', (data) => {
235236
if (data.todo === undefined || data.todo === false) {
236237
process.exitCode = kGenericUserError;
Collapse file

‎lib/internal/test_runner/runner.js‎

Copy file name to clipboardExpand all lines: lib/internal/test_runner/runner.js
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ const {
6969
convertStringToRegExp,
7070
countCompletedTest,
7171
kDefaultPattern,
72+
parseCommandLine,
7273
} = require('internal/test_runner/utils');
7374
const { Glob } = require('internal/fs/glob');
7475
const { once } = require('events');
@@ -566,7 +567,14 @@ function run(options = kEmptyObject) {
566567
});
567568
}
568569

569-
const root = createTestTree({ __proto__: null, concurrency, timeout, signal });
570+
const rootTestOptions = { __proto__: null, concurrency, timeout, signal };
571+
const globalOptions = {
572+
__proto__: null,
573+
// parseCommandLine() should not be used here. However, The existing run()
574+
// behavior has relied on it, so removing it must be done in a semver major.
575+
...parseCommandLine(),
576+
};
577+
const root = createTestTree(rootTestOptions, globalOptions);
570578

571579
if (process.env.NODE_TEST_CONTEXT !== undefined) {
572580
process.emitWarning('node:test run() is being called recursively within a test file. skipping running files.');

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.