mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
test_runner: wait for filtered suite build
Signed-off-by: semimikoh <ejffjeosms@gmail.com> PR-URL: https://github.com/nodejs/node/pull/64208 Fixes: https://github.com/nodejs/node/issues/64203 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
This commit is contained in:
1 parent
d7266cdd99
commit
4368303e01
3 files changed
+45
No files matched your search
@@ -1854,6 +1854,11 @@ class Suite extends Test {
|
||||
return { __proto__: null, ctx, args: [ctx] };
|
||||
}
|
||||
|
||||
async filteredRun() {
|
||||
await this.buildSuite;
|
||||
return super.filteredRun();
|
||||
}
|
||||
|
||||
async run() {
|
||||
this.computeInheritedHooks();
|
||||
const hookArgs = this.getRunArgs();
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import test from 'node:test';
|
||||
import { setTimeout as delay } from 'node:timers/promises';
|
||||
|
||||
test.suite('Outer', async () => {
|
||||
await delay(1);
|
||||
|
||||
// This suite is filtered out by name. Its build is still pending when the
|
||||
// filtered run starts, so the subtest below is registered late.
|
||||
test.suite('Nested A', async () => {
|
||||
await delay(1);
|
||||
test('Nested A test', async () => {});
|
||||
});
|
||||
|
||||
test.suite('Nested C', async () => {
|
||||
test('Nested C test', async () => {});
|
||||
});
|
||||
});
|
||||
@@ -7,6 +7,8 @@ const { test } = require('node:test');
|
||||
|
||||
const fixture1 = fixtures.path('test-runner', 'no-isolation', 'one.test.js');
|
||||
const fixture2 = fixtures.path('test-runner', 'no-isolation', 'two.test.js');
|
||||
const asyncBuildFilteredSuite =
|
||||
fixtures.path('test-runner', 'filtered-suite-async-build.mjs');
|
||||
|
||||
test('works with --test-only', () => {
|
||||
const args = [
|
||||
@@ -71,6 +73,27 @@ test('works with --test-name-pattern', () => {
|
||||
assert.match(stdout, /# suites 0/);
|
||||
});
|
||||
|
||||
test('filtered suites with an async build do not leave cancelled tests', () => {
|
||||
const args = [
|
||||
'--test',
|
||||
'--test-reporter=tap',
|
||||
'--test-isolation=none',
|
||||
'--test-name-pattern=C',
|
||||
asyncBuildFilteredSuite,
|
||||
];
|
||||
const child = spawnSync(process.execPath, args);
|
||||
const stdout = child.stdout.toString();
|
||||
|
||||
assert.strictEqual(child.status, 0);
|
||||
assert.strictEqual(child.signal, null);
|
||||
assert.match(stdout, /# tests 1/);
|
||||
assert.match(stdout, /# suites 2/);
|
||||
assert.match(stdout, /# pass 1/);
|
||||
assert.match(stdout, /# fail 0/);
|
||||
assert.match(stdout, /# cancelled 0/);
|
||||
assert.doesNotMatch(stdout, /parentAlreadyFinished/);
|
||||
});
|
||||
|
||||
test('works with --test-skip-pattern', () => {
|
||||
const args = [
|
||||
'--test',
|
||||
|
||||
Reference in new issue
Block a user