Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

test: fail the re-exec'd signal tests when the child runs no test (#4426)

Worktrunk Bote1679713fafe
diff --git a/src/commands/custom.rs b/src/commands/custom.rs
index d7410de3e..0c4c26ea8 100644
--- a/src/commands/custom.rs
+++ b/src/commands/custom.rs
@@ -310,14 +310,17 @@ mod tests {
"--exact",
"commands::custom::tests::run_custom_propagates_signal_exit_code",
])
- .env(CHILD_ENV, "1");
- assert!(
- worktrunk::shell_exec::spawn(&mut command)
- .unwrap()
- .wait()
- .unwrap()
- .success()
- );
+ .env(CHILD_ENV, "1")
+ .stdout(std::process::Stdio::piped());
+ let output = worktrunk::shell_exec::spawn(&mut command)
+ .unwrap()
+ .wait_with_output()
+ .unwrap();
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ assert!(output.status.success(), "{stdout}");
+ // `--exact` matching nothing also exits 0; require that the child
+ // actually ran this test.
+ assert!(stdout.contains(" 1 passed;"), "{stdout}");
return;
}
diff --git a/src/signal_forwarder.rs b/src/signal_forwarder.rs
index ab4cee181..37a231583 100644
--- a/src/signal_forwarder.rs
+++ b/src/signal_forwarder.rs
@@ -525,14 +525,16 @@ mod tests {
command.args([
"--exact",
"signal_forwarder::tests::operation_cancellation_survives_scope_retirement_and_resets",
- ]).env(CHILD_ENV, "1");
- assert!(
- crate::shell_exec::spawn(&mut command)
- .unwrap()
- .wait()
- .unwrap()
- .success()
- );
+ ]).env(CHILD_ENV, "1").stdout(std::process::Stdio::piped());
+ let output = crate::shell_exec::spawn(&mut command)
+ .unwrap()
+ .wait_with_output()
+ .unwrap();
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ assert!(output.status.success(), "{stdout}");
+ // `--exact` matching nothing also exits 0; require that the child
+ // actually ran this test.
+ assert!(stdout.contains(" 1 passed;"), "{stdout}");
return;
}