| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d8d2d33 commit ddf819f
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1915,6 +1915,8 @@ Node.js options that are allowed are: | |||
| 1915 | 1915 | * `--secure-heap` | |
| 1916 | 1916 | * `--snapshot-blob` | |
| 1917 | 1917 | * `--test-only` | |
| 1918 | + * `--test-reporter-destination` | ||
| 1919 | + * `--test-reporter` | ||
| 1918 | 1920 | * `--throw-deprecation` | |
| 1919 | 1921 | * `--title` | |
| 1920 | 1922 | * `--tls-cipher-list` | |
@@ -2056,6 +2058,11 @@ If `value` equals `'1'`, the check for a supported platform is skipped during | |||
| 2056 | 2058 | Node.js startup. Node.js might not execute correctly. Any issues encountered | |
| 2057 | 2059 | on unsupported platforms will not be fixed. | |
| 2058 | 2060 | ||
| 2061 | + ### `NODE_TEST_CONTEXT=value` | ||
| 2062 | + | ||
| 2063 | + If `value` equals `'child'`, test reporter options will be overridden and test | ||
| 2064 | + output will be sent to stdout in the TAP format. | ||
| 2065 | + | ||
| 2059 | 2066 | ### `NODE_TLS_REJECT_UNAUTHORIZED=value` | |
| 2060 | 2067 | ||
| 2061 | 2068 | If `value` equals `'0'`, certificate validation is disabled for TLS connections. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -144,6 +144,7 @@ function getRunArgs({ path, inspectPort }) { | |||
| 144 | 144 | ArrayPrototypePush(argv, `--inspect-port=${getInspectPort(inspectPort)}`); | |
| 145 | 145 | } | |
| 146 | 146 | ArrayPrototypePush(argv, path); | |
| 147 | + | ||
| 147 | 148 | return argv; | |
| 148 | 149 | } | |
| 149 | 150 | ||
@@ -259,7 +260,7 @@ function runTestFile(path, root, inspectPort, filesWatcher) { | |||
| 259 | 260 | const subtest = root.createSubtest(FileTest, path, async (t) => { | |
| 260 | 261 | const args = getRunArgs({ path, inspectPort }); | |
| 261 | 262 | const stdio = ['pipe', 'pipe', 'pipe']; | |
| 262 | - const env = { ...process.env }; | ||
| 263 | + const env = { ...process.env, NODE_TEST_CONTEXT: 'child' }; | ||
| 263 | 264 | if (filesWatcher) { | |
| 264 | 265 | stdio.push('ipc'); | |
| 265 | 266 | env.WATCH_REPORT_DEPENDENCIES = '1'; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,7 @@ const { | |||
| 9 | 9 | RegExpPrototypeExec, | |
| 10 | 10 | SafeMap, | |
| 11 | 11 | } = primordials; | |
| 12 | + | ||
| 12 | 13 | const { basename } = require('path'); | |
| 13 | 14 | const { createWriteStream } = require('fs'); | |
| 14 | 15 | const { pathToFileURL } = require('internal/url'); | |
@@ -167,25 +168,33 @@ function parseCommandLine() { | |||
| 167 | 168 | ||
| 168 | 169 | const isTestRunner = getOptionValue('--test'); | |
| 169 | 170 | const coverage = getOptionValue('--experimental-test-coverage'); | |
| 170 | - const destinations = getOptionValue('--test-reporter-destination'); | ||
| 171 | - const reporters = getOptionValue('--test-reporter'); | ||
| 171 | + const isChildProcess = process.env.NODE_TEST_CONTEXT === 'child'; | ||
| 172 | + let destinations; | ||
| 173 | + let reporters; | ||
| 172 | 174 | let testNamePatterns; | |
| 173 | 175 | let testOnlyFlag; | |
| 174 | 176 | ||
| 175 | - if (reporters.length === 0 && destinations.length === 0) { | ||
| 176 | - ArrayPrototypePush(reporters, kDefaultReporter); | ||
| 177 | - } | ||
| 177 | + if (isChildProcess) { | ||
| 178 | + reporters = [kDefaultReporter]; | ||
| 179 | + destinations = [kDefaultDestination]; | ||
| 180 | + } else { | ||
| 181 | + destinations = getOptionValue('--test-reporter-destination'); | ||
| 182 | + reporters = getOptionValue('--test-reporter'); | ||
| 183 | + if (reporters.length === 0 && destinations.length === 0) { | ||
| 184 | + ArrayPrototypePush(reporters, kDefaultReporter); | ||
| 185 | + } | ||
| 178 | 186 | ||
| 179 | - if (reporters.length === 1 && destinations.length === 0) { | ||
| 180 | - ArrayPrototypePush(destinations, kDefaultDestination); | ||
| 181 | - } | ||
| 187 | + if (reporters.length === 1 && destinations.length === 0) { | ||
| 188 | + ArrayPrototypePush(destinations, kDefaultDestination); | ||
| 189 | + } | ||
| 182 | 190 | ||
| 183 | - if (destinations.length !== reporters.length) { | ||
| 184 | - throw new ERR_INVALID_ARG_VALUE( | ||
| 185 | - '--test-reporter', | ||
| 186 | - reporters, | ||
| 187 | - 'must match the number of specified \'--test-reporter-destination\'', | ||
| 188 | - ); | ||
| 191 | + if (destinations.length !== reporters.length) { | ||
| 192 | + throw new ERR_INVALID_ARG_VALUE( | ||
| 193 | + '--test-reporter', | ||
| 194 | + reporters, | ||
| 195 | + 'must match the number of specified \'--test-reporter-destination\'', | ||
| 196 | + ); | ||
| 197 | + } | ||
| 189 | 198 | } | |
| 190 | 199 | ||
| 191 | 200 | if (isTestRunner) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -574,10 +574,12 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { | |||
| 574 | 574 | &EnvironmentOptions::test_name_pattern); | |
| 575 | 575 | AddOption("--test-reporter", | |
| 576 | 576 | "report test output using the given reporter", | |
| 577 | - &EnvironmentOptions::test_reporter); | ||
| 577 | + &EnvironmentOptions::test_reporter, | ||
| 578 | + kAllowedInEnvvar); | ||
| 578 | 579 | AddOption("--test-reporter-destination", | |
| 579 | 580 | "report given reporter to the given destination", | |
| 580 | - &EnvironmentOptions::test_reporter_destination); | ||
| 581 | + &EnvironmentOptions::test_reporter_destination, | ||
| 582 | + kAllowedInEnvvar); | ||
| 581 | 583 | AddOption("--test-only", | |
| 582 | 584 | "run tests with 'only' option set", | |
| 583 | 585 | &EnvironmentOptions::test_only, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments