Watch
0
0
Fork
You've already forked hyperhive
0

write the remaining test fake executables from a child process

This commit is contained in:
atlas 2026-10-28 12:49:30 +01:00
commit d452da09ae

View file

@ -64,6 +64,24 @@ mod tests {
sleep 30 >/dev/null 2>&1 &\n\
wait\n";
/// Write the script `body` to `path` as an executable, from a child process
/// rather than from this one: a write fd on it held here could be inherited
/// by a child another test thread forks, and exec'ing a file some process
/// still holds open for writing fails with `ETXTBSY`.
fn write_executable(path: &Path, body: &str) {
let status = std::process::Command::new("/bin/sh")
.args([
"-c",
r#"printf '%s' "$1" > "$2" && chmod 755 "$2""#,
"sh",
body,
])
.arg(path)
.status()
.expect("run /bin/sh");
assert!(status.success(), "writing {} failed", path.display());
}
async fn exists(path: &Path) {
for _ in 0..250 {
if path.exists() {
@ -76,12 +94,9 @@ mod tests {
#[tokio::test]
async fn a_claude_stop_is_a_sigint_to_the_process() {
use std::os::unix::fs::PermissionsExt as _;
let dir = tempfile::tempdir().unwrap();
let program = dir.path().join("fake-claude");
std::fs::write(&program, FAKE_CLAUDE).unwrap();
std::fs::set_permissions(&program, std::fs::Permissions::from_mode(0o755)).unwrap();
write_executable(&program, FAKE_CLAUDE);
let (ready, mark) = (dir.path().join("ready"), dir.path().join("int"));
let config = Config {
program: Some(program),