GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — test_runner: add cwd option to run by pmarchini · Pull Request #54705 · nodejs/node Conversation
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 This change could impact many other parts of the code, such as:
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. All reactions
Collaborator
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
avivkeller
reviewed
Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page.
Contributor
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
pmarchini
force-pushed
the
feat/cwd-option-run
branch
from
4fa3784 to
3419393
Compare
avivkeller
reviewed
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. Uh oh!
There was an error while loading. Please reload this page.
cjihrig
reviewed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should add this. The
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Btw, while working on this, I noticed an unexpected behavior related to isolation and watch mode.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
force-pushed
the
feat/cwd-option-run
branch
from
fc95c78 to
518bb16
Compare
avivkeller
reviewed
Uh oh!
There was an error while loading. Please reload this page.
cjihrig
reviewed
Comment on lines
568
to
572
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would rather not do this.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
cjihrig
reviewed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should ensure that
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
cjihrig
reviewed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer to get the
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the meantime, I've seen that in node/lib/internal/test_runner/harness.js Lines 80 to 90 in c1afd2c
While the method definition is: node/lib/internal/test_runner/harness.js Lines 182 to 184 in c1afd2c
Can I remove
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
cjihrig
reviewed
Uh oh!
There was an error while loading. Please reload this page.
cjihrig
reviewed
Uh oh!
There was an error while loading. Please reload this page.
cjihrig
reviewed
Uh oh!
There was an error while loading. Please reload this page.
pmarchini
force-pushed
the
feat/cwd-option-run
branch
2 times, most recently
from
924c375 to
ac74667
Compare
pmarchini
marked this pull request as ready for review
|
There was an error while loading. Please reload this page.
Codecov ReportAttention: Patch coverage is
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
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
25deaa7 to
29d93c6
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can this be simplified to:
| ...(cwd ? { cwd } : {}), | |
| ...(isolation ? { isolation } : {}), | |
| cwd, | |
| isolation, |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
done
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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:
cwd to the object returned in parseCommandLine(). Although then that function is not strictly only working with the command line.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.
There was an error while loading. Please reload this page.
There was a problem 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.
There was an error while loading. Please reload this page.
29d93c6 to
e832333
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Landed in 1c7795e |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The commit lands cleanly on v22.x-staging but test fails: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
My guess is that the problem is the fixture's |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I'll take a look ASAP |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hey @cjihrig, I just took a quick look and the fixtures are not using 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 The behaviour I would expect is the one in Note: I just tried to execute The output is different, when test('test one', function() { record(this.name); }); (I just tested this in main) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I believe it is:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, I completely missed it, even though I had just recopied it 😬 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@cjihrig, but still, do you think it makes sense to have two different behaviors based on the isolation? 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 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
For the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
I agree, but I think I might be missing something here. Why is 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! 🚀 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The idea is that no one ever wants to type 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 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I believe so. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
AFAICT that PR is already on |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hey @aduh95, I just tested locally, and I think we're missing this PR: #54881 (landed in commit dbaef33) I suppose it can't be backported, as it's a Note: forgive me if what I've said doesn't make sense; I'm not super confident about backporting and release management 😬 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
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 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.