-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add a regression test for WASI (#4822)
Currently, we only have WASM regression tests that run without WASI. However, rust provides a WASI specific target which enables code to special case WASI. This PR adds a basic test to cover that case. This is an initial addition to help land #4716.
- Loading branch information
1 parent
4daeea8
commit ad942de
Showing
4 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 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 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,41 @@ | ||
use tokio::sync::oneshot; | ||
use tokio::task; | ||
|
||
async fn spawn_send() { | ||
let (tx, rx) = oneshot::channel(); | ||
|
||
let task = tokio::spawn(async { | ||
for _ in 0..10 { | ||
task::yield_now().await; | ||
} | ||
|
||
tx.send("done").unwrap(); | ||
}); | ||
|
||
assert_eq!("done", rx.await.unwrap()); | ||
task.await.unwrap(); | ||
} | ||
|
||
#[tokio::main(flavor = "current_thread")] | ||
async fn entry_point() { | ||
spawn_send().await; | ||
} | ||
|
||
#[tokio::test] | ||
async fn test_macro() { | ||
spawn_send().await; | ||
} | ||
|
||
#[test] | ||
fn main_macro() { | ||
entry_point(); | ||
} | ||
|
||
#[test] | ||
fn manual_rt() { | ||
let rt = tokio::runtime::Builder::new_current_thread() | ||
.build() | ||
.unwrap(); | ||
|
||
rt.block_on(async { spawn_send().await }); | ||
} |