-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit introduces a CLI flag and test runner functionality to support running a subset of tests that are indicated by an 'only' option passed to the test. PR-URL: nodejs/node#42514 Backport-PR-URL: nodejs/node#43904 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
- Loading branch information
Showing
10 changed files
with
283 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
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
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,48 @@ | ||
// Flags: --no-warnings --test-only | ||
'use strict'; | ||
require('../common'); | ||
const test = require('node:test'); | ||
|
||
// These tests should be skipped based on the 'only' option. | ||
test('only = undefined'); | ||
test('only = undefined, skip = string', { skip: 'skip message' }); | ||
test('only = undefined, skip = true', { skip: true }); | ||
test('only = undefined, skip = false', { skip: false }); | ||
test('only = false', { only: false }); | ||
test('only = false, skip = string', { only: false, skip: 'skip message' }); | ||
test('only = false, skip = true', { only: false, skip: true }); | ||
test('only = false, skip = false', { only: false, skip: false }); | ||
|
||
// These tests should be skipped based on the 'skip' option. | ||
test('only = true, skip = string', { only: true, skip: 'skip message' }); | ||
test('only = true, skip = true', { only: true, skip: true }); | ||
|
||
// An 'only' test with subtests. | ||
test('only = true, with subtests', { only: true }, async (t) => { | ||
// These subtests should run. | ||
await t.test('running subtest 1'); | ||
await t.test('running subtest 2'); | ||
|
||
// Switch the context to only execute 'only' tests. | ||
t.runOnly(true); | ||
await t.test('skipped subtest 1'); | ||
await t.test('skipped subtest 2'); | ||
await t.test('running subtest 3', { only: true }); | ||
|
||
// Switch the context back to execute all tests. | ||
t.runOnly(false); | ||
await t.test('running subtest 4', async (t) => { | ||
// These subtests should run. | ||
await t.test('running sub-subtest 1'); | ||
await t.test('running sub-subtest 2'); | ||
|
||
// Switch the context to only execute 'only' tests. | ||
t.runOnly(true); | ||
await t.test('skipped sub-subtest 1'); | ||
await t.test('skipped sub-subtest 2'); | ||
}); | ||
|
||
// Explicitly do not run these tests. | ||
await t.test('skipped subtest 3', { only: false }); | ||
await t.test('skipped subtest 4', { skip: true }); | ||
}); |
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,102 @@ | ||
TAP version 13 | ||
ok 1 - only = undefined # SKIP 'only' option not set | ||
--- | ||
duration_ms: * | ||
... | ||
ok 2 - only = undefined, skip = string # SKIP 'only' option not set | ||
--- | ||
duration_ms: * | ||
... | ||
ok 3 - only = undefined, skip = true # SKIP 'only' option not set | ||
--- | ||
duration_ms: * | ||
... | ||
ok 4 - only = undefined, skip = false # SKIP 'only' option not set | ||
--- | ||
duration_ms: * | ||
... | ||
ok 5 - only = false # SKIP 'only' option not set | ||
--- | ||
duration_ms: * | ||
... | ||
ok 6 - only = false, skip = string # SKIP 'only' option not set | ||
--- | ||
duration_ms: * | ||
... | ||
ok 7 - only = false, skip = true # SKIP 'only' option not set | ||
--- | ||
duration_ms: * | ||
... | ||
ok 8 - only = false, skip = false # SKIP 'only' option not set | ||
--- | ||
duration_ms: * | ||
... | ||
ok 9 - only = true, skip = string # SKIP skip message | ||
--- | ||
duration_ms: * | ||
... | ||
ok 10 - only = true, skip = true # SKIP | ||
--- | ||
duration_ms: * | ||
... | ||
ok 1 - running subtest 1 | ||
--- | ||
duration_ms: * | ||
... | ||
ok 2 - running subtest 2 | ||
--- | ||
duration_ms: * | ||
... | ||
ok 3 - skipped subtest 1 # SKIP 'only' option not set | ||
--- | ||
duration_ms: * | ||
... | ||
ok 4 - skipped subtest 2 # SKIP 'only' option not set | ||
--- | ||
duration_ms: * | ||
... | ||
ok 5 - running subtest 3 | ||
--- | ||
duration_ms: * | ||
... | ||
ok 1 - running sub-subtest 1 | ||
--- | ||
duration_ms: * | ||
... | ||
ok 2 - running sub-subtest 2 | ||
--- | ||
duration_ms: * | ||
... | ||
ok 3 - skipped sub-subtest 1 # SKIP 'only' option not set | ||
--- | ||
duration_ms: * | ||
... | ||
ok 4 - skipped sub-subtest 2 # SKIP 'only' option not set | ||
--- | ||
duration_ms: * | ||
... | ||
1..4 | ||
ok 6 - running subtest 4 | ||
--- | ||
duration_ms: * | ||
... | ||
ok 7 - skipped subtest 3 # SKIP 'only' option not set | ||
--- | ||
duration_ms: * | ||
... | ||
ok 8 - skipped subtest 4 # SKIP | ||
--- | ||
duration_ms: * | ||
... | ||
1..8 | ||
ok 11 - only = true, with subtests | ||
--- | ||
duration_ms: * | ||
... | ||
1..11 | ||
# tests 11 | ||
# pass 1 | ||
# fail 0 | ||
# skipped 10 | ||
# 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
Oops, something went wrong.