-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
test: add tests for time in wasm32-unknown-unknown #7510
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5642a74
test: add tests for time and wasm
unvalley 298c8f9
fix: test
unvalley 3e50c2c
Merge branch 'master' into test-instant-now
unvalley f858d13
test: fix test and enable time feature on ci
unvalley d199318
Merge branch 'test-instant-now' of https://github.com/unvalley/tokio …
unvalley b21663e
chore: enable rt
unvalley 0825a4c
chore: add comment
unvalley a273739
ci: update matrix for wasm test
unvalley 3324f68
Add rt without time test config
Darksonn 409676d
Merge branch 'master' into test-instant-now
Darksonn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#![warn(rust_2018_idioms)] | ||
#![cfg(all(target_arch = "wasm32", not(target_os = "wasi")))] | ||
|
||
use wasm_bindgen_test::wasm_bindgen_test; | ||
|
||
#[wasm_bindgen_test] | ||
#[should_panic] | ||
fn instant_now_panics() { | ||
let _ = tokio::time::Instant::now(); | ||
} | ||
|
||
#[cfg(all(feature = "rt", not(feature = "time")))] | ||
#[wasm_bindgen_test] | ||
fn runtime_without_time_does_not_panic() { | ||
let rt = tokio::runtime::Builder::new_current_thread() | ||
.build() | ||
.unwrap(); | ||
rt.block_on(async {}); | ||
} | ||
Darksonn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#[cfg(all(feature = "rt", feature = "time"))] | ||
#[wasm_bindgen_test] | ||
#[should_panic] // should remove this once time is supported | ||
fn runtime_with_time_does_not_panic() { | ||
let rt = tokio::runtime::Builder::new_current_thread() | ||
.build() | ||
.unwrap(); | ||
rt.block_on(async {}); | ||
} | ||
|
||
#[cfg(all(feature = "rt", feature = "time"))] | ||
#[wasm_bindgen_test] | ||
#[should_panic] | ||
fn sleep_panics_on_unknown_unknown() { | ||
let rt = tokio::runtime::Builder::new_current_thread() | ||
.enable_time() | ||
.build() | ||
.unwrap(); | ||
rt.block_on(async { tokio::time::sleep(core::time::Duration::from_millis(1)).await }); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The wasm target runs according to this configuration:
tokio/.github/workflows/ci.yml
Lines 1041 to 1057 in 0922aa2
Here, time is not enabled, so this means that we do not run these tests with time enabled at all! You'll have to modify the
ci.yml
file to test the time case.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.
Oops, thank you for clarifying! Do we also need to add rt feature here?
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.
We probably need to run multiple combinations here to really test this.