Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
fix(ci): use compile-time binary path for nextest compatibility (#884)
worktrunk-bot4bfe85403c6c
diff --git a/tests/common/mod.rs b/tests/common/mod.rsindex 860365549..ba570769c 100644--- a/tests/common/mod.rs+++ b/tests/common/mod.rs@@ -394,10 +394,18 @@ pub fn open_pty_with_size(rows: u16, cols: u16) -> portable_pty::PtyPair {.unwrap()}-use insta_cmd::get_cargo_bin;use std::collections::HashMap;use std::path::{Path, PathBuf};use std::process::Command;++/// Path to the `wt` binary built by Cargo.+///+/// Uses `env!()` (compile-time) rather than runtime lookup so Cargo knows to+/// build the binary when compiling tests. This works with both `cargo test`+/// and `cargo nextest`.+pub fn wt_bin() -> PathBuf {+ PathBuf::from(env!("CARGO_BIN_EXE_wt"))+}use tempfile::TempDir;use worktrunk::config::sanitize_branch_name;use worktrunk::path::to_posix_path;@@ -599,7 +607,7 @@ const NULL_DEVICE: &str = "/dev/null";/// - Terminal width set to 150 columns (`COLUMNS=150`)#[must_use]pub fn wt_command() -> Command {- let mut cmd = Command::new(get_cargo_bin("wt"));+ let mut cmd = Command::new(wt_bin());configure_cli_command(&mut cmd);cmd}@@ -1310,7 +1318,7 @@ impl TestRepo {/// ```#[must_use]pub fn wt_command(&self) -> Command {- let mut cmd = Command::new(get_cargo_bin("wt"));+ let mut cmd = Command::new(wt_bin());self.configure_wt_cmd(&mut cmd);cmd.current_dir(self.root_path());cmd@@ -2875,7 +2883,7 @@ pub fn make_snapshot_cmd_with_global_flags(cwd: Option<&Path>,global_flags: &[&str],) -> Command {- let mut cmd = Command::new(insta_cmd::get_cargo_bin("wt"));+ let mut cmd = Command::new(wt_bin());repo.configure_wt_cmd(&mut cmd);cmd.args(global_flags).arg(subcommand)diff --git a/tests/common/progressive_output.rs b/tests/common/progressive_output.rsindex fea8c8985..9ed60a000 100644--- a/tests/common/progressive_output.rs+++ b/tests/common/progressive_output.rs@@ -98,8 +98,7 @@//! - `with_byte_interval(n)` - Capture every n bytes (deterministic)//! - `default()` - Time-based capture every 50ms (less deterministic)-use crate::common::{ExponentialBackoff, TestRepo};-use insta_cmd::get_cargo_bin;+use crate::common::{ExponentialBackoff, TestRepo, wt_bin};use portable_pty::CommandBuilder;use std::io::Read;use std::time::{Duration, Instant};@@ -334,7 +333,7 @@ pub fn capture_progressive_output(let pair = super::open_pty_with_size(options.terminal_size.0, options.terminal_size.1);// Build command- let mut cmd = CommandBuilder::new(get_cargo_bin("wt"));+ let mut cmd = CommandBuilder::new(wt_bin());cmd.arg(subcommand);for arg in args {cmd.arg(arg);diff --git a/tests/common/shell.rs b/tests/common/shell.rsindex eb18a236d..f8996b16a 100644--- a/tests/common/shell.rs+++ b/tests/common/shell.rs@@ -1,5 +1,4 @@-use super::{TestRepo, wt_command};-use insta_cmd::get_cargo_bin;+use super::{TestRepo, wt_bin, wt_command};/// Map shell display names to actual binaries.pub fn get_shell_binary(shell: &str) -> &str {@@ -178,9 +177,5 @@ pub fn path_export_syntax(shell: &str, bin_path: &str) -> String {/// Helper that returns the `wt` binary directory for PATH injection.pub fn wt_bin_dir() -> String {- get_cargo_bin("wt")- .parent()- .unwrap()- .to_string_lossy()- .to_string()+ wt_bin().parent().unwrap().to_string_lossy().to_string()}diff --git a/tests/integration_tests/approval_pty.rs b/tests/integration_tests/approval_pty.rsindex 06ba77f8a..5307cc0df 100644--- a/tests/integration_tests/approval_pty.rs+++ b/tests/integration_tests/approval_pty.rs@@ -9,9 +9,8 @@//! error case (non-TTY environments).use crate::common::pty::exec_in_pty;-use crate::common::{TestRepo, add_pty_binary_path_filters, add_pty_filters, repo};+use crate::common::{TestRepo, add_pty_binary_path_filters, add_pty_filters, repo, wt_bin};use insta::assert_snapshot;-use insta_cmd::get_cargo_bin;use rstest::rstest;/// Execute wt in a PTY with interactive input.@@ -24,7 +23,7 @@ fn exec_wt_in_pty(input: &str,) -> (String, i32) {exec_in_pty(- get_cargo_bin("wt").to_str().unwrap(),+ wt_bin().to_str().unwrap(),args,repo.root_path(),env_vars,diff --git a/tests/integration_tests/configure_shell.rs b/tests/integration_tests/configure_shell.rsindex 75764fe1a..12fdbe207 100644--- a/tests/integration_tests/configure_shell.rs+++ b/tests/integration_tests/configure_shell.rs@@ -1534,9 +1534,10 @@ fn test_uninstall_shell_dry_run_multiple(repo: TestRepo, temp_home: TempDir) {#[cfg(all(unix, feature = "shell-integration-tests"))]mod pty_tests {use crate::common::pty::exec_cmd_in_pty;- use crate::common::{TestRepo, add_pty_filters, configure_pty_command, repo, temp_home};+ use crate::common::{+ TestRepo, add_pty_filters, configure_pty_command, repo, temp_home, wt_bin,+ };use insta::assert_snapshot;- use insta_cmd::get_cargo_bin;use portable_pty::CommandBuilder;use rstest::rstest;use std::fs;@@ -1544,7 +1545,7 @@ mod pty_tests {/// Execute shell install command in a PTY with interactive inputfn exec_install_in_pty(temp_home: &TempDir, repo: &TestRepo, input: &str) -> (String, i32) {- let mut cmd = CommandBuilder::new(get_cargo_bin("wt"));+ let mut cmd = CommandBuilder::new(wt_bin());cmd.arg("-C");cmd.arg(repo.root_path());cmd.arg("config");diff --git a/tests/integration_tests/git_error_display.rs b/tests/integration_tests/git_error_display.rsindex 7d405caea..8d61baac7 100644--- a/tests/integration_tests/git_error_display.rs+++ b/tests/integration_tests/git_error_display.rs@@ -400,10 +400,10 @@ fn multiline_error_crlf_normalization() {#[test]#[cfg(unix)]fn git_unavailable_error_includes_command() {- use insta_cmd::get_cargo_bin;+ use crate::common::wt_bin;use std::process::Command;- let mut cmd = Command::new(get_cargo_bin("wt"));+ let mut cmd = Command::new(wt_bin());cmd.arg("list")// Set PATH to empty so git isn't found.env("PATH", "/nonexistent")diff --git a/tests/integration_tests/select.rs b/tests/integration_tests/select.rsindex a6143b381..cffdfa017 100644--- a/tests/integration_tests/select.rs+++ b/tests/integration_tests/select.rs@@ -19,9 +19,8 @@//! - **Stabilization detection** waits for screen to stop changing//! - **Content expectations** wait for async preview content to load (e.g., "diff --git")-use crate::common::{TestRepo, repo};+use crate::common::{TestRepo, repo, wt_bin};use insta::assert_snapshot;-use insta_cmd::get_cargo_bin;use portable_pty::CommandBuilder;use rstest::rstest;use std::io::{Read, Write};@@ -336,7 +335,7 @@ fn test_select_abort_with_escape(mut repo: TestRepo) {let env_vars = repo.test_env_vars();let (raw_output, exit_code) = exec_in_pty_with_input(- get_cargo_bin("wt").to_str().unwrap(),+ wt_bin().to_str().unwrap(),&["select"],repo.root_path(),&env_vars,@@ -361,7 +360,7 @@ fn test_select_with_multiple_worktrees(mut repo: TestRepo) {let env_vars = repo.test_env_vars();let (raw_output, exit_code) = exec_in_pty_with_input(- get_cargo_bin("wt").to_str().unwrap(),+ wt_bin().to_str().unwrap(),&["select"],repo.root_path(),&env_vars,@@ -392,7 +391,7 @@ fn test_select_with_branches(mut repo: TestRepo) {let env_vars = repo.test_env_vars();let (raw_output, exit_code) = exec_in_pty_with_input(- get_cargo_bin("wt").to_str().unwrap(),+ wt_bin().to_str().unwrap(),&["select", "--branches"],repo.root_path(),&env_vars,@@ -446,7 +445,7 @@ fn test_select_preview_panel_uncommitted(mut repo: TestRepo) {// Type "feature" to filter to just the feature worktree, press 1 for HEAD± panel// Wait for "diff --git" to appear after pressing 1 - the async preview can be slow under congestionlet (raw_output, exit_code) = exec_in_pty_with_input_expectations(- get_cargo_bin("wt").to_str().unwrap(),+ wt_bin().to_str().unwrap(),&["select"],repo.root_path(),&env_vars,@@ -503,7 +502,7 @@ fn test_select_preview_panel_log(mut repo: TestRepo) {// Type "feature" to filter, press 2 for log panel// Wait for commit log format "* [hash]" to appear - the async preview can be slow under congestionlet (raw_output, exit_code) = exec_in_pty_with_input_expectations(- get_cargo_bin("wt").to_str().unwrap(),+ wt_bin().to_str().unwrap(),&["select"],repo.root_path(),&env_vars,@@ -593,7 +592,7 @@ fn test_new_feature() {// Type "feature" to filter, press 3 for main…± panel// Wait for "diff --git" to appear after pressing 3 - the async preview can be slow under congestionlet (raw_output, exit_code) = exec_in_pty_with_input_expectations(- get_cargo_bin("wt").to_str().unwrap(),+ wt_bin().to_str().unwrap(),&["select"],repo.root_path(),&env_vars,@@ -633,7 +632,7 @@ branches = truelet env_vars = repo.test_env_vars();let (raw_output, exit_code) = exec_in_pty_with_input(- get_cargo_bin("wt").to_str().unwrap(),+ wt_bin().to_str().unwrap(),&["select"], // No --branches flag - config should enable itrepo.root_path(),&env_vars,diff --git a/tests/integration_tests/shell_integration_prompt.rs b/tests/integration_tests/shell_integration_prompt.rsindex f3a5618fe..50bb5ac47 100644--- a/tests/integration_tests/shell_integration_prompt.rs+++ b/tests/integration_tests/shell_integration_prompt.rs@@ -204,9 +204,8 @@ fn test_switch_no_shell_env_shows_hint(repo: TestRepo) {mod pty_tests {use super::*;use crate::common::pty::exec_in_pty_with_home;- use crate::common::{add_pty_filters, setup_snapshot_settings};+ use crate::common::{add_pty_filters, setup_snapshot_settings, wt_bin};use insta::assert_snapshot;- use insta_cmd::get_cargo_bin;use std::path::Path;use tempfile::TempDir;@@ -252,7 +251,7 @@ mod pty_tests {env_vars.push(("SHELL".to_string(), "/bin/bash".to_string()));let (output, exit_code) = exec_in_pty_with_home(- get_cargo_bin("wt").to_str().unwrap(),+ wt_bin().to_str().unwrap(),&["switch", "--create", "feature"],repo.root_path(),&env_vars,@@ -297,7 +296,7 @@ mod pty_tests {env_vars.push(("SHELL".to_string(), "/bin/bash".to_string()));let (output, exit_code) = exec_in_pty_with_home(- get_cargo_bin("wt").to_str().unwrap(),+ wt_bin().to_str().unwrap(),&["switch", "--create", "feature"],repo.root_path(),&env_vars,@@ -353,7 +352,7 @@ mod pty_tests {env_vars.push(("SHELL".to_string(), "/bin/bash".to_string()));let (output, exit_code) = exec_in_pty_with_home(- get_cargo_bin("wt").to_str().unwrap(),+ wt_bin().to_str().unwrap(),&["switch", "--create", "feature"],repo.root_path(),&env_vars,@@ -410,7 +409,7 @@ mod pty_tests {env_vars.push(("SHELL".to_string(), "/bin/bash".to_string()));let (output, exit_code) = exec_in_pty_with_home(- get_cargo_bin("wt").to_str().unwrap(),+ wt_bin().to_str().unwrap(),&["switch", "--create", "feature"],repo.root_path(),&env_vars,@@ -466,7 +465,7 @@ mod pty_tests {// First switch - decline the promptlet (_, _) = exec_in_pty_with_home(- get_cargo_bin("wt").to_str().unwrap(),+ wt_bin().to_str().unwrap(),&["switch", "--create", "feature1"],repo.root_path(),&env_vars,@@ -476,7 +475,7 @@ mod pty_tests {// Second switch - should NOT prompt againlet (output, exit_code) = exec_in_pty_with_home(- get_cargo_bin("wt").to_str().unwrap(),+ wt_bin().to_str().unwrap(),&["switch", "--create", "feature2"],repo.root_path(),&env_vars,@@ -498,7 +497,7 @@ mod pty_tests {mod commit_generation_prompt_tests {use super::*;use crate::common::pty::exec_in_pty_with_home;- use insta_cmd::get_cargo_bin;+ use crate::common::wt_bin;use std::os::unix::fs::PermissionsExt;use std::path::{Path, PathBuf};use tempfile::TempDir;@@ -531,7 +530,7 @@ mod commit_generation_prompt_tests {env_vars.push(("PATH".to_string(), "/usr/bin:/bin".to_string()));let (output, exit_code) = exec_in_pty_with_home(- get_cargo_bin("wt").to_str().unwrap(),+ wt_bin().to_str().unwrap(),&["step", "commit"],repo.root_path(),&env_vars,@@ -567,7 +566,7 @@ mod commit_generation_prompt_tests {env_vars.push(("PATH".to_string(), path));let (output, exit_code) = exec_in_pty_with_home(- get_cargo_bin("wt").to_str().unwrap(),+ wt_bin().to_str().unwrap(),&["step", "commit"],repo.root_path(),&env_vars,@@ -607,7 +606,7 @@ mod commit_generation_prompt_tests {env_vars.push(("PATH".to_string(), path));let (output, _exit_code) = exec_in_pty_with_home(- get_cargo_bin("wt").to_str().unwrap(),+ wt_bin().to_str().unwrap(),&["step", "commit"],repo.root_path(),&env_vars,@@ -648,7 +647,7 @@ mod commit_generation_prompt_tests {env_vars.push(("PATH".to_string(), path));let (output, exit_code) = exec_in_pty_with_home(- get_cargo_bin("wt").to_str().unwrap(),+ wt_bin().to_str().unwrap(),&["step", "commit"],repo.root_path(),&env_vars,diff --git a/tests/integration_tests/shell_wrapper.rs b/tests/integration_tests/shell_wrapper.rsindex 1301486c4..34f24a476 100644--- a/tests/integration_tests/shell_wrapper.rs+++ b/tests/integration_tests/shell_wrapper.rs@@ -31,8 +31,7 @@// =============================================================================// Shared imports (both platforms)-use crate::common::{TestRepo, shell::get_shell_binary};-use insta_cmd::get_cargo_bin;+use crate::common::{TestRepo, shell::get_shell_binary, wt_bin};use std::process::Command;// Unix-only imports@@ -112,7 +111,7 @@ fn shell_wrapper_settings() -> insta::Settings {/// Generate a shell wrapper script using the actual `wt config shell init` commandfn generate_wrapper(repo: &TestRepo, shell: &str) -> String {- let wt_bin = get_cargo_bin("wt");+ let wt_bin = wt_bin();let mut cmd = Command::new(&wt_bin);cmd.arg("config").arg("shell").arg("init").arg(shell);@@ -185,7 +184,7 @@ fn powershell_quote(s: &str) -> String {/// Build a shell script that sources the wrapper and runs a commandfn build_shell_script(shell: &str, repo: &TestRepo, subcommand: &str, args: &[&str]) -> String {- let wt_bin = get_cargo_bin("wt");+ let wt_bin = wt_bin();let wrapper_script = generate_wrapper(repo, shell);let mut script = String::new();@@ -1535,7 +1534,7 @@ approved-commands = ["echo 'fish background task'"]let worktrunk_source = canonicalize(&env::current_dir().unwrap()).unwrap();// Build a shell script that runs from the worktrunk source directory- let wt_bin = get_cargo_bin("wt");+ let wt_bin = wt_bin();let wrapper_script = generate_wrapper(&repo, shell);let mut script = String::new();@@ -1710,7 +1709,7 @@ approved-commands = ["echo 'bash background'"].unwrap();// Build the setup script that defines the wt function- let wt_bin = get_cargo_bin("wt");+ let wt_bin = wt_bin();let wrapper_script = generate_wrapper(&repo, "bash");let wt_bin_quoted = shell_quote(&wt_bin.display().to_string());let config_quoted = shell_quote(&repo.test_config_path().display().to_string());@@ -1769,7 +1768,7 @@ approved-commands = ["echo 'bash background'"]/// Note: Completions are inline in the wrapper script (lazy loading)#[rstest]fn test_bash_completions_registered(repo: TestRepo) {- let wt_bin = get_cargo_bin("wt");+ let wt_bin = wt_bin();let wrapper_script = generate_wrapper(&repo, "bash");// Script that sources wrapper and checks if completion is registered@@ -1806,7 +1805,7 @@ approved-commands = ["echo 'bash background'"]/// Test that fish completions are properly registered#[rstest]fn test_fish_completions_registered(repo: TestRepo) {- let wt_bin = get_cargo_bin("wt");+ let wt_bin = wt_bin();let wrapper_script = generate_wrapper(&repo, "fish");let completions_script = generate_completions(&repo, "fish");@@ -1849,7 +1848,7 @@ approved-commands = ["echo 'bash background'"]/// Note: Completions are inline in the wrapper script (lazy loading via compdef)#[rstest]fn test_zsh_wrapper_function_registered(repo: TestRepo) {- let wt_bin = get_cargo_bin("wt");+ let wt_bin = wt_bin();let wrapper_script = generate_wrapper(&repo, "zsh");// Use a marker file to avoid PTY output race conditions.@@ -1954,7 +1953,7 @@ approved-commands = ["echo 'bash background'"]#[case("zsh")]#[case("fish")]fn test_worktrunk_bin_fallback(#[case] shell: &str, repo: TestRepo) {- let wt_bin = get_cargo_bin("wt");+ let wt_bin = wt_bin();let wrapper_script = generate_wrapper(&repo, shell);// Use shell_quote to handle paths with special chars (like single quotes)@@ -2573,7 +2572,7 @@ test = "echo 'Running tests...'"let pair = crate::common::open_pty();- let cargo_bin = get_cargo_bin("wt");+ let cargo_bin = wt_bin();let mut cmd = CommandBuilder::new(cargo_bin);cmd.arg("switch");cmd.arg("--create");@@ -2669,7 +2668,7 @@ test = "echo 'Running tests...'"fn test_bash_completion_produces_correct_output(repo: TestRepo) {use std::io::Read;- let wt_bin = get_cargo_bin("wt");+ let wt_bin = wt_bin();let wt_bin_dir = wt_bin.parent().unwrap();// Generate wrapper without WORKTRUNK_BIN (simulates installed wt)@@ -2805,7 +2804,7 @@ fifn test_zsh_completion_produces_correct_output(repo: TestRepo) {use std::io::Read;- let wt_bin = get_cargo_bin("wt");+ let wt_bin = wt_bin();let wt_bin_dir = wt_bin.parent().unwrap();// Generate wrapper without WORKTRUNK_BIN (simulates installed wt)@@ -2919,7 +2918,7 @@ fi/// Sources actual `wt config shell init zsh`, triggers completion, snapshots result.#[test]fn test_zsh_completion_subcommands() {- let wt_bin = get_cargo_bin("wt");+ let wt_bin = wt_bin();let init = std::process::Command::new(&wt_bin).args(["config", "shell", "init", "zsh"]).output()@@ -2962,7 +2961,7 @@ _wt_lazy_complete/// Sources actual `wt config shell init bash`, triggers completion, snapshots result.#[test]fn test_bash_completion_subcommands() {- let wt_bin = get_cargo_bin("wt");+ let wt_bin = wt_bin();let init = std::process::Command::new(&wt_bin).args(["config", "shell", "init", "bash"]).output()@@ -3000,7 +2999,7 @@ for c in "${{COMPREPLY[@]}}"; do echo "${{c%% *}}"; done/// Fish completions call binary with COMPLETE=fish (separate from init script).#[test]fn test_fish_completion_subcommands() {- let wt_bin = get_cargo_bin("wt");+ let wt_bin = wt_bin();let output = std::process::Command::new(&wt_bin).args(["--", "wt", ""])@@ -3043,7 +3042,7 @@ for c in "${{COMPREPLY[@]}}"; do echo "${{c%% *}}"; donefn test_wrapper_help_redirect_captures_all_output(#[case] shell: &str, repo: TestRepo) {use std::io::Read;- let wt_bin = get_cargo_bin("wt");+ let wt_bin = wt_bin();let wt_bin_dir = wt_bin.parent().unwrap();// Create a temp file for the redirect target@@ -3193,7 +3192,7 @@ echo "SCRIPT_COMPLETED"fn test_wrapper_help_interactive_uses_pager(#[case] shell: &str, repo: TestRepo) {use std::io::Read;- let wt_bin = get_cargo_bin("wt");+ let wt_bin = wt_bin();let wt_bin_dir = wt_bin.parent().unwrap();// Create temp dir for marker file and pager script@@ -3407,9 +3406,9 @@ mod windows_tests {#[test]fn test_conpty_wt_version() {use crate::common::pty::exec_in_pty;- use insta_cmd::get_cargo_bin;+ use crate::common::wt_bin;- let wt_bin = get_cargo_bin("wt");+ let wt_bin = wt_bin();let tmp = tempfile::tempdir().unwrap();let (output, exit_code) = exec_in_pty(@@ -3631,7 +3630,7 @@ mod windows_tests {#[ignore = "ConPTY output not captured when cargo test redirects stdout"]fn test_powershell_wrapper_function_registered(repo: TestRepo) {// Test that the wrapper function is defined by checking if it exists- let wt_bin = get_cargo_bin("wt");+ let wt_bin = wt_bin();let wrapper_script = generate_wrapper(&repo, "powershell");// Build a script that sources the wrapper and checks if wt is a function@@ -3674,7 +3673,7 @@ mod windows_tests {#[rstest]#[ignore = "ConPTY output not captured when cargo test redirects stdout"]fn test_powershell_completion_registered(repo: TestRepo) {- let wt_bin = get_cargo_bin("wt");+ let wt_bin = wt_bin();let wrapper_script = generate_wrapper(&repo, "powershell");// Build a script that sources the wrapper and checks for completion@@ -3760,7 +3759,7 @@ mod windows_tests {#[ignore = "ConPTY output not captured when cargo test redirects stdout"]fn test_powershell_worktrunk_bin_env(repo: TestRepo) {// This tests the fix we just made - WORKTRUNK_BIN should be used- let wt_bin = get_cargo_bin("wt");+ let wt_bin = wt_bin();let wrapper_script = generate_wrapper(&repo, "powershell");// Script that prints which binary would be used