| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3cfafbc commit 34433a4
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,7 +12,6 @@ const { | |||
| 12 | 12 | ArrayPrototypePush, | |
| 13 | 13 | ArrayPrototypePushApply, | |
| 14 | 14 | ArrayPrototypeShift, | |
| 15 | - ArrayPrototypeSlice, | ||
| 16 | 15 | ArrayPrototypeSome, | |
| 17 | 16 | ArrayPrototypeSort, | |
| 18 | 17 | MathMax, | |
@@ -185,6 +184,9 @@ function getRunArgs(path, { forceExit, | |||
| 185 | 184 | testSkipPatterns, | |
| 186 | 185 | testTagFilterExpressions, | |
| 187 | 186 | only, | |
| 187 | + hasFiles, | ||
| 188 | + testFiles, | ||
| 189 | + globPatterns, | ||
| 188 | 190 | argv: suppliedArgs, | |
| 189 | 191 | execArgv, | |
| 190 | 192 | rerunFailuresFilePath, | |
@@ -245,7 +247,8 @@ function getRunArgs(path, { forceExit, | |||
| 245 | 247 | ||
| 246 | 248 | if (path === kIsolatedProcessName) { | |
| 247 | 249 | ArrayPrototypePush(runArgs, '--test'); | |
| 248 | - ArrayPrototypePushApply(runArgs, ArrayPrototypeSlice(process.argv, 1)); | ||
| 250 | + ArrayPrototypePush(runArgs, '--test-isolation=none'); | ||
| 251 | + ArrayPrototypePushApply(runArgs, hasFiles ? testFiles : globPatterns ?? []); | ||
| 249 | 252 | } else { | |
| 250 | 253 | ArrayPrototypePush(runArgs, path); | |
| 251 | 254 | } | |
@@ -986,6 +989,7 @@ function run(options = kEmptyObject) { | |||
| 986 | 989 | workerIdPool: isolation === 'process' ? workerIdPool : null, | |
| 987 | 990 | randomize, | |
| 988 | 991 | randomSeed, | |
| 992 | + testFiles, | ||
| 989 | 993 | }; | |
| 990 | 994 | ||
| 991 | 995 | if (isolation === 'process') { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,43 @@ | |||
| 1 | + // Test run({ watch: true, cwd, isolation: 'none' }) does not reuse the | ||
| 2 | + // parent process argv when spawning the watch child. | ||
| 3 | + import * as common from '../common/index.mjs'; | ||
| 4 | + import assert from 'node:assert'; | ||
| 5 | + import { readFileSync, writeFileSync } from 'node:fs'; | ||
| 6 | + import { join } from 'node:path'; | ||
| 7 | + import { run } from 'node:test'; | ||
| 8 | + import tmpdir from '../common/tmpdir.js'; | ||
| 9 | + import { skipIfNoWatch } from '../common/watch.js'; | ||
| 10 | + | ||
| 11 | + skipIfNoWatch(); | ||
| 12 | + tmpdir.refresh(); | ||
| 13 | + | ||
| 14 | + const marker = join(tmpdir.path, 'marker'); | ||
| 15 | + writeFileSync(join(tmpdir.path, 'test.js'), ` | ||
| 16 | + const test = require('node:test'); | ||
| 17 | + const { writeFileSync } = require('node:fs'); | ||
| 18 | + | ||
| 19 | + test('test ran from cwd', () => { | ||
| 20 | + writeFileSync(${JSON.stringify(marker)}, 'ran'); | ||
| 21 | + }); | ||
| 22 | + `); | ||
| 23 | + | ||
| 24 | + const controller = new AbortController(); | ||
| 25 | + const stream = run({ | ||
| 26 | + cwd: tmpdir.path, | ||
| 27 | + watch: true, | ||
| 28 | + signal: controller.signal, | ||
| 29 | + isolation: 'none', | ||
| 30 | + }).on('data', function({ type }) { | ||
| 31 | + if (type === 'test:watch:drained') { | ||
| 32 | + stream.removeAllListeners('test:fail'); | ||
| 33 | + stream.removeAllListeners('test:pass'); | ||
| 34 | + controller.abort(); | ||
| 35 | + } | ||
| 36 | + }); | ||
| 37 | + | ||
| 38 | + stream.on('test:fail', common.mustNotCall()); | ||
| 39 | + stream.on('test:pass', common.mustCall(1)); | ||
| 40 | + // eslint-disable-next-line no-unused-vars | ||
| 41 | + for await (const _ of stream); | ||
| 42 | + | ||
| 43 | + assert.strictEqual(readFileSync(marker, 'utf8'), 'ran'); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments