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

fix(cli): use Instant for test times #22853

Merged
merged 1 commit into from
Mar 12, 2024
Merged

Conversation

mmastrac
Copy link
Contributor

Copy link
Collaborator

@iuioiua iuioiua left a comment

Choose a reason for hiding this comment

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

Nice

@iuioiua
Copy link
Collaborator

iuioiua commented Mar 12, 2024

There are other instances of the use of SystemTime::now() in the codebase. How many of them should use Instant::now() instead, too? Documentation says it's good for measuring the duration between two points in time.

@mmastrac
Copy link
Contributor Author

There are other instances of the use of SystemTime::now() in the codebase. How many of them should use Instant::now() instead, too? Documentation says it's good for measuring the duration between two points in time.

We should use SystemTime::now only in two cases:

  • One, if we are using elapsed time since the UNIX_EPOCH (this is generally safe)
  • Two, if we are printing a string date with the actual date/time

If we use SystemTime::now and a duration since anything but the unix epoch, that's definitely a problem!

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, from what I see the worst case is we're gonna get 0ms elapsed. Seems fine for tests.

@mmastrac mmastrac merged commit 61d86b9 into denoland:main Mar 12, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

flaky test failure on macOS with the error message error: second time provided was later than self
3 participants