test_runner: do not tag-filter test file wrappers · nodejs/node@4e06739 · GitHub
Skip to content

Commit 4e06739

Browse files
atlowChemiaduh95
authored andcommitted
test_runner: do not tag-filter test file wrappers
Under run({ testTagFilters, isolation: 'process' }) the parent process's FileTest wrappers have empty tag sets, so any include filter filtered out the wrappers themselves and no test file was ever spawned. The same applied to the single re-spawned child in watch mode with isolation 'none'. Exempt file wrappers from tag filtering: the filter is re-emitted to the child process and applied there, matching isolation 'none' results. This also removes the testTagFilterExpressions bookkeeping and the isolation-conditional assignment of testTagFilters, both of which existed only to keep the parent process from filtering its own file wrappers. The parent now always holds the canonical filter values and re-emits them to child processes. Refs: #63221 Signed-off-by: atlowChemi <chemi@atlow.co.il> PR-URL: #65170 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
1 parent d6059e8 commit 4e06739

4 files changed

Lines changed: 32 additions & 24 deletions

File tree

lib/internal/test_runner/runner.js

Lines changed: 11 additions & 7 deletions

lib/internal/test_runner/test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ class Test extends AsyncResource {
656656
}
657657

658658
if (isFilteringByTags) {
659-
this.filteredByTag = !evaluateTagFilters(config.testTagFilters, this.tagSet);
659+
this.filteredByTag = this.willBeFilteredByTags();
660660
if (!this.filteredByTag) {
661661
for (let t = this.parent; t !== null && t.filteredByTag; t = t.parent) {
662662
t.filteredByTag = false;
@@ -894,6 +894,10 @@ class Test extends AsyncResource {
894894
return false;
895895
}
896896

897+
willBeFilteredByTags() {
898+
return !evaluateTagFilters(this.config.testTagFilters, this.tagSet);
899+
}
900+
897901
/**
898902
* Returns a name of the test prefixed by name of all its ancestors in ascending order, separated by a space
899903
* Ex."grandparent parent test"

lib/internal/test_runner/utils.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ function parseCommandLine() {
273273
let testNamePatterns = mapPatternFlagToRegExArray('--test-name-pattern');
274274
let testSkipPatterns = mapPatternFlagToRegExArray('--test-skip-pattern');
275275
let testTagFilters = null;
276-
let testTagFilterExpressions = null;
277276

278277
if (isChildProcessV8) {
279278
kBuiltinReporters.set('v8-serializer', 'internal/test_runner/reporter/v8-serializer');
@@ -309,19 +308,14 @@ function parseCommandLine() {
309308
const tagFilterFlag = getOptionValue('--experimental-test-tag-filter');
310309
if (tagFilterFlag?.length > 0) {
311310
emitExperimentalWarning('Test tags');
312-
testTagFilterExpressions = tagFilterFlag;
313-
// Validate at parent startup so a malformed flag fails fast,
314-
// independent of isolation mode. Under isolation='process' the
315-
// validated strings go unused at the parent (children re-validate
316-
// and apply the filter); the validation here only surfaces input
317-
// errors early.
318-
const validated = ArrayPrototypeMap(
311+
// File wrappers are exempt from tag filtering, so holding the filters
312+
// in the parent is safe under any isolation mode; under
313+
// isolation='process' the canonical values are re-emitted to the
314+
// child processes, which apply the filter themselves.
315+
testTagFilters = ArrayPrototypeMap(
319316
tagFilterFlag,
320317
(value, i) => validateAndCanonicalizeTagFilter(value, `--experimental-test-tag-filter[${i}]`),
321318
);
322-
if (isolation === 'none') {
323-
testTagFilters = validated;
324-
}
325319
}
326320

327321
if (isolation === 'none') {
@@ -365,7 +359,6 @@ function parseCommandLine() {
365359
const tagFilterFlag = getOptionValue('--experimental-test-tag-filter');
366360
if (tagFilterFlag?.length > 0) {
367361
emitExperimentalWarning('Test tags');
368-
testTagFilterExpressions = tagFilterFlag;
369362
testTagFilters = ArrayPrototypeMap(
370363
tagFilterFlag,
371364
(value, i) => validateAndCanonicalizeTagFilter(value, `--experimental-test-tag-filter[${i}]`),
@@ -433,7 +426,6 @@ function parseCommandLine() {
433426
sourceMaps,
434427
testNamePatterns,
435428
testSkipPatterns,
436-
testTagFilterExpressions,
437429
testTagFilters,
438430
timeout,
439431
updateSnapshots,

test/parallel/test-runner-tags-events.mjs

Lines changed: 11 additions & 3 deletions

0 commit comments

Comments
 (0)