-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test_runner: finish build phase before running tests
This commit updates the test runner to wait for suites to finish building before starting any tests. This is necessary when test filtering is enabled, as suites may transition from filtered to not filtered depending on what is inside of them. Fixes: #54084 Fixes: #54154 PR-URL: #54423 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Jake Yuesong Li <[email protected]>
- Loading branch information
Showing
9 changed files
with
302 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
test/fixtures/test-runner/output/filtered-suite-delayed-build.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Flags: --test-name-pattern=enabled | ||
'use strict'; | ||
const common = require('../../../common'); | ||
const { suite, test } = require('node:test'); | ||
|
||
suite('async suite', async () => { | ||
await 1; | ||
test('enabled 1', common.mustCall()); | ||
await 1; | ||
test('not run', common.mustNotCall()); | ||
await 1; | ||
}); | ||
|
||
suite('sync suite', () => { | ||
test('enabled 2', common.mustCall()); | ||
}); |
34 changes: 34 additions & 0 deletions
34
test/fixtures/test-runner/output/filtered-suite-delayed-build.snapshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
TAP version 13 | ||
# Subtest: async suite | ||
# Subtest: enabled 1 | ||
ok 1 - enabled 1 | ||
--- | ||
duration_ms: * | ||
... | ||
1..1 | ||
ok 1 - async suite | ||
--- | ||
duration_ms: * | ||
type: 'suite' | ||
... | ||
# Subtest: sync suite | ||
# Subtest: enabled 2 | ||
ok 1 - enabled 2 | ||
--- | ||
duration_ms: * | ||
... | ||
1..1 | ||
ok 2 - sync suite | ||
--- | ||
duration_ms: * | ||
type: 'suite' | ||
... | ||
1..2 | ||
# tests 2 | ||
# suites 2 | ||
# pass 2 | ||
# fail 0 | ||
# cancelled 0 | ||
# skipped 0 | ||
# todo 0 | ||
# duration_ms * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Flags: --test-only | ||
import { describe, test, after } from 'node:test'; | ||
|
||
after(() => { console.log('with global after()'); }); | ||
await Promise.resolve(); | ||
|
||
console.log('Execution order was:'); | ||
const ll = (t) => { console.log(` * ${t.fullName}`) }; | ||
|
||
describe('A', () => { | ||
test.only('A', ll); | ||
test('B', ll); | ||
describe.only('C', () => { | ||
test.only('A', ll); | ||
test('B', ll); | ||
}); | ||
describe('D', () => { | ||
test.only('A', ll); | ||
test('B', ll); | ||
}); | ||
}); | ||
describe.only('B', () => { | ||
test('A', ll); | ||
test('B', ll); | ||
describe('C', () => { | ||
test('A', ll); | ||
}); | ||
}); | ||
describe('C', () => { | ||
test.only('A', ll); | ||
test('B', ll); | ||
describe.only('C', () => { | ||
test('A', ll); | ||
test('B', ll); | ||
}); | ||
describe('D', () => { | ||
test('A', ll); | ||
test.only('B', ll); | ||
}); | ||
}); | ||
describe('D', () => { | ||
test('A', ll); | ||
test.only('B', ll); | ||
}); | ||
describe.only('E', () => { | ||
test('A', ll); | ||
test('B', ll); | ||
}); | ||
test.only('F', ll); |
166 changes: 166 additions & 0 deletions
166
test/fixtures/test-runner/output/filtered-suite-order.snapshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
Execution order was: | ||
* A > A | ||
* A > C > A | ||
* A > D > A | ||
* B > A | ||
* B > B | ||
* B > C > A | ||
* C > A | ||
* C > C > A | ||
* C > C > B | ||
* C > D > B | ||
* D > B | ||
* E > A | ||
* E > B | ||
* F | ||
with global after() | ||
TAP version 13 | ||
# Subtest: A | ||
# Subtest: A | ||
ok 1 - A | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: C | ||
# Subtest: A | ||
ok 1 - A | ||
--- | ||
duration_ms: * | ||
... | ||
1..1 | ||
ok 2 - C | ||
--- | ||
duration_ms: * | ||
type: 'suite' | ||
... | ||
# Subtest: D | ||
# Subtest: A | ||
ok 1 - A | ||
--- | ||
duration_ms: * | ||
... | ||
1..1 | ||
ok 3 - D | ||
--- | ||
duration_ms: * | ||
type: 'suite' | ||
... | ||
1..3 | ||
ok 1 - A | ||
--- | ||
duration_ms: * | ||
type: 'suite' | ||
... | ||
# Subtest: B | ||
# Subtest: A | ||
ok 1 - A | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: B | ||
ok 2 - B | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: C | ||
# Subtest: A | ||
ok 1 - A | ||
--- | ||
duration_ms: * | ||
... | ||
1..1 | ||
ok 3 - C | ||
--- | ||
duration_ms: * | ||
type: 'suite' | ||
... | ||
1..3 | ||
ok 2 - B | ||
--- | ||
duration_ms: * | ||
type: 'suite' | ||
... | ||
# Subtest: C | ||
# Subtest: A | ||
ok 1 - A | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: C | ||
# Subtest: A | ||
ok 1 - A | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: B | ||
ok 2 - B | ||
--- | ||
duration_ms: * | ||
... | ||
1..2 | ||
ok 2 - C | ||
--- | ||
duration_ms: * | ||
type: 'suite' | ||
... | ||
# Subtest: D | ||
# Subtest: B | ||
ok 1 - B | ||
--- | ||
duration_ms: * | ||
... | ||
1..1 | ||
ok 3 - D | ||
--- | ||
duration_ms: * | ||
type: 'suite' | ||
... | ||
1..3 | ||
ok 3 - C | ||
--- | ||
duration_ms: * | ||
type: 'suite' | ||
... | ||
# Subtest: D | ||
# Subtest: B | ||
ok 1 - B | ||
--- | ||
duration_ms: * | ||
... | ||
1..1 | ||
ok 4 - D | ||
--- | ||
duration_ms: * | ||
type: 'suite' | ||
... | ||
# Subtest: E | ||
# Subtest: A | ||
ok 1 - A | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: B | ||
ok 2 - B | ||
--- | ||
duration_ms: * | ||
... | ||
1..2 | ||
ok 5 - E | ||
--- | ||
duration_ms: * | ||
type: 'suite' | ||
... | ||
# Subtest: F | ||
ok 6 - F | ||
--- | ||
duration_ms: * | ||
... | ||
1..6 | ||
# tests 14 | ||
# suites 10 | ||
# pass 14 | ||
# fail 0 | ||
# cancelled 0 | ||
# skipped 0 | ||
# todo 0 | ||
# duration_ms * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,9 +21,6 @@ not ok 1 - fails | |
* | ||
* | ||
* | ||
* | ||
* | ||
* | ||
... | ||
1..1 | ||
# tests 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters