Skip to content
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: recalculate run duration on watch restart #57786

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pmarchini
Copy link
Member

Re-running a test using the --watch flag keeps the duration unchanged across the various reruns.
I've drafted a trivial implementation.

The test I introduced is flaky by design; I need to consider a better approach even though the number of digits is high and the likelihood of getting the same number in two consecutive runs is really low.

image

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@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 Apr 7, 2025

// Reset the root start time to recalculate the duration
// of the run
opts.root.clearStartTime();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason not to put this with the other reset logic here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, I just drafted the PR based on what I saw while working on the global setup/teardown, was not meant to be ready!
You're right, the section you highlighted is 100% the right place!
I'll push a new commit ASAP!

Copy link
Member Author

Choose a reason for hiding this comment

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

@cjihrig The only issue I see is that at that point we're resetting the values for the next run, so we can't reset the time there.
By setting it to zero, the effect is that the value gets recalculated in the postRun (if I'm not mistaken).
The test doesn't go through run again and doesn't recalculate its start time.

I'll take a closer look tomorrow, but I'm afraid that, as things stand, the timer's start needs to be handled at the runner level.

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good to put all of the watch reset logic together if possible. If that means moving the current logic, that seems fine too.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree! As soon as I'm done fighting with Windows watch related tests, I'll take a deep dive into this one 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants