From 9eef0aefab5a577add47574a1ead20ee1e9c739b Mon Sep 17 00:00:00 2001 From: barath-dev Date: Mon, 23 Nov 2026 15:50:10 +0530 Subject: [PATCH] Tests: start a just-copied program again while Linux says it is busy codex_sessions_beside_claude_code copies the fake program into place as codex and starts it at once. On Linux a process another test starts during the copy holds the new file open for writing until it runs its own program, and starting the copy then fails with "Text file busy". It did on Ubuntu CI after #6 was merged. The test now tries again for up to two seconds while the file is busy. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013DS9XhJVN73JGnZEqrX89o --- tests/e2e.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/e2e.rs b/tests/e2e.rs index 108fbe5..a199936 100644 --- a/tests/e2e.rs +++ b/tests/e2e.rs @@ -21,6 +21,20 @@ fn now_ms() -> i64 { SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis() as i64 } +/// Start a program that was copied into place a moment ago. On Linux, a process +/// another test starts during the copy holds the new file open for writing until +/// it runs its own program, and until then starting this one fails with "Text file +/// busy". That passes in moments, so try again for a while. +fn spawn_copied(cmd: &mut Command) -> Child { + let deadline = Instant::now() + Duration::from_secs(2); + loop { + match cmd.spawn() { + Err(e) if e.kind() == std::io::ErrorKind::ExecutableFileBusy && Instant::now() < deadline => thread::sleep(Duration::from_millis(20)), + other => return other.unwrap(), + } + } +} + /// A process that plays a running Claude session; ended when dropped. /// /// A background thread waits on it, the way a shell does for a real session, @@ -518,7 +532,7 @@ fn codex_sessions_beside_claude_code() { if cfg!(unix) { let program = m.root.join("bin").join("codex"); fs::copy(FAKE_CLAUDE, &program).unwrap(); - let mut holder = Command::new(&program).arg("hold").arg(&rollout).current_dir(&project).stdin(Stdio::null()).spawn().unwrap(); + let mut holder = spawn_copied(Command::new(&program).arg("hold").arg(&rollout).current_dir(&project).stdin(Stdio::null())); let pid = holder.id(); // Waited on as a shell would, so once it exits it is gone rather than left a zombie. let ended = Arc::new(AtomicBool::new(false));