Uh oh!
There was an error while loading. Please reload this page.
test_runner: improve --test-name-pattern to allow matching single test - #51577
Conversation
nodejs-github-bot
commented
Jan 27, 2024
Review requested:
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
9603fec to
f47b2b0Comparemdrobny
commented
Jan 27, 2024
I fixed too long commit message, it should pass the lint now |
MoLow
commented
Jan 27, 2024
do we have a benchmark test for |
@MoLow you are right, there can be negative performance implications when using I can try to write some naive benchmark test. So far, for 1000 test suits, I didn't observe any meaningful difference |
mdrobny
commented
Jan 30, 2024
I experimented with benchmarking test runner with mitata package. It repeats many times the operation and does the measurements Here is the test suite repeated 1000 times const{describe, it}=require('node:test');for(leti=0;i<1000;i++){describe('describeTest',()=>{it('itTest1',()=>{});it('itTest2',()=>{});describe('describeTest',()=>{it('itTest1',()=>{});it('itTest2',()=>{});});})}here is the benchmark code using my locally compiled version of Node with changes from this branch import{run,bench,group,baseline}from'mitata';import{spawnSync}from'node:child_process'constpathToLocalNode='../../node/node';group('test runner',()=>{baseline('no pattern',()=>{spawnSync(pathToLocalNode,['--test'],{stdio: 'ignore'})});bench('with name pattern not matching any test',()=>{spawnSync(pathToLocalNode,['--test-name-pattern','nothing','--test'],{stdio: 'ignore'})})bench('with name pattern matching all tests',()=>{spawnSync(pathToLocalNode,['--test-name-pattern','describeTest','--test'],{stdio: 'ignore'})})bench('with name pattern matching single test',()=>{spawnSync(pathToLocalNode,['--test-name-pattern','describeTest describeTest itTest2','--test'],{stdio: 'ignore'})})});awaitrun();those are the results from running benchmark on my computer (Macbook with M1 Pro) ![]() Looks like there is almost no difference when using |
mdrobny
commented
Feb 15, 2024
@MoLow what do you think about the benchmark results? |
nodejs-github-bot
commented
Feb 18, 2024
@MoLow why do you consider it a major (breaking) change? 🤔 |
nodejs-github-bot
commented
Feb 26, 2024
MoLow
commented
Feb 26, 2024
using the example from the documentation, added in this PR: describe('test 1',(t)=>{it('some test');});describe('test 2',(t)=>{it('some test');});
prior to this change, using |
MoLow
commented
Feb 26, 2024
@mdrobny please rebase this PR |
f47b2b0 to
a66c5a9Comparenodejs-github-bot
commented
Feb 29, 2024
Commit Queue failed- Loading data for nodejs/node/pull/51577 ✔ Done loading data for nodejs/node/pull/51577 ----------------------------------- PR info ------------------------------------ Title test_runner: improve `--test-name-pattern` to allow matching single test (#51577) Author Michał Drobniak (@mdrobny, first-time contributor) Branch mdrobny:feat/test-runner-match-unique-name -> nodejs:main Labels semver-major, author ready, needs-ci, test_runner Commits 1 - test_runner: improve `--test-name-pattern` to allow matching single test Committers 1 - mdrobny PR-URL: https://github.com/nodejs/node/pull/51577 Fixes: https://github.com/nodejs/node/issues/46728 Reviewed-By: Moshe Atlow Reviewed-By: Chemi Atlow ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/51577 Fixes: https://github.com/nodejs/node/issues/46728 Reviewed-By: Moshe Atlow Reviewed-By: Chemi Atlow -------------------------------------------------------------------------------- ℹ This PR was created on Sat, 27 Jan 2024 09:22:46 GMT ✔ Approvals: 2 ✔ - Moshe Atlow (@MoLow) (TSC): https://github.com/nodejs/node/pull/51577#pullrequestreview-1908557778 ✔ - Chemi Atlow (@atlowChemi): https://github.com/nodejs/node/pull/51577#pullrequestreview-1887168630 ✘ semver-major requires at least 2 TSC approvals ✔ Last GitHub CI successful ℹ Last Full PR CI on 2024-02-29T10:49:29Z: https://ci.nodejs.org/job/node-test-pull-request/57498/ - Querying data for job/node-test-pull-request/57498/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/8096266840 |
nodejs-github-bot
commented
Mar 1, 2024
Landed in 00dc6d9 |

Try to match a test by name prefixed with all its ancestors to ensure uniqueness of the name
Fixes: #46728
It adds a feature that is present in all major test runners. It's well described in this comment
It allows developers to quickly run/debug a single test e.g. from their editor
I am a first time contributor 😉