test_runner: use run options with isolation="none" · nodejs/node@cce803b · GitHub
Skip to content

Commit cce803b

Browse files
inukshukaduh95
authored andcommitted
test_runner: use run options with isolation="none"
When using run() programatically with isolation="none", testNamePatterns, testSkipPattersn, and only were ignored. This combination of options only worked when set via CLI flags, because parseCommandLine() is still used to seed globalOptions. Fixes: #57399 Signed-off-by: Sylvester Keil <sylvester@keil.or.at> PR-URL: #62269 Reviewed-By: Ethan Arrowood <ethan@arrowood.dev> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
1 parent 6ec735c commit cce803b

3 files changed

Lines changed: 86 additions & 0 deletions

File tree

lib/internal/test_runner/runner.js

Lines changed: 12 additions & 0 deletions
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { run } from 'node:test';
2+
import { tap } from 'node:test/reporters';
3+
import { parseArgs } from 'node:util';
4+
5+
const {
6+
values,
7+
} = parseArgs({
8+
args: process.argv.slice(2),
9+
options: {
10+
file: { type: 'string' },
11+
only: { type: 'boolean' },
12+
'name-pattern': { type: 'string' },
13+
'skip-pattern': { type: 'string' },
14+
},
15+
});
16+
17+
const opts = {
18+
isolation: 'none',
19+
files: [values.file],
20+
};
21+
22+
if (values.only) {
23+
opts.only = true;
24+
}
25+
if (values['name-pattern']) {
26+
opts.testNamePatterns = [new RegExp(values['name-pattern'])];
27+
}
28+
if (values['skip-pattern']) {
29+
opts.testSkipPatterns = [new RegExp(values['skip-pattern'])];
30+
}
31+
32+
run(opts).compose(tap).pipe(process.stdout);

test/parallel/test-runner-run.mjs

Lines changed: 42 additions & 0 deletions

0 commit comments

Comments
 (0)