From fdc69df4540c3f57ddd7047c50ddf4a34d8380a8 Mon Sep 17 00:00:00 2001 From: gt-oai Date: Mon, 26 Jan 2026 18:05:30 +0000 Subject: [PATCH] Fix flakey shell snapshot test (#9919) Sometimes fails with: ``` failures: ---- shell_snapshot::tests::timed_out_snapshot_shell_is_terminated stdout ---- thread 'shell_snapshot::tests::timed_out_snapshot_shell_is_terminated' panicked at codex-rs/core/src/shell_snapshot.rs:588:9: expected timeout error, got Failed to execute sh Caused by: Text file busy (os error 26) failures: shell_snapshot::tests::timed_out_snapshot_shell_is_terminated test result: FAILED. 815 passed; 1 failed; 4 ignored; 0 measured; 0 filtered out; finished in 18.00s ``` --- codex-rs/core/src/shell_snapshot.rs | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/codex-rs/core/src/shell_snapshot.rs b/codex-rs/core/src/shell_snapshot.rs index b578c4232..78581186c 100644 --- a/codex-rs/core/src/shell_snapshot.rs +++ b/codex-rs/core/src/shell_snapshot.rs @@ -464,8 +464,6 @@ mod tests { use pretty_assertions::assert_eq; #[cfg(unix)] use std::os::unix::ffi::OsStrExt; - #[cfg(target_os = "linux")] - use std::os::unix::fs::PermissionsExt; #[cfg(unix)] use std::process::Command; #[cfg(target_os = "linux")] @@ -562,27 +560,16 @@ mod tests { use tokio::time::sleep; let dir = tempdir()?; - let shell_path = dir.path().join("hanging-shell.sh"); let pid_path = dir.path().join("pid"); - - let script = format!( - "#!/bin/sh\n\ - echo $$ > {}\n\ - sleep 30\n", - pid_path.display() - ); - fs::write(&shell_path, script).await?; - let mut permissions = std::fs::metadata(&shell_path)?.permissions(); - permissions.set_mode(0o755); - std::fs::set_permissions(&shell_path, permissions)?; + let script = format!("echo $$ > \"{}\"; sleep 30", pid_path.display()); let shell = Shell { shell_type: ShellType::Sh, - shell_path, + shell_path: PathBuf::from("/bin/sh"), shell_snapshot: crate::shell::empty_shell_snapshot_receiver(), }; - let err = run_script_with_timeout(&shell, "ignored", Duration::from_millis(500), true) + let err = run_script_with_timeout(&shell, &script, Duration::from_secs(1), true) .await .expect_err("snapshot shell should time out"); assert!(