forked from nodejs/node-core-test
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test_runner: add --test-name-pattern CLI flag
This commit adds support for running tests that match a regular expression. Fixes: nodejs/node#42984 (cherry picked from commit 87170c3f9271da947a7b33d0696ec4cf8aab6eb6)
- Loading branch information
Showing
12 changed files
with
334 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env node | ||
|
||
const { argv } = require('#internal/options') | ||
|
||
argv['test-name-pattern'] = true | ||
|
||
require('./node-core-test.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
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 @@ | ||
// https://github.com/nodejs/node/blob/87170c3f9271da947a7b33d0696ec4cf8aab6eb6/test/message/test_runner_test_name_pattern.js | ||
// Flags: --no-warnings --test-name-pattern=enabled --test-name-pattern=/pattern/i | ||
'use strict' | ||
const common = require('../common') | ||
const { | ||
after, | ||
afterEach, | ||
before, | ||
beforeEach, | ||
describe, | ||
it, | ||
test | ||
} = require('#node:test') | ||
|
||
test('top level test disabled', common.mustNotCall()) | ||
test('top level skipped test disabled', { skip: true }, common.mustNotCall()) | ||
test('top level skipped test enabled', { skip: true }, common.mustNotCall()) | ||
it('top level it enabled', common.mustCall()) | ||
it('top level it disabled', common.mustNotCall()) | ||
it.skip('top level skipped it disabled', common.mustNotCall()) | ||
it.skip('top level skipped it enabled', common.mustNotCall()) | ||
describe('top level describe disabled', common.mustNotCall()) | ||
describe.skip('top level skipped describe disabled', common.mustNotCall()) | ||
describe.skip('top level skipped describe enabled', common.mustNotCall()) | ||
test('top level runs because name includes PaTtErN', common.mustCall()) | ||
|
||
test('top level test enabled', common.mustCall(async (t) => { | ||
t.beforeEach(common.mustCall()) | ||
t.afterEach(common.mustCall()) | ||
await t.test( | ||
'nested test runs because name includes PATTERN', | ||
common.mustCall() | ||
) | ||
})) | ||
|
||
describe('top level describe enabled', () => { | ||
before(common.mustCall()) | ||
beforeEach(common.mustCall(2)) | ||
afterEach(common.mustCall(2)) | ||
after(common.mustCall()) | ||
|
||
it('nested it disabled', common.mustNotCall()) | ||
it('nested it enabled', common.mustCall()) | ||
describe('nested describe disabled', common.mustNotCall()) | ||
describe('nested describe enabled', common.mustCall(() => { | ||
it('is enabled', common.mustCall()) | ||
})) | ||
}) |
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,107 @@ | ||
TAP version 13 | ||
# Subtest: top level test disabled | ||
ok 1 - top level test disabled # SKIP test name does not match pattern | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: top level skipped test disabled | ||
ok 2 - top level skipped test disabled # SKIP test name does not match pattern | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: top level skipped test enabled | ||
ok 3 - top level skipped test enabled # SKIP | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: top level it enabled | ||
ok 4 - top level it enabled | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: top level it disabled | ||
ok 5 - top level it disabled # SKIP test name does not match pattern | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: top level skipped it disabled | ||
ok 6 - top level skipped it disabled # SKIP test name does not match pattern | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: top level skipped it enabled | ||
ok 7 - top level skipped it enabled # SKIP | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: top level describe disabled | ||
ok 8 - top level describe disabled # SKIP test name does not match pattern | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: top level skipped describe disabled | ||
ok 9 - top level skipped describe disabled # SKIP test name does not match pattern | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: top level skipped describe enabled | ||
ok 10 - top level skipped describe enabled # SKIP | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: top level runs because name includes PaTtErN | ||
ok 11 - top level runs because name includes PaTtErN | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: top level test enabled | ||
# Subtest: nested test runs because name includes PATTERN | ||
ok 1 - nested test runs because name includes PATTERN | ||
--- | ||
duration_ms: * | ||
... | ||
1..1 | ||
ok 12 - top level test enabled | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: top level describe enabled | ||
# Subtest: nested it disabled | ||
ok 1 - nested it disabled # SKIP test name does not match pattern | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: nested it enabled | ||
ok 2 - nested it enabled | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: nested describe disabled | ||
ok 3 - nested describe disabled # SKIP test name does not match pattern | ||
--- | ||
duration_ms: * | ||
... | ||
# Subtest: nested describe enabled | ||
# Subtest: is enabled | ||
ok 1 - is enabled | ||
--- | ||
duration_ms: * | ||
... | ||
1..1 | ||
ok 4 - nested describe enabled | ||
--- | ||
duration_ms: * | ||
... | ||
1..4 | ||
ok 13 - top level describe enabled | ||
--- | ||
duration_ms: * | ||
... | ||
1..13 | ||
# tests 13 | ||
# pass 4 | ||
# fail 0 | ||
# cancelled 0 | ||
# skipped 9 | ||
# 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,14 @@ | ||
// https://github.com/nodejs/node/blob/87170c3f9271da947a7b33d0696ec4cf8aab6eb6/test/message/test_runner_test_name_pattern_with_only.js | ||
// Flags: --no-warnings --test-only --test-name-pattern=enabled | ||
'use strict' | ||
const common = require('../common') | ||
const { test } = require('#node:test') | ||
|
||
test('enabled and only', { only: true }, common.mustCall(async (t) => { | ||
await t.test('enabled', common.mustCall()) | ||
await t.test('disabled', common.mustNotCall()) | ||
})) | ||
|
||
test('enabled but not only', common.mustNotCall()) | ||
test('only does not match pattern', { only: true }, common.mustNotCall()) | ||
test('not only and does not match pattern', common.mustNotCall()) |
Oops, something went wrong.