Skip to content

Commit 13fbdac

Browse files
authored
process: add test for Child::kill after Child::wait (#7163)
1 parent 4380c3d commit 13fbdac

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#![warn(rust_2018_idioms)]
2+
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi cannot run system commands
3+
4+
use tokio::process::Command;
5+
6+
#[tokio::test]
7+
async fn kill_after_wait() {
8+
let mut cmd;
9+
10+
if cfg!(windows) {
11+
cmd = Command::new("cmd");
12+
cmd.arg("/c");
13+
} else {
14+
cmd = Command::new("sh");
15+
cmd.arg("-c");
16+
}
17+
18+
let mut child = cmd.arg("exit 2").spawn().unwrap();
19+
20+
child.start_kill().unwrap();
21+
22+
child.wait().await.unwrap();
23+
24+
// Kill after `wait` is fine.
25+
child.start_kill().unwrap();
26+
child.kill().await.unwrap();
27+
}

0 commit comments

Comments
 (0)