Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions modules/shell/tests/transcription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,17 @@ fn a_transcript_ended_by_kitokey_ends_with_what_it_started_and_is_not_written()
assert!(alive(&child));
transcription.end();
assert_eq!(end(&said), Made::Failed(String::new()));
assert!(!alive(&child), "what the program started is left running");
// Its group killed, the child is gone once the KILL is delivered and it is reaped — by the
// system, its parent gone: a moment after the answer on a loaded machine, a zombie meanwhile,
// which `kill -0` still finds (#845). Waited for as a state, within half a second.
let killed = std::time::Instant::now();
while !gone(&child) && killed.elapsed() < Duration::from_millis(500) {
std::thread::sleep(Duration::from_millis(10));
}
assert!(
gone(&child),
"what the program started is left running half a second after the answer"
);
assert!(!folder.path().join("session/transcript.jsonl").exists());
}

Expand Down Expand Up @@ -341,9 +351,16 @@ sleep 60"#,
let pressed = std::time::Instant::now();
transcription.cancel();
let ended = said.recv_timeout(Duration::from_secs(2)).expect("not ended within two seconds");
let answered = pressed.elapsed();
assert!(matches!(ended, Made::Failed(_)), "{ended:?}");
assert!(gone(&child), "its child, deaf to TERM, still runs");
assert!(pressed.elapsed() <= Duration::from_secs(2));
assert!(answered <= Duration::from_secs(2), "{answered:?}");
// The KILL sent, the child is gone once the kernel has delivered it and the process is reaped:
// a moment after the answer on a loaded machine (#845). Waited for as a state, within half a second.
let killed = std::time::Instant::now();
while !gone(&child) && killed.elapsed() < Duration::from_millis(500) {
std::thread::sleep(Duration::from_millis(10));
}
assert!(gone(&child), "its child, deaf to TERM, still runs half a second after the answer");
}

#[test]
Expand Down
Loading