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

Implement an internal time type and Clock trait #4149

Merged
merged 2 commits into from
Feb 1, 2025
Merged

Conversation

hansl
Copy link
Contributor

@hansl hansl commented Jan 27, 2025

This will add the capacity for the entire engine to mock time during tests. No impact on performance should be noticeable.

Fixed #4144

This will add the capacity for the entire engine to mock time during
tests. No impact on performance should be noticeable.

Fixed boa-dev#4144
@hansl hansl requested a review from jedel1043 January 27, 2025 19:38
Copy link

codecov bot commented Jan 27, 2025

Codecov Report

Attention: Patch coverage is 61.40351% with 22 lines in your changes missing coverage. Please review.

Project coverage is 53.56%. Comparing base (6ddc2b4) to head (6e6d34c).
Report is 358 commits behind head on main.

Files with missing lines Patch % Lines
core/engine/src/context/time.rs 68.29% 13 Missing ⚠️
core/engine/src/context/mod.rs 37.50% 5 Missing ⚠️
core/engine/src/object/builtins/jsdate.rs 0.00% 3 Missing ⚠️
core/engine/src/builtins/date/mod.rs 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4149      +/-   ##
==========================================
+ Coverage   47.24%   53.56%   +6.31%     
==========================================
  Files         476      488      +12     
  Lines       46892    48923    +2031     
==========================================
+ Hits        22154    26204    +4050     
+ Misses      24738    22719    -2019     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hansl hansl requested a review from a team January 27, 2025 19:57
A negative duration is invalid.
Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

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

Loving the new API!

Comment on lines +185 to +188
#[deprecated(
since = "0.21.0",
note = "Use `context.clock().now().millis_since_epoch()` instead"
)]
Copy link
Member

Choose a reason for hiding this comment

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

Oooh, I like this! It should make it easier for users to migrate, and maybe we can comment when the deprecated API should be removed e.g. a version after deprecation or something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can always update the note later with more info.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll leave the deprecation policy of this repo to the leadership :)

@jedel1043 jedel1043 requested a review from a team January 31, 2025 23:31
Copy link
Member

@nekevss nekevss left a comment

Choose a reason for hiding this comment

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

Looks good to me overall :)

@jedel1043 jedel1043 added this pull request to the merge queue Feb 1, 2025
Merged via the queue into boa-dev:main with commit 2987565 Feb 1, 2025
14 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Feb 3, 2025
…imeout`) implementations (#4130)

* Make the HostHooks shareable

* `setTimeout`, `setInterval` and `clearInterval` (and the same `clearTimeout`) implementations

This adds non-async implementations of the `setTimeout`/`setInterval` API functions. They are by default registered in the context when registering all APIs from `boa_runtime`.

* Add timeout jobs to tokio/smol event_loop examples and fix borrow issue

* Fix compiling issue in smol_event_loop

* Fix documentation generation for job

* Implement an internal time type and Clock trait

This will add the capacity for the entire engine to mock time during
tests. No impact on performance should be noticeable.

Fixed #4144

* Retype JsDuration in/out to unsigned

A negative duration is invalid.

* Rework the PR to merge the clock from #4149

* Rework the PR to merge the clock from #4149

* Fix smol/tokio event loops

* Remove unused crate
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.

Newtypes JsInstant and JsDuration to allow Boa, hosts and libraries a single (wall) clock type
3 participants