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: https://github.com/nodejs/node/pull/60265
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
This commit is contained in:
Joyee Cheung 2025-10-17 15:14:11 +02:00 committed by GitHub
parent 875a7bb8d2
commit 8096aeab81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 0 deletions

View File

@ -421,6 +421,27 @@ You can also execute the tests in a test suite directory
tools/test.py test/message
```
You can execute tests that match a specific naming pattern using the wildcard
`*`. For example, to run all tests under `test/parallel` with a name that starts
with `test-stream-`:
```bash
tools/test.py test/parallel/test-stream-*
tools/test.py parallel/test-stream-* # The test/ prefix can be omitted
# In some shell environments, you may need to quote the pattern
tools/test.py "test/parallel/test-stream-*"
```
The whildcard `*` can be used in any part of the path. For example, to run all tests
with a name that starts with `test-inspector-`, regardless of the directory they are in:
```bash
# Matches test/sequential/test-inspector-*, test/parallel/test-inspector-*,
# test/known_issues/test-inspector-*, etc.
tools/test.py "test/*/test-inspector-*"
tools/test.py "*/test-inspector-*" # The test/ prefix can be omitted
```
If you want to check the other options, please refer to the help by using
the `--help` option:

View File

@ -485,6 +485,11 @@ To generate a test coverage report, see the
Nightly coverage reports for the Node.js `main` branch are available at
<https://coverage.nodejs.org/>.
## Running tests
See the [Building guide](../../BUILDING.md#running-tests) for details on how to
run tests.
[ASCII]: https://man7.org/linux/man-pages/man7/ascii.7.html
[Google Test]: https://github.com/google/googletest
[Test Coverage section of the Building guide]: https://github.com/nodejs/node/blob/HEAD/BUILDING.md#running-coverage