GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test_runner: add cwd option to run by pmarchini · Pull Request #54705 · nodejs/node

Conversation

@pmarchini

@pmarchini pmarchini commented Sep 1, 2024

Copy link
Copy Markdown
Member

I'm opening this PR as a draft to have a place where we can discuss this implementation.

Some background context:

During #54225, we discussed the possibility of adding a new option to run.
This new option would be cwd.

This change could impact many other parts of the code, such as:
#54225 (comment)

I just pushed a new commit.

Nice. I realized that this new cwd option may introduce new bugs in at least three places:

  • With --experimental-test-isolation=none.
  • With code coverage reporting.
  • With test locations.

For this reason, we decided to work on this in a separate PR (#54225 (comment)).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

avivkeller, bricss, and mcollina reacted with eyes emoji
All reactions
  • 👀 3 reactions
@nodejs-github-bot

nodejs-github-bot commented Sep 1, 2024

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/test_runner
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels Sep 1, 2024
avivkeller
avivkeller reviewed Sep 1, 2024
View reviewed changes
Comment thread doc/api/test.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread doc/api/test.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig

cjihrig commented Sep 3, 2024

Copy link
Copy Markdown
Contributor
  • With --experimental-test-isolation=none.

We need to turn the cwd option into a URL and get the href.

  • With code coverage reporting.

If we make the cwd a part of the globalOptions object, the coverage code will have access to it.

  • With test locations.

Same thing. The test object there will have a reference to the cwd.

pmarchini and MoLow reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pmarchini

pmarchini commented Sep 3, 2024

Copy link
Copy Markdown
Member Author

@cjihrig thanks for the support, I'm gonna take a look ASAP!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pmarchini
pmarchini force-pushed the feat/cwd-option-run branch from 4fa3784 to 3419393 Compare September 11, 2024 09:35
avivkeller
avivkeller reviewed Sep 11, 2024
View reviewed changes
Comment thread doc/api/cli.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/node_options.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread doc/api/cli.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/internal/test_runner/utils.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/node_options.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/parallel/test-runner-run.mjs Resolved

Uh oh!

There was an error while loading. Please reload this page.

cjihrig
cjihrig reviewed Sep 11, 2024
View reviewed changes
Comment thread src/node_options.cc Outdated

@cjihrig cjihrig Sep 11, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should add this. The cwd option should be supported by the run() API only IMO.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pmarchini pmarchini Sep 11, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, makes sense! I was thinking about a way to set the entire test runner's cwd to allow this behavior to be configured via the CLI as well.

Btw, while working on this, I noticed an unexpected behavior related to isolation and watch mode.
I'm going to open a PR to ask for your feedback, @cjihrig

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@avivkeller avivkeller Sep 11, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the user wants to use the CLI, they could do something like cd path/to/tests && node --test

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pmarchini reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@pmarchini pmarchini Sep 11, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pmarchini
pmarchini force-pushed the feat/cwd-option-run branch from fc95c78 to 518bb16 Compare September 11, 2024 14:48
@avivkeller avivkeller added the commit-queue-squash PRs the Commit Queue should land as one squashed commit. label Sep 11, 2024
avivkeller
avivkeller reviewed Sep 12, 2024
View reviewed changes
Comment thread lib/internal/test_runner/coverage.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

cjihrig
cjihrig reviewed Sep 12, 2024
View reviewed changes
Comment thread lib/internal/test_runner/runner.js Outdated
Comment on lines 568 to 572

@cjihrig cjihrig Sep 12, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather not do this. existsSync() specifically is a race condition. Just assume that the cwd is a directory and handle any errors. For example, the child process APIs, which also take a cwd option don't perform this type of validation.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pmarchini reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@pmarchini pmarchini Sep 12, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the validation and added a couple of tests to check that run handles an incorrect cwd without throwing errors

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cjihrig reacted with hooray emoji
All reactions
  • 🎉 1 reaction
cjihrig
cjihrig reviewed Sep 12, 2024
View reviewed changes
Comment thread lib/internal/test_runner/coverage.js Outdated

@cjihrig cjihrig Sep 12, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should ensure that options.cwd always exists and remove the ?? process.cwd() fallback.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

avivkeller and pmarchini reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
cjihrig
cjihrig reviewed Sep 12, 2024
View reviewed changes
Comment thread lib/internal/test_runner/harness.js Outdated

@cjihrig cjihrig Sep 12, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to get the cwd from the rootTest here instead of adding another argument.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pmarchini pmarchini Sep 16, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pmarchini pmarchini Sep 16, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the meantime, I've seen that in harness.js we have:

node/lib/internal/test_runner/harness.js

Lines 80 to 90 in c1afd2c

harness.resetCounters();
globalRoot = new Test({
__proto__: null,
...rootTestOptions,
harness,
name: '<root>',
});
setupProcessState(globalRoot, globalOptions, harness);
globalRoot.startTime = hrtime();
return globalRoot;
}

While the method definition is:

node/lib/internal/test_runner/harness.js

Lines 182 to 184 in c1afd2c

function setupProcessState(root, globalOptions) {
const hook = createHook({

Can I remove harness from the setupProcessState method call, or should I do that in a separate PR?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
cjihrig
cjihrig reviewed Sep 12, 2024
View reviewed changes
Comment thread lib/internal/test_runner/harness.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

cjihrig
cjihrig reviewed Sep 12, 2024
View reviewed changes
Comment thread src/node_options.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

cjihrig
cjihrig reviewed Sep 12, 2024
View reviewed changes
Comment thread test/parallel/test-runner-no-isolation-different-cwd.mjs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@pmarchini
pmarchini force-pushed the feat/cwd-option-run branch 2 times, most recently from 924c375 to ac74667 Compare September 16, 2024 10:06
@pmarchini
pmarchini marked this pull request as ready for review September 16, 2024 13:21
@codecov

codecov Bot commented Sep 16, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 83.33333% with 3 lines in your changes missing coverage. Please review.

Project coverage is 88.42%. Comparing base (89a2f56) to head (a162f2d).
Report is 31 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/test_runner/runner.js 78.57% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #54705      +/-   ##
==========================================
+ Coverage   88.39%   88.42%   +0.02%     
==========================================
  Files         652      652              
  Lines      186565   186576      +11     
  Branches    36046    36050       +4     
==========================================
+ Hits       164916   164981      +65     
+ Misses      14908    14866      -42     
+ Partials     6741     6729      -12     
Files with missing lines Coverage Δ
lib/internal/test_runner/coverage.js 64.69% <100.00%> (-0.06%) ⬇️
lib/internal/test_runner/harness.js 92.67% <100.00%> (+0.02%) ⬆️
lib/internal/test_runner/runner.js 89.42% <78.57%> (+2.38%) ⬆️

... and 45 files with indirect coverage changes

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pmarchini
pmarchini commented Sep 18, 2024
View reviewed changes
Comment thread test/parallel/test-runner-watch-mode.mjs Outdated
Comment on lines 93 to 96

@pmarchini pmarchini Sep 18, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @cjihrig, regarding these tests, I was working on a GitHub codespace yesterday, and I noticed that this test was flaky there.
The issue was with the interval: if the system is delayed for any reason beyond the timeout, a second run of "rename" (and similarly for "delete") is triggered, causing an error because the file has already been renamed and can no longer be found under its previous name.

I'll take a look at the other similar tests

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@cjihrig cjihrig Sep 18, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. Timers in tests should be avoided like the plague if possible.

Do we need to use an interval for operations like that? For example, would it work to use a setTimeout() and then reschedule the callback again once the timer fires?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pmarchini pmarchini Sep 20, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @cjihrig, I agree, I hadn’t thought about replacing it with setTimeout 😬
I’ll do it ASAP !

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pmarchini pmarchini Sep 20, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cjihrig, following another fix I was working on for a related flaky test, test/parallel/test-runner-watch-mode-complex.mjs, and following your suggestions, I removed the setIntervals in an attempt to simplify the test's readability while hopefully preventing flakiness

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pmarchini pmarchini mentioned this pull request Sep 20, 2024
test_runner: do not read from process.argv and process.cwd() in run() #53867
Open
@pmarchini
pmarchini force-pushed the feat/cwd-option-run branch 2 times, most recently from 25deaa7 to 29d93c6 Compare September 20, 2024 19:18
cjihrig
cjihrig reviewed Sep 21, 2024
View reviewed changes
Comment thread test/fixtures/test-runner-watch.mjs Outdated
Comment on lines 40 to 41

@cjihrig cjihrig Sep 21, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be simplified to:

Suggested change
...(cwd ? { cwd } : {}),
...(isolation ? { isolation } : {}),
cwd,
isolation,

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pmarchini reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread test/parallel/test-runner-watch-mode.mjs Outdated

@cjihrig cjihrig Sep 21, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use setTimeout() from node:timers/promises (or is this just the changes from your other PR?)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pmarchini pmarchini Sep 22, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely! I worked on them at the same time.
I need to port what we did on the other test to this one 😁

This change could also reduce the flakiness of this test (at least I hope so)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pmarchini pmarchini Sep 22, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread lib/internal/test_runner/harness.js Outdated

@cjihrig cjihrig Sep 21, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it would be more efficient to either:

  1. Add cwd to the object returned in parseCommandLine(). Although then that function is not strictly only working with the command line.
  2. Do globalOptions.cwd = process.cwd() here instead of creating an object in parseCommandLine(), spreading it here, and creating a new object containing all the same values as the original object.

I'm personally leaning toward option 2.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pmarchini pmarchini Sep 22, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @cjihrig, I agree regarding option 2.
IMHO option 1 would make sense if we were adding a new option.

I'm going to take a look ASAP

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pmarchini
pmarchini force-pushed the feat/cwd-option-run branch from 29d93c6 to e832333 Compare September 22, 2024 19:29
mcollina
mcollina approved these changes Sep 23, 2024
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Sep 23, 2024
@cjihrig cjihrig added the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 3, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 3, 2024
@nodejs-github-bot
nodejs-github-bot merged commit 1c7795e into nodejs:main Oct 3, 2024
@nodejs-github-bot

nodejs-github-bot commented Oct 3, 2024

Copy link
Copy Markdown
Collaborator

Landed in 1c7795e

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@targos targos added the backport-requested-v22.x PRs awaiting manual backport to the v22.x-staging branch. label Oct 5, 2024
@targos

targos commented Oct 5, 2024

Copy link
Copy Markdown
Member

The commit lands cleanly on v22.x-staging but test fails:

./node test/parallel/test-runner-no-isolation-different-cwd.mjs
before one: <root>
suite one
before two: <root>
suite two
beforeEach one: suite one - test
beforeEach two: suite one - test
suite one - test
afterEach one: suite one - test
afterEach two: suite one - test
beforeEach one: test one
beforeEach two: test one
test one
afterEach one: test one
afterEach two: test one
before suite two: suite two
beforeEach one: suite two - test
beforeEach two: suite two - test
suite two - test
afterEach one: suite two - test
afterEach two: suite two - test
after one: <root>
after two: <root>
node:internal/modules/run_main:122
    triggerUncaughtException(
    ^

AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
+ actual - expected ... Lines skipped

  [
    'before one: <root>',
...
    'afterEach one: suite one - test',
    'afterEach two: suite one - test',
+   'beforeEach one: test one',
+   'beforeEach two: test one',
+   'test one',
+   'afterEach one: test one',
+   'afterEach two: test one',
    'before suite two: suite two',
...
    'after one: <root>',
    'after two: <root>'
  ]
    at file:///Users/mzasso/git/nodejs/v22.x/test/parallel/test-runner-no-isolation-different-cwd.mjs:16:1
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig

cjihrig commented Oct 5, 2024

Copy link
Copy Markdown
Contributor

My guess is that the problem is the fixture's only test which requires --test-only on v22, but does not on main.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pmarchini

pmarchini commented Oct 5, 2024

Copy link
Copy Markdown
Member Author

I'll take a look ASAP

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pmarchini

pmarchini commented Oct 8, 2024

Copy link
Copy Markdown
Member Author

Hey @cjihrig, I just took a quick look and the fixtures are not using only.

Given one.test.js:

suite('suite one', function() {
  record(this.name);

  test('suite one - test', { only: true }, function() {
    record(this.name);
  });
});

test('test one', function() {
  record(this.name);
});

and checking the output it seems that the failing output on the v22.x-staging is indeed correct.
Idk why but it seems that in main, atm, given those test files, we're only executing the tests contained inside the suite and not the standalone test ('test one').

The behaviour I would expect is the one in v22.x-staging, do we agree on this?

Note:

I just tried to execute
./node --test --experimental-test-isolation=none test/fixtures/test-runner/no-isolation/one.test.js
and
./node --test --experimental-test-isolation=process test/fixtures/test-runner/no-isolation/one.test.js.

The output is different, when isolation == none we're skipping

test('test one', function() {
  record(this.name);
});

(I just tested this in main)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig

cjihrig commented Oct 8, 2024

Copy link
Copy Markdown
Contributor

I just took a quick look and the fixtures are not using only.

I believe it is:

test('suite one - test', { only: true }, function() {

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pmarchini

pmarchini commented Oct 8, 2024

Copy link
Copy Markdown
Member Author

I just took a quick look and the fixtures are not using only.

I believe it is:

test('suite one - test', { only: true }, function() {

Sorry, I completely missed it, even though I had just recopied it 😬

cjihrig reacted with laugh emoji
All reactions
  • 😄 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pmarchini

pmarchini commented Oct 8, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

@cjihrig, but still, do you think it makes sense to have two different behaviors based on the isolation?
Honestly, I wasn't expecting this.

Note:

> ./node --test --experimental-test-isolation=none  test/fixtures/test-runner/no-isolation/one.test.js
▶ suite one
  ✔ suite one - test (0.510791ms)
✔ suite one (0.929208ms)
ℹ tests 1
ℹ suites 1
ℹ pass 1
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 14.173333

and

> ./node --test --experimental-test-isolation=process  test/fixtures/test-runner/no-isolation/one.test.js
▶ suite one
  ✔ suite one - test (0.441834ms)
  ℹ 'only' and 'runOnly' require the --test-only command-line option.
✔ suite one (0.865417ms)
✔ test one (0.209416ms)
ℹ tests 2
ℹ suites 1
ℹ pass 2
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 94.562917
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig

cjihrig commented Oct 8, 2024

Copy link
Copy Markdown
Contributor

do you think it makes sense to have two different behaviors based on the isolation?

For the only flag, I do. When running multiple test processes in parallel, some things are inherently different. For example, look at mocha, which calls out "some important implications of the behavior" including not supporting only at all.

pmarchini reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pmarchini

pmarchini commented Oct 8, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

do you think it makes sense to have two different behaviors based on the isolation?

For the only flag, I do. When running multiple test processes in parallel, some things are inherently different. For example, look at mocha, which calls out "some important implications of the behavior" including not supporting only at all.

I agree, but I think I might be missing something here.

Why is test-only the default when isolation == none? As a user, I would expect to have to set --test-only even when isolation == none (or perhaps the reverse should be true).

What I mean is, I would expect the same default behavior regardless of the isolation mode.

This is an honest question. Considering that 22.x is still following this logic, I suppose it's something that was considered and decided recently. I'm not strongly opinionated on this, just curious.

EDIT: As always, thanks for your time and support! 🚀

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig

cjihrig commented Oct 8, 2024

Copy link
Copy Markdown
Contributor

The idea is that no one ever wants to type --test-only because only tests can be automatically detected and handled appropriately. only is uniquely annoying because the test runner has to discover all of the tests that it will run, determine if any only tests were found, and if so, then apply filtering.

When using process isolation the annoyance factor is 100x worse because that logic needs to be coordinated across multiple child processes. It is technically possible to support, but the complexity and performance overhead are not worth it IMO. Prior to isolation=none existing, process isolation was the only mode of execution, so we needed a way to handle only tests. That's how --test-only came to be (the idea was copied from node-tap).

pmarchini reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pmarchini

pmarchini commented Oct 8, 2024

Copy link
Copy Markdown
Member Author

@cjihrig, thank you for the explanation, it makes perfect sense 😁
I suppose this problem will be fixed as soon as #54832 is backported to 22.x, right?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cjihrig

cjihrig commented Oct 8, 2024

Copy link
Copy Markdown
Contributor

I believe so.

pmarchini reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aduh95

aduh95 commented Oct 9, 2024

Copy link
Copy Markdown
Contributor

I suppose this problem will be fixed as soon as #54832 is backported to 22.x, right?

AFAICT that PR is already on v22.x, but trying to cherry-pick the commit from this PR still have a failing test.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pmarchini

pmarchini commented Oct 10, 2024

Copy link
Copy Markdown
Member Author

Hey @aduh95, I just tested locally, and I think we're missing this PR: #54881 (landed in commit dbaef33)
I tried cherry-picking that specific commit into 22.x-staging, and it fixes this test.

I suppose it can't be backported, as it's a semver-major.

Note: forgive me if what I've said doesn't make sense; I'm not super confident about backporting and release management 😬

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aduh95 aduh95 mentioned this pull request Oct 14, 2024
2024-10-16, Version 23.0.0 (Current) #55338
Merged
@aduh95

aduh95 commented Jan 31, 2025

Copy link
Copy Markdown
Contributor

Not having this on v22.x creates more and more divergence between 23.x and 22.x, causing more and more backports to fail. It would be very helpful to work on a backport before the tech debt has grown out of proportions. IIUC it would probably require to find a way to backport #54881 in a non-semver-major way

pmarchini and tonivj5 reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Jan 31, 2025
test_runner: pass options directly to TestCoverage #55578
Merged
test_runner: exclude test files from coverage by default #56060
Merged
test_runner,cli: mark test isolation as stable #56298
Merged
@cjihrig

cjihrig commented Feb 3, 2025

Copy link
Copy Markdown
Contributor

@aduh95 maybe #54881 should be treated as a bug fix? I don't think it would realistically break anyone and it would unblock backporting all of these other changes.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@murataslan1 murataslan1 mentioned this pull request Mar 21, 2026
test_runner: avoid reading process state directly in run() #62377
Open
@AliMahmoudDev AliMahmoudDev mentioned this pull request May 26, 2026
test_runner: pass processExecArgv and globPatterns to run() instead of reading process directly #63580
Closed
@Chrismart04 Chrismart04 mentioned this pull request Jun 28, 2026
test_runner: stop reading process state in run() #64186
Open
3 of 4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@lemire lemire lemire left review comments
@avivkeller avivkeller avivkeller left review comments
@mcollina mcollina mcollina approved these changes
@cjihrig cjihrig cjihrig approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. backport-requested-v22.x PRs awaiting manual backport to the v22.x-staging branch. commit-queue-squash PRs the Commit Queue should land as one squashed commit. test_runner Issues and PRs related to the test runner subsystem.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@pmarchini @nodejs-github-bot @cjihrig @targos @aduh95 @mcollina @lemire @avivkeller
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.