mirror of
https://github.com/openai/codex.git
synced 2026-04-24 22:54:54 +00:00
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
```
This commit is contained in:
@@ -464,8 +464,6 @@ mod tests {
|
|||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::os::unix::ffi::OsStrExt;
|
use std::os::unix::ffi::OsStrExt;
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
use std::os::unix::fs::PermissionsExt;
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
@@ -562,27 +560,16 @@ mod tests {
|
|||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
|
|
||||||
let dir = tempdir()?;
|
let dir = tempdir()?;
|
||||||
let shell_path = dir.path().join("hanging-shell.sh");
|
|
||||||
let pid_path = dir.path().join("pid");
|
let pid_path = dir.path().join("pid");
|
||||||
|
let script = format!("echo $$ > \"{}\"; sleep 30", pid_path.display());
|
||||||
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 shell = Shell {
|
let shell = Shell {
|
||||||
shell_type: ShellType::Sh,
|
shell_type: ShellType::Sh,
|
||||||
shell_path,
|
shell_path: PathBuf::from("/bin/sh"),
|
||||||
shell_snapshot: crate::shell::empty_shell_snapshot_receiver(),
|
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
|
.await
|
||||||
.expect_err("snapshot shell should time out");
|
.expect_err("snapshot shell should time out");
|
||||||
assert!(
|
assert!(
|
||||||
|
|||||||
Reference in New Issue
Block a user