Skip to content

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

test(testing): panic with the fix when mock-stub binary is absent (#2744)

Maximilian Roose637cf011460
diff --git a/CLAUDE.md b/CLAUDE.md
index 7aca227e7..f77dd034a 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -67,6 +67,8 @@ cargo test --test integration # integration tests (no shell tests)
cargo test --test integration --features shell-integration-tests # with shell tests
```
+A filtered `--test integration` run on a fresh `target/` panics with "mock-stub binary not found" — a target filter skips the helper-bin build. Fix: `cargo build -p mock-stub`, or use `cargo nextest run` / `cargo llvm-cov nextest`.
+
### Claude Code Web Environment
Run `task setup-web` to install required shells (zsh, fish, nushell), `gh`, and other dev tools. Install `task` first if needed:
diff --git a/src/testing/mock_commands.rs b/src/testing/mock_commands.rs
index 79bdad10c..581e37db7 100644
--- a/src/testing/mock_commands.rs
+++ b/src/testing/mock_commands.rs
@@ -18,9 +18,42 @@ use std::collections::HashMap;
use std::fs;
use std::path::Path;
-/// Path to the mock-stub binary, built by `cargo test`.
+/// Path to the mock-stub binary.
+///
+/// `workspace.default-members` builds it under an unfiltered `cargo test` /
+/// `cargo nextest run`, and `.config/nextest.toml`'s setup-script builds it
+/// under filtered nextest (including `cargo llvm-cov nextest`). A bare
+/// `cargo test --test integration` builds neither path — a target filter
+/// overrides `default-members`, and `cargo test` ignores nextest setup-scripts
+/// — so the binary is absent on a clean `target/`, and always absent under
+/// `cargo llvm-cov --test integration` since cargo-llvm-cov uses its own
+/// target dir. Asserting here surfaces the fix; the alternative is an opaque
+/// failure later inside a mock spawn (ENOENT on a dangling symlink, or a
+/// silently-dropped CI indicator when `tool_available("tea")` returns false).
+///
+/// Folding the helper bins back into the worktrunk crate would let
+/// `cargo test --test integration` build them automatically and delete this
+/// whole layer — it's blocked on cargo-dist; see `.config/nextest.toml` and
+/// `tests/helpers/mock-stub/Cargo.toml`.
fn mock_stub_binary() -> std::path::PathBuf {
- super::workspace_bin("mock-stub")
+ let path = super::workspace_bin("mock-stub");
+ assert_mock_stub_present(&path);
+ path
+}
+
+/// Panic with build instructions if `path` (the resolved mock-stub location)
+/// doesn't exist. Split out so a unit test can drive the missing-binary arm
+/// without depending on whether the real binary happens to be built.
+fn assert_mock_stub_present(path: &Path) {
+ assert!(
+ path.exists(),
+ "mock-stub binary not found at {}\n\n\
+ Build it once with `cargo build -p mock-stub`, or use a runner that builds\n\
+ the test helper bins:\n\
+ \n cargo nextest run --features shell-integration-tests --test integration ...\
+ \n cargo llvm-cov nextest --features shell-integration-tests --test integration ...\n",
+ path.display(),
+ );
}
/// Builder for mock command configuration.
@@ -389,4 +422,10 @@ mod tests {
#[cfg(windows)]
assert!(bin_dir.join("test-cmd.exe").exists());
}
+
+ #[test]
+ #[should_panic(expected = "mock-stub binary not found at")]
+ fn assert_mock_stub_present_panics_when_absent() {
+ assert_mock_stub_present(Path::new("/nonexistent/mock-stub"));
+ }
}