-
Notifications
You must be signed in to change notification settings - Fork 30.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test_runner: fix delete test file cause dependency file change not rerun the tests #53533
test_runner: fix delete test file cause dependency file change not rerun the tests #53533
Conversation
Review requested:
|
@@ -0,0 +1,100 @@ | |||
// Flags: --expose-internals |
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.
Is this used only for util.createDeferredPromise
?
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.
yes, it only used for util.createDeferredPromise
d79b8d7
to
e270e58
Compare
maybe we can get CI started again? 👀 |
let currentRun = ''; | ||
const runs = []; | ||
|
||
child.stdout.on('data', (data) => { |
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.
This could just be .toArray()
on child.stdout
which would also save the util.createDeferredPromise
and would make it easier to listen to stdout
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.
(just make sure to not await it before you trigger the watch)
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 I get a little bit of help here? I tried to use child.stdout.toArray()
- but I cannot seem to be able to control the test runs, I cannot manage to get 2 runs (get result for initial run 3/3 pass, delete a test file modify another test to get the result of second run 2/2 pass) successfully, I can only get result for 1 run
I must be doing something incorrectly.
Would you mind explaining not await to what?
(just make sure to not await it before you trigger the watch)
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 think I may have understood what you mean - use child.stdout.toArray()
to get a promise then delete a test file and update a file in order to trigger the rerun (watch), after that resolve the promise to get all the std out results, am I understanding correctly? 👀
Haven't got back from @benjamingr yet on #53533 (comment), shall we land this bug fix first and I can try to create a follow up PR to improve it. |
This comment was marked as outdated.
This comment was marked as outdated.
SGTM |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
When a watched test file is being deleted then the referenced dependency file(s) will be updated incorrect when `unfilterFilesOwnedBy` method is called, which will cause tests not being rerun when its referenced dependency changed. To prevent this case, we can simply `return` when we detect a watched test file being deleted.
Co-authored-by: Chemi Atlow <chemi@atlow.co.il>
I figured out the watch capability is limited in AIX which caused the test in CI on that platform to fail. |
a82efaa
to
b1e06fc
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #53533 +/- ##
==========================================
- Coverage 87.10% 87.10% -0.01%
==========================================
Files 647 647
Lines 181739 181759 +20
Branches 34887 34889 +2
==========================================
+ Hits 158310 158323 +13
- Misses 16738 16740 +2
- Partials 6691 6696 +5
|
Green CI now 🥳 would appreciate someone can take a look again and give a green tick so this PR is able to land (my latest change was skipping the test on AIX platform as the watch capability is restricted) |
@mcollina do you mind taking a quick look 🙏 as you recently did some work in this area as well |
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
Landed in 1212eca |
When a watched test file is being deleted then the referenced dependency file(s) will be updated incorrect when `unfilterFilesOwnedBy` method is called, which will cause tests not being rerun when its referenced dependency changed. To prevent this case, we can simply `return` when we detect a watched test file being deleted. PR-URL: #53533 Refs: #53114 Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
There is an edge case left from #53114
Reproduce step:
You would observe that
test-b.mjs
andtest-c.mjs
are not being rerun. The expected behaviour should betest-b.mjs
,test-c.mjs
being rerun and failed (sinceassert.strictEqual(a, 1)
is not correct anymore).Change explain:
When a watched test file is being deleted, the test runner will rerun the test(s) and because the test file is no longer there but the
dependencyOwners
wouldn't be able to know it, so it failed in silence. Since a test file is being deleted, we don't need to rerun anything so we can just safelyreturn
.notes:
The test is quite identical to
test/parallel/test-runner-watch-mode.mjs
but with a more complicated setup, I am thinking to spend some time to see how I can refactor the test so we can write more complicated test cases in the future, I am committed and would like to do a separate PR for it.Ref: #53114