diff --git a/tests/hook_cli.rs b/tests/hook_cli.rs index ca83f09..f6cb89c 100644 --- a/tests/hook_cli.rs +++ b/tests/hook_cli.rs @@ -1339,7 +1339,13 @@ fn stop_waits_for_a_baseline_that_is_still_being_written() { std::thread::spawn(move || { std::thread::sleep(std::time::Duration::from_secs(1)); let baseline = r#"{"ran":[["test","!","-e","red"]],"red":[["test","!","-e","red"]]}"#; - std::fs::write(directory.join("s-wait.json"), baseline).unwrap(); + // Renamed into place, as `SessionStart` writes it. Written in + // place instead, the file exists empty for an instant, and a Stop + // polling for it can read that instant as an unreadable baseline. + // The partial file's name is not the baseline's, so no poll opens it. + let partial = directory.join("s-wait.json.partial"); + std::fs::write(&partial, baseline).unwrap(); + std::fs::rename(&partial, directory.join("s-wait.json")).unwrap(); std::fs::remove_file(directory.join("s-wait.pending")).unwrap(); }) };