mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-25 12:00:35 +00:00
process: add test for Child::kill
after Child::wait
(#7163)
This commit is contained in:
parent
4380c3d821
commit
13fbdace66
27
tokio/tests/process_kill_after_wait.rs
Normal file
27
tokio/tests/process_kill_after_wait.rs
Normal file
@ -0,0 +1,27 @@
|
||||
#![warn(rust_2018_idioms)]
|
||||
#![cfg(all(feature = "full", not(target_os = "wasi"), not(miri)))] // Wasi cannot run system commands
|
||||
|
||||
use tokio::process::Command;
|
||||
|
||||
#[tokio::test]
|
||||
async fn kill_after_wait() {
|
||||
let mut cmd;
|
||||
|
||||
if cfg!(windows) {
|
||||
cmd = Command::new("cmd");
|
||||
cmd.arg("/c");
|
||||
} else {
|
||||
cmd = Command::new("sh");
|
||||
cmd.arg("-c");
|
||||
}
|
||||
|
||||
let mut child = cmd.arg("exit 2").spawn().unwrap();
|
||||
|
||||
child.start_kill().unwrap();
|
||||
|
||||
child.wait().await.unwrap();
|
||||
|
||||
// Kill after `wait` is fine.
|
||||
child.start_kill().unwrap();
|
||||
child.kill().await.unwrap();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user