Skip to content

Commit fcc888a

Browse files
authored
Fix the hello-stdout-post-return-test (#12569)
This fixes a mistake in the test added in #12185 where the test passes both with and without the changes in that commit due to the way it was structured. Restructuring the test, notably not waiting for `write_via_stream` to return, means that it's now accurately testing that the `TaskExit` value is used.
1 parent 112112d commit fcc888a

1 file changed

Lines changed: 13 additions & 17 deletions

File tree

crates/test-programs/src/bin/p3_cli_hello_stdout_post_return.rs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,19 @@ export!(Component);
77
impl exports::wasi::cli::run::Guest for Component {
88
async fn run() -> Result<(), ()> {
99
let (mut tx, rx) = wit_stream::new();
10-
futures::join!(
11-
async {
12-
wasi::cli::stdout::write_via_stream(rx).await.unwrap();
13-
},
14-
async {
15-
tx.write_all(b"hello, world\n".to_vec()).await;
16-
wit_bindgen::spawn(async move {
17-
// Yield a few times to allow the host to accept and process
18-
// the `run` result.
19-
for _ in 0..10 {
20-
wit_bindgen::yield_async().await;
21-
}
22-
tx.write_all(b"hello again, after return\n".to_vec()).await;
23-
drop(tx);
24-
});
25-
},
26-
);
10+
wit_bindgen::spawn(async move {
11+
wasi::cli::stdout::write_via_stream(rx).await.unwrap();
12+
});
13+
tx.write_all(b"hello, world\n".to_vec()).await;
14+
wit_bindgen::spawn(async move {
15+
// Yield a few times to allow the host to accept and process
16+
// the `run` result.
17+
for _ in 0..10 {
18+
wit_bindgen::yield_async().await;
19+
}
20+
tx.write_all(b"hello again, after return\n".to_vec()).await;
21+
drop(tx);
22+
});
2723
Ok(())
2824
}
2925
}

0 commit comments

Comments
 (0)