use super::*;
#[tokio::test]
async fn owned_child_terminate_stops_running_process() {
#[cfg(unix)]
let cmd = {
let mut c = Command::new("sh");
c.args(["-c", "sleep 30"]);
c
};
#[cfg(windows)]
let cmd = {
let mut c = Command::new("powershell.exe");
c.args(["-NoProfile", "-Command", "Start-Sleep -Seconds 30"]);
c
};
let mut child = OwnedChild::spawn(cmd).expect("spawn child");
let budget = TERMINATION_GRACE_PERIOD * 25;
let status = tokio::time::timeout(budget, async {
child.terminate().await;
child.wait().await
})
.await
.unwrap_or_else(|_| panic!("terminate did not stop the child within {budget:?}"))
.expect("wait on terminated child");
assert!(!status.success());
}