Skip to content

Commit 8096aea

Browse files
authored
doc: document wildcard supported by tools/test.py
This seems to be a underdocumented but useful trick that only very few people know about. Also add a pointer to the test running guide in the test writing guide. PR-URL: #60265 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
1 parent 875a7bb commit 8096aea

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

BUILDING.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,27 @@ You can also execute the tests in a test suite directory
421421
tools/test.py test/message
422422
```
423423

424+
You can execute tests that match a specific naming pattern using the wildcard
425+
`*`. For example, to run all tests under `test/parallel` with a name that starts
426+
with `test-stream-`:
427+
428+
```bash
429+
tools/test.py test/parallel/test-stream-*
430+
tools/test.py parallel/test-stream-* # The test/ prefix can be omitted
431+
# In some shell environments, you may need to quote the pattern
432+
tools/test.py "test/parallel/test-stream-*"
433+
```
434+
435+
The whildcard `*` can be used in any part of the path. For example, to run all tests
436+
with a name that starts with `test-inspector-`, regardless of the directory they are in:
437+
438+
```bash
439+
# Matches test/sequential/test-inspector-*, test/parallel/test-inspector-*,
440+
# test/known_issues/test-inspector-*, etc.
441+
tools/test.py "test/*/test-inspector-*"
442+
tools/test.py "*/test-inspector-*" # The test/ prefix can be omitted
443+
```
444+
424445
If you want to check the other options, please refer to the help by using
425446
the `--help` option:
426447

doc/contributing/writing-tests.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,11 @@ To generate a test coverage report, see the
485485
Nightly coverage reports for the Node.js `main` branch are available at
486486
<https://coverage.nodejs.org/>.
487487

488+
## Running tests
489+
490+
See the [Building guide](../../BUILDING.md#running-tests) for details on how to
491+
run tests.
492+
488493
[ASCII]: https://man7.org/linux/man-pages/man7/ascii.7.html
489494
[Google Test]: https://github.com/google/googletest
490495
[Test Coverage section of the Building guide]: https://github.com/nodejs/node/blob/HEAD/BUILDING.md#running-coverage

0 commit comments

Comments
 (0)