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
16 changes: 15 additions & 1 deletion tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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));
Expand Down
Loading