| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1e88045 commit ed1ede8
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,8 +17,6 @@ const { | |||
| 17 | 17 | }, | |
| 18 | 18 | } = require('internal/errors'); | |
| 19 | 19 | const { exitCodes: { kGenericUserError } } = internalBinding('errors'); | |
| 20 | - | ||
| 21 | - const { kEmptyObject } = require('internal/util'); | ||
| 22 | 20 | const { kCancelledByParent, Test, Suite } = require('internal/test_runner/test'); | |
| 23 | 21 | const { | |
| 24 | 22 | parseCommandLine, | |
@@ -34,8 +32,7 @@ let globalRoot; | |||
| 34 | 32 | ||
| 35 | 33 | testResources.set(reporterScope.asyncId(), reporterScope); | |
| 36 | 34 | ||
| 37 | - function createTestTree(options = kEmptyObject) { | ||
| 38 | - const globalOptions = parseCommandLine(); | ||
| 35 | + function createTestTree(rootTestOptions, globalOptions) { | ||
| 39 | 36 | const harness = { | |
| 40 | 37 | __proto__: null, | |
| 41 | 38 | allowTestsToRun: false, | |
@@ -65,7 +62,7 @@ function createTestTree(options = kEmptyObject) { | |||
| 65 | 62 | harness.resetCounters(); | |
| 66 | 63 | globalRoot = new Test({ | |
| 67 | 64 | __proto__: null, | |
| 68 | - ...options, | ||
| 65 | + ...rootTestOptions, | ||
| 69 | 66 | harness, | |
| 70 | 67 | name: '<root>', | |
| 71 | 68 | }); | |
@@ -230,7 +227,11 @@ function lazyBootstrapRoot() { | |||
| 230 | 227 | if (!globalRoot) { | |
| 231 | 228 | // This is where the test runner is bootstrapped when node:test is used | |
| 232 | 229 | // 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()); | ||
| 234 | 235 | globalRoot.reporter.on('test:fail', (data) => { | |
| 235 | 236 | if (data.todo === undefined || data.todo === false) { | |
| 236 | 237 | process.exitCode = kGenericUserError; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -69,6 +69,7 @@ const { | |||
| 69 | 69 | convertStringToRegExp, | |
| 70 | 70 | countCompletedTest, | |
| 71 | 71 | kDefaultPattern, | |
| 72 | + parseCommandLine, | ||
| 72 | 73 | } = require('internal/test_runner/utils'); | |
| 73 | 74 | const { Glob } = require('internal/fs/glob'); | |
| 74 | 75 | const { once } = require('events'); | |
@@ -566,7 +567,14 @@ function run(options = kEmptyObject) { | |||
| 566 | 567 | }); | |
| 567 | 568 | } | |
| 568 | 569 | ||
| 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); | ||
| 570 | 578 | ||
| 571 | 579 | if (process.env.NODE_TEST_CONTEXT !== undefined) { | |
| 572 | 580 | process.emitWarning('node:test run() is being called recursively within a test file. skipping running files.'); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments