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
18 changes: 14 additions & 4 deletions crates/agent-gui/src-tauri/src/runtime/shell_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,24 +1018,34 @@ mod tests {
let started = Instant::now();
let result = run_shell_script(
temp_dir.display().to_string(),
"sleep 5 & echo ready".to_string(),
"sleep 15 & background_pid=$!; echo ready:$background_pid".to_string(),
None,
Some(60_000),
None,
None,
None,
)
.expect("shell run should return a response");
let elapsed = started.elapsed();
let background_pid = result
.stdout
.lines()
.find_map(|line| line.strip_prefix("ready:"))
.expect("shell should report the background process id")
.trim();
let _ = std::process::Command::new("kill")
.arg(background_pid)
.status();

let _ = fs::remove_dir_all(&temp_dir);

assert_eq!(result.exit_code, 0);
assert!(result.stdio_open_after_exit);
assert!(result.stdout.contains("ready"));
assert!(result.stdout.contains("ready:"));
assert!(result.stderr.contains("stdout/stderr remained open"));
assert!(
started.elapsed() < Duration::from_secs(3),
"background stdio leak should not block until the background process exits"
elapsed < Duration::from_secs(10),
"background stdio leak should not block until the background process exits; elapsed: {elapsed:?}"
);
}

Expand Down
Loading