| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d6059e8 commit 4e06739
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -182,7 +182,7 @@ function getRunArgs(path, { forceExit, | |||
| 182 | 182 | inspectPort, | |
| 183 | 183 | testNamePatterns, | |
| 184 | 184 | testSkipPatterns, | |
| 185 | - testTagFilterExpressions, | ||
| 185 | + testTagFilters, | ||
| 186 | 186 | only, | |
| 187 | 187 | hasFiles, | |
| 188 | 188 | testFiles, | |
@@ -224,8 +224,8 @@ function getRunArgs(path, { forceExit, | |||
| 224 | 224 | if (testSkipPatterns != null) { | |
| 225 | 225 | ArrayPrototypeForEach(testSkipPatterns, (pattern) => ArrayPrototypePush(runArgs, `--test-skip-pattern=${pattern}`)); | |
| 226 | 226 | } | |
| 227 | - if (testTagFilterExpressions != null) { | ||
| 228 | - ArrayPrototypeForEach(testTagFilterExpressions, (value) => ArrayPrototypePush(runArgs, `--experimental-test-tag-filter=${value}`)); | ||
| 227 | + if (testTagFilters != null) { | ||
| 228 | + ArrayPrototypeForEach(testTagFilters, (value) => ArrayPrototypePush(runArgs, `--experimental-test-tag-filter=${value}`)); | ||
| 229 | 229 | } | |
| 230 | 230 | if (only === true) { | |
| 231 | 231 | ArrayPrototypePush(runArgs, '--test-only'); | |
@@ -284,6 +284,14 @@ class FileTest extends Test { | |||
| 284 | 284 | this.timeout = null; | |
| 285 | 285 | } | |
| 286 | 286 | ||
| 287 | + willBeFilteredByTags() { | ||
| 288 | + // File wrappers have no tags of their own. Tag filtering applies to the | ||
| 289 | + // tests inside the file, which run in a child process (or in-process | ||
| 290 | + // import); filtering the wrapper would prevent the file from running at | ||
| 291 | + // all. | ||
| 292 | + return false; | ||
| 293 | + } | ||
| 294 | + | ||
| 287 | 295 | #skipReporting() { | |
| 288 | 296 | return this.#reportedChildren > 0 && (!this.error || this.error.failureType === kSubtestsFailed); | |
| 289 | 297 | } | |
@@ -864,7 +872,6 @@ function run(options = kEmptyObject) { | |||
| 864 | 872 | }); | |
| 865 | 873 | } | |
| 866 | 874 | ||
| 867 | - let testTagFilterExpressions = null; | ||
| 868 | 875 | if (testTagFilters != null) { | |
| 869 | 876 | if (!ArrayIsArray(testTagFilters)) { | |
| 870 | 877 | testTagFilters = [testTagFilters]; | |
@@ -876,10 +883,8 @@ function run(options = kEmptyObject) { | |||
| 876 | 883 | testTagFilters = ArrayPrototypeMap(testTagFilters, (value, i) => ( | |
| 877 | 884 | validateAndCanonicalizeTagFilter(value, `options.testTagFilters[${i}]`) | |
| 878 | 885 | )); | |
| 879 | - testTagFilterExpressions = testTagFilters; | ||
| 880 | 886 | } | |
| 881 | 887 | } | |
| 882 | - testTagFilterExpressions ??= options.testTagFilterExpressions; | ||
| 883 | 888 | ||
| 884 | 889 | validateOneOf(isolation, 'options.isolation', ['process', 'none']); | |
| 885 | 890 | validateBoolean(coverage, 'options.coverage'); | |
@@ -982,7 +987,6 @@ function run(options = kEmptyObject) { | |||
| 982 | 987 | testNamePatterns, | |
| 983 | 988 | testSkipPatterns, | |
| 984 | 989 | testTagFilters, | |
| 985 | - testTagFilterExpressions, | ||
| 986 | 990 | hasFiles: files != null, | |
| 987 | 991 | globPatterns, | |
| 988 | 992 | only, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -656,7 +656,7 @@ class Test extends AsyncResource { | |||
| 656 | 656 | } | |
| 657 | 657 | ||
| 658 | 658 | if (isFilteringByTags) { | |
| 659 | - this.filteredByTag = !evaluateTagFilters(config.testTagFilters, this.tagSet); | ||
| 659 | + this.filteredByTag = this.willBeFilteredByTags(); | ||
| 660 | 660 | if (!this.filteredByTag) { | |
| 661 | 661 | for (let t = this.parent; t !== null && t.filteredByTag; t = t.parent) { | |
| 662 | 662 | t.filteredByTag = false; | |
@@ -894,6 +894,10 @@ class Test extends AsyncResource { | |||
| 894 | 894 | return false; | |
| 895 | 895 | } | |
| 896 | 896 | ||
| 897 | + willBeFilteredByTags() { | ||
| 898 | + return !evaluateTagFilters(this.config.testTagFilters, this.tagSet); | ||
| 899 | + } | ||
| 900 | + | ||
| 897 | 901 | /** | |
| 898 | 902 | * Returns a name of the test prefixed by name of all its ancestors in ascending order, separated by a space | |
| 899 | 903 | * Ex."grandparent parent test" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -273,7 +273,6 @@ function parseCommandLine() { | |||
| 273 | 273 | let testNamePatterns = mapPatternFlagToRegExArray('--test-name-pattern'); | |
| 274 | 274 | let testSkipPatterns = mapPatternFlagToRegExArray('--test-skip-pattern'); | |
| 275 | 275 | let testTagFilters = null; | |
| 276 | - let testTagFilterExpressions = null; | ||
| 277 | 276 | ||
| 278 | 277 | if (isChildProcessV8) { | |
| 279 | 278 | kBuiltinReporters.set('v8-serializer', 'internal/test_runner/reporter/v8-serializer'); | |
@@ -309,19 +308,14 @@ function parseCommandLine() { | |||
| 309 | 308 | const tagFilterFlag = getOptionValue('--experimental-test-tag-filter'); | |
| 310 | 309 | if (tagFilterFlag?.length > 0) { | |
| 311 | 310 | 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( | ||
| 319 | 316 | tagFilterFlag, | |
| 320 | 317 | (value, i) => validateAndCanonicalizeTagFilter(value, `--experimental-test-tag-filter[${i}]`), | |
| 321 | 318 | ); | |
| 322 | - if (isolation === 'none') { | ||
| 323 | - testTagFilters = validated; | ||
| 324 | - } | ||
| 325 | 319 | } | |
| 326 | 320 | ||
| 327 | 321 | if (isolation === 'none') { | |
@@ -365,7 +359,6 @@ function parseCommandLine() { | |||
| 365 | 359 | const tagFilterFlag = getOptionValue('--experimental-test-tag-filter'); | |
| 366 | 360 | if (tagFilterFlag?.length > 0) { | |
| 367 | 361 | emitExperimentalWarning('Test tags'); | |
| 368 | - testTagFilterExpressions = tagFilterFlag; | ||
| 369 | 362 | testTagFilters = ArrayPrototypeMap( | |
| 370 | 363 | tagFilterFlag, | |
| 371 | 364 | (value, i) => validateAndCanonicalizeTagFilter(value, `--experimental-test-tag-filter[${i}]`), | |
@@ -433,7 +426,6 @@ function parseCommandLine() { | |||
| 433 | 426 | sourceMaps, | |
| 434 | 427 | testNamePatterns, | |
| 435 | 428 | testSkipPatterns, | |
| 436 | - testTagFilterExpressions, | ||
| 437 | 429 | testTagFilters, | |
| 438 | 430 | timeout, | |
| 439 | 431 | updateSnapshots, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -83,14 +83,22 @@ describe('tag-bearing event payloads', { concurrency: false }, () => { | |||
| 83 | 83 | }); | |
| 84 | 84 | ||
| 85 | 85 | it('test:pass fires only for selected tagged tests when filtered', async () => { | |
| 86 | - // isolation='none' so the parent applies the filter directly. Under | ||
| 87 | - // 'process', the FileTest wrapper (which has no tags) would itself be | ||
| 88 | - // filtered out by the include filter - same wart as --test-name-pattern. | ||
| 89 | 86 | const stream = run({ files: [fixture], testTagFilters: ['db'], isolation: 'none' }); | |
| 90 | 87 | stream.on('test:fail', common.mustNotCall()); | |
| 91 | 88 | // 3 db-tagged tests pass + the db suite itself. | |
| 92 | 89 | stream.on('test:pass', common.mustCall(4)); | |
| 93 | 90 | // eslint-disable-next-line no-unused-vars | |
| 94 | 91 | for await (const _ of stream); | |
| 95 | 92 | }); | |
| 93 | + | ||
| 94 | + it('filtering under process isolation runs the file and filters inside it', async () => { | ||
| 95 | + // The FileTest wrapper has no tags and must not be filtered out itself; | ||
| 96 | + // the filter is re-emitted to the child process and applied there. | ||
| 97 | + const stream = run({ files: [fixture], testTagFilters: ['db'], isolation: 'process' }); | ||
| 98 | + stream.on('test:fail', common.mustNotCall()); | ||
| 99 | + // 3 db-tagged tests pass + the db suite itself. | ||
| 100 | + stream.on('test:pass', common.mustCall(4)); | ||
| 101 | + // eslint-disable-next-line no-unused-vars | ||
| 102 | + for await (const _ of stream); | ||
| 103 | + }); | ||
| 96 | 104 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments