Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
fix: resolve analyze_trace test timeouts under nextest (#1933)
Maximilian Roos5cb9f954d419
diff --git a/Cargo.toml b/Cargo.tomlindex 9d657ac18..47a8882c8 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -1,7 +1,7 @@[workspace]members = ["tests/helpers/wt-perf", "tests/helpers/mock-stub"]-# Include mock-stub so `cargo test` builds its binary (via its integration test)-default-members = [".", "tests/helpers/mock-stub"]+# Include mock-stub and wt-perf so `cargo test` builds their binaries+default-members = [".", "tests/helpers/mock-stub", "tests/helpers/wt-perf"][package]name = "worktrunk"diff --git a/tests/common/mock_commands.rs b/tests/common/mock_commands.rsindex 6b0384449..79bdad10c 100644--- a/tests/common/mock_commands.rs+++ b/tests/common/mock_commands.rs@@ -20,17 +20,7 @@ use std::path::Path;/// Path to the mock-stub binary, built by `cargo test`.fn mock_stub_binary() -> std::path::PathBuf {- let mut path = std::env::current_exe().expect("failed to get test executable path");- path.pop(); // Remove test binary name- path.pop(); // Remove deps/-- #[cfg(windows)]- path.push("mock-stub.exe");-- #[cfg(not(windows))]- path.push("mock-stub");-- path+ super::workspace_bin("mock-stub")}/// Builder for mock command configuration.diff --git a/tests/common/mod.rs b/tests/common/mod.rsindex a67899f60..a3a21a763 100644--- a/tests/common/mod.rs+++ b/tests/common/mod.rs@@ -406,6 +406,25 @@ use std::process::Command;pub fn wt_bin() -> PathBuf {PathBuf::from(env!("CARGO_BIN_EXE_wt"))}++/// Path to a workspace member binary (e.g., `wt-perf`, `mock-stub`).+///+/// These are binaries from other workspace packages (not the main `wt` crate),+/// so `CARGO_BIN_EXE_<name>` isn't available. Derives the path from the test+/// executable's location in `target/debug/deps/`.+pub fn workspace_bin(name: &str) -> PathBuf {+ let mut path = std::env::current_exe().expect("failed to get test executable path");+ path.pop(); // Remove test binary name+ path.pop(); // Remove deps/++ #[cfg(windows)]+ path.push(format!("{name}.exe"));++ #[cfg(not(windows))]+ path.push(name);++ path+}use tempfile::TempDir;use worktrunk::config::sanitize_branch_name;use worktrunk::path::to_posix_path;diff --git a/tests/helpers/wt-perf/Cargo.toml b/tests/helpers/wt-perf/Cargo.tomlindex 0b45e9fb4..f20e3018f 100644--- a/tests/helpers/wt-perf/Cargo.toml+++ b/tests/helpers/wt-perf/Cargo.toml@@ -1,3 +1,7 @@+# HOW THE BINARY GETS BUILT:+# Has a dummy integration test (tests/builds.rs) that triggers binary compilation+# when running `cargo test`. Combined with `workspace.default-members` including+# this package, `cargo test` automatically builds the binary.[package]name = "wt-perf"version = "0.1.0"diff --git a/tests/helpers/wt-perf/tests/builds.rs b/tests/helpers/wt-perf/tests/builds.rsnew file mode 100644index 000000000..d2afa2199--- /dev/null+++ b/tests/helpers/wt-perf/tests/builds.rs@@ -0,0 +1,5 @@+//! Dummy test that triggers binary compilation.+//! See wt-perf/Cargo.toml and mock-stub/Cargo.toml for why this is needed.++#[test]+fn builds() {}diff --git a/tests/integration_tests/analyze_trace.rs b/tests/integration_tests/analyze_trace.rsindex 36ab5c083..2bbfb30b3 100644--- a/tests/integration_tests/analyze_trace.rs+++ b/tests/integration_tests/analyze_trace.rs@@ -3,17 +3,10 @@use std::io::Write;use std::process::{Command, Stdio};-fn wt_perf_bin() -> std::path::PathBuf {- // Build and get path to wt-perf binary- let output = Command::new("cargo")- .args(["build", "-p", "wt-perf"])- .output()- .expect("Failed to build wt-perf");- assert!(output.status.success(), "Failed to build wt-perf");+use crate::common::workspace_bin;- std::env::current_dir()- .unwrap()- .join("target/debug/wt-perf")+fn wt_perf_bin() -> std::path::PathBuf {+ workspace_bin("wt-perf")}/// Test that the binary produces Chrome Trace Format JSON for sample trace input.