| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a408f27 commit b7fdb48
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, | |
@@ -175,6 +174,9 @@ function getRunArgs(path, { forceExit, | |||
| 175 | 174 | testNamePatterns, | |
| 176 | 175 | testSkipPatterns, | |
| 177 | 176 | only, | |
| 177 | + hasFiles, | ||
| 178 | + testFiles, | ||
| 179 | + globPatterns, | ||
| 178 | 180 | argv: suppliedArgs, | |
| 179 | 181 | execArgv, | |
| 180 | 182 | rerunFailuresFilePath, | |
@@ -232,7 +234,8 @@ function getRunArgs(path, { forceExit, | |||
| 232 | 234 | ||
| 233 | 235 | if (path === kIsolatedProcessName) { | |
| 234 | 236 | ArrayPrototypePush(runArgs, '--test'); | |
| 235 | - ArrayPrototypePushApply(runArgs, ArrayPrototypeSlice(process.argv, 1)); | ||
| 237 | + ArrayPrototypePush(runArgs, '--test-isolation=none'); | ||
| 238 | + ArrayPrototypePushApply(runArgs, hasFiles ? testFiles : globPatterns ?? []); | ||
| 236 | 239 | } else { | |
| 237 | 240 | ArrayPrototypePush(runArgs, path); | |
| 238 | 241 | } | |
@@ -951,6 +954,7 @@ function run(options = kEmptyObject) { | |||
| 951 | 954 | workerIdPool: isolation === 'process' ? workerIdPool : null, | |
| 952 | 955 | randomize, | |
| 953 | 956 | randomSeed, | |
| 957 | + testFiles, | ||
| 954 | 958 | }; | |
| 955 | 959 | ||
| 956 | 960 | 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