Skip to content

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

refactor(tests): consolidate PTY normalization using insta filters (#669)

Maximilian Roosb89531a4b9bd
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index 2dcd2ad18..b4df2e8ab 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -2331,6 +2331,90 @@ pub fn setup_temp_snapshot_settings(temp_path: &std::path::Path) -> insta::Setti
settings
}
+// =============================================================================
+// PTY Test Filters
+// =============================================================================
+//
+// PTY-based tests (shell wrappers, approval prompts, TUI select) capture output
+// from pseudo-terminals. This output has platform-specific artifacts that need
+// normalization for stable snapshots.
+//
+// These filters consolidate patterns that were previously scattered across
+// individual `normalize_*` functions in each test file. Using insta filters
+// instead of custom normalization functions:
+// - Reduces code duplication
+// - Ensures consistent normalization across all PTY tests
+// - Makes it easier to add new normalizations in one place
+//
+// Usage:
+// let mut settings = insta::Settings::clone_current();
+// add_pty_filters(&mut settings);
+// settings.bind(|| {
+// assert_snapshot!(output);
+// });
+
+/// Add filters for PTY-specific artifacts that vary between platforms.
+///
+/// This handles:
+/// - CRLF line endings (PTYs use \r\n)
+/// - macOS PTY control sequences (^D followed by backspaces)
+/// - Leading ANSI reset codes that vary between macOS and Linux
+pub fn add_pty_filters(settings: &mut insta::Settings) {
+ // PTYs use \r\n line endings, normalize to \n
+ settings.add_filter(r"\r\n", "\n");
+
+ // macOS PTYs emit ^D (literal caret-D) followed by backspaces (0x08)
+ // when EOF is signaled. Linux PTYs don't. Strip these for consistency.
+ settings.add_filter(r"\^D\x08+", "");
+
+ // Remove redundant leading reset codes per line.
+ // macOS and Linux PTYs generate ANSI codes slightly differently.
+ // This handles lines that start with ESC[0m (reset).
+ settings.add_filter(r"(?m)^\x1b\[0m", "");
+}
+
+/// Add filters for temporary directory paths in PTY output.
+///
+/// PTY tests create temp directories that appear in output. These paths vary
+/// per test run and need normalization.
+///
+/// # Arguments
+/// * `settings` - The insta Settings to add filters to
+/// * `placeholder` - The placeholder text to use (e.g., "[TMPDIR]", "_REPO_")
+pub fn add_pty_tmpdir_filters(settings: &mut insta::Settings, placeholder: &str) {
+ // macOS temp paths: /private/var/folders/.../T/.tmpXXX or /var/folders/.../T/.tmpXXX
+ settings.add_filter(
+ r"(?:/private)?/var/folders/[^/]+/[^/]+/T/\.tmp[^\s/'\x1b\)]+",
+ placeholder,
+ );
+
+ // Linux temp paths: /tmp/.tmpXXX
+ settings.add_filter(r"/tmp/\.tmp[^\s/'\x1b\)]+", placeholder);
+
+ // Fish shell temp paths: /tmp/.psubXXX (process substitution)
+ settings.add_filter(r"/tmp/\.psub[^\s/'\x1b\)]+", placeholder);
+
+ // Collapse duplicate placeholders that can appear with nested mktemp paths.
+ // e.g., [TMPDIR]/[TMPDIR]/foo -> [TMPDIR]/foo
+ let collapse_pattern = format!(
+ r"\[{0}](?:/?\[{0}])+",
+ regex::escape(placeholder.trim_matches(|c| c == '[' || c == ']'))
+ );
+ settings.add_filter(&collapse_pattern, placeholder);
+}
+
+/// Add filters for binary paths (target/debug/wt) in PTY output.
+///
+/// Test binaries are run from the cargo target directory, which varies.
+pub fn add_pty_binary_path_filters(settings: &mut insta::Settings) {
+ // Match paths ending in target/debug/wt or target/release/wt
+ // Also handles llvm-cov-target used by cargo-llvm-cov
+ settings.add_filter(
+ r"[^\s]+/target/(?:llvm-cov-target/)?(?:debug|release)/wt",
+ "[BIN]",
+ );
+}
+
/// Create a configured Command for snapshot testing
///
/// This extracts the common command setup while allowing the test file
diff --git a/tests/integration_tests/approval_pty.rs b/tests/integration_tests/approval_pty.rs
index 82bbc07a6..47b7984c5 100644
--- a/tests/integration_tests/approval_pty.rs
+++ b/tests/integration_tests/approval_pty.rs
@@ -7,12 +7,8 @@
//! Note: These tests are separate from `approval_ui.rs` because they require PTY setup
//! to simulate interactive terminals. The non-PTY tests in `approval_ui.rs` verify the
//! error case (non-TTY environments).
-//!
-//! TODO: PTY snapshots show environment-specific linebreak variations due to timing-dependent
-//! buffering of input/output interleaving. Consider normalizing extra blank lines to make
-//! snapshots more stable across different environments (local vs CI vs Claude Code web).
-use crate::common::{TestRepo, repo};
+use crate::common::{TestRepo, add_pty_binary_path_filters, add_pty_filters, repo};
use insta::assert_snapshot;
use insta_cmd::get_cargo_bin;
use portable_pty::CommandBuilder;
@@ -69,78 +65,22 @@ fn exec_in_pty_with_input(
(buf, exit_code)
}
-/// Normalize output for snapshot testing
-fn normalize_output(output: &str) -> String {
- // Remove platform-specific PTY control sequences
- // macOS PTYs emit ^D (literal caret-D) followed by backspaces (0x08),
- // while Linux PTYs don't. Strip these to ensure consistent snapshots.
- // Use multiline mode to match after user input (e.g., "n\n\n^D\b\b")
- let output = regex::Regex::new(r"\^D\x08+")
- .unwrap()
- .replace_all(output, "");
-
- // Remove repository paths (macOS uses .tmp dirs like /var/folders/.../test.tmpXXX)
- // Match repo.branch-name but not trailing ANSI codes (which start with escape char \x1b)
- let output = regex::Regex::new(r"/[^\s]+\.tmp[^\s/]+/repo\.[a-zA-Z0-9_-]+")
- .unwrap()
- .replace_all(&output, "_REPO_/repo.BRANCH");
-
- // Also normalize remaining .tmp paths (for non-worktree paths)
- let output = regex::Regex::new(r"/[^\s]+\.tmp[^\s/]+")
- .unwrap()
- .replace_all(&output, "_REPO_");
-
- // Normalize worktree paths that show as ~/repo.branch-name
- // When HOME is set to the test temp dir, format_path_for_display abbreviates to ~
- // Match branch names but not trailing ANSI codes
- let output = regex::Regex::new(r"~/repo\.[a-zA-Z0-9_-]+")
- .unwrap()
- .replace_all(&output, "_REPO_/repo.BRANCH");
-
- // Remove config paths
- let output = regex::Regex::new(r"/var/folders/[^\s]+/test-config\.toml")
- .unwrap()
- .replace_all(&output, "[CONFIG]");
-
- // Normalize binary path in shell integration hint (e.g., /path/to/target/debug/wt -> [BIN])
- // Also handles llvm-cov-target used by cargo-llvm-cov in coverage builds
- // The path may contain ANSI codes (bold), so match any non-whitespace before /target
- let output = regex::Regex::new(r"[^\s]+/target/(llvm-cov-target/)?debug/wt")
- .unwrap()
- .replace_all(&output, "[BIN]");
-
- // Normalize blank lines due to PTY timing variations
- // Different environments (local, CI, Claude Code web) may have blank lines
- // in different positions due to timing-dependent buffering.
-
- // PTYs use \r\n line endings, normalize to \n first
- let mut output_str = output.replace("\r\n", "\n");
-
- // Ensure blank line after user input (y or n)
- if output_str.starts_with("y\n") || output_str.starts_with("n\n") {
- // Check if there's already a blank line after y/n
- if !output_str.starts_with("y\n\n") && !output_str.starts_with("n\n\n") {
- // Add blank line after y/n
- output_str = output_str.replacen("y\n🟡", "y\n\n🟡", 1);
- output_str = output_str.replacen("n\n🟡", "n\n\n🟡", 1);
- }
- }
+/// Create insta settings for approval PTY tests.
+///
+/// Uses shared PTY filters plus test-specific normalizations for config file paths.
+fn approval_pty_settings(repo: &TestRepo) -> insta::Settings {
+ let mut settings = crate::common::setup_snapshot_settings(repo);
+
+ // Add PTY-specific filters (CRLF, ^D, ANSI resets)
+ add_pty_filters(&mut settings);
- // Remove blank line between prompt and subsequent message
- // The prompt ends with "] " followed by ANSI codes (like [0m or [22m), space, newline,
- // then we may have a blank line. Use regex to handle varying ANSI sequences.
- let blank_after_prompt = regex::Regex::new(r"\[y/N\](\x1b\[\d+m)* \n\n(🔄|⚪)").unwrap();
- output_str = blank_after_prompt
- .replace_all(&output_str, |caps: &regex::Captures| {
- format!(
- "[y/N]{} \n{}",
- caps.get(1).map_or("", |m| m.as_str()),
- &caps[2]
- )
- })
- .to_string();
-
- output_str
+ // Binary path normalization
+ add_pty_binary_path_filters(&mut settings);
+
+ // Config paths specific to these tests
+ settings.add_filter(r"/var/folders/[^\s]+/test-config\.toml", "[CONFIG]");
+
+ settings
}
/// Get test env vars with shell integration configured.
@@ -174,9 +114,10 @@ fn test_approval_prompt_accept(repo: TestRepo) {
"y\n",
);
- let normalized = normalize_output(&output);
assert_eq!(exit_code, 0);
- assert_snapshot!("approval_prompt_accept", normalized);
+ approval_pty_settings(&repo).bind(|| {
+ assert_snapshot!("approval_prompt_accept", &output);
+ });
}
#[rstest]
@@ -198,9 +139,10 @@ fn test_approval_prompt_decline(repo: TestRepo) {
"n\n",
);
- let normalized = normalize_output(&output);
assert_eq!(exit_code, 0);
- assert_snapshot!("approval_prompt_decline", normalized);
+ approval_pty_settings(&repo).bind(|| {
+ assert_snapshot!("approval_prompt_decline", &output);
+ });
}
#[rstest]
@@ -228,9 +170,10 @@ third = "echo 'Third command'"
"y\n",
);
- let normalized = normalize_output(&output);
assert_eq!(exit_code, 0);
- assert_snapshot!("approval_prompt_multiple_commands", normalized);
+ approval_pty_settings(&repo).bind(|| {
+ assert_snapshot!("approval_prompt_multiple_commands", &output);
+ });
}
/// TODO: Find a way to test permission errors without skipping when running as root.
@@ -280,24 +223,25 @@ fn test_approval_prompt_permission_error(repo: TestRepo) {
"y\n",
);
- let normalized = normalize_output(&output);
assert_eq!(
exit_code, 0,
"Command should succeed even when saving approval fails"
);
assert!(
- normalized.contains("Failed to save command approval"),
+ output.contains("Failed to save command approval"),
"Should show permission error warning"
);
assert!(
- normalized.contains("Approval will be requested again next time"),
+ output.contains("Approval will be requested again next time"),
"Should show hint about approval being requested again"
);
assert!(
- normalized.contains("test command"),
+ output.contains("test command"),
"Command should still execute despite save failure"
);
- assert_snapshot!("approval_prompt_permission_error", normalized);
+ approval_pty_settings(&repo).bind(|| {
+ assert_snapshot!("approval_prompt_permission_error", &output);
+ });
}
#[rstest]
@@ -325,21 +269,22 @@ test = "echo 'Running tests...'"
"y\n",
);
- let normalized = normalize_output(&output);
assert_eq!(exit_code, 0);
assert!(
- normalized.contains("install") && normalized.contains("Installing dependencies"),
+ output.contains("install") && output.contains("Installing dependencies"),
"Should show command name 'install' and execute it"
);
assert!(
- normalized.contains("build") && normalized.contains("Building project"),
+ output.contains("build") && output.contains("Building project"),
"Should show command name 'build' and execute it"
);
assert!(
- normalized.contains("test") && normalized.contains("Running tests"),
+ output.contains("test") && output.contains("Running tests"),
"Should show command name 'test' and execute it"
);
- assert_snapshot!("approval_prompt_named_commands", normalized);
+ approval_pty_settings(&repo).bind(|| {
+ assert_snapshot!("approval_prompt_named_commands", &output);
+ });
}
#[rstest]
@@ -375,32 +320,28 @@ approved-commands = ["echo 'Second command'"]
"y\n",
);
- let normalized = normalize_output(&output);
assert_eq!(exit_code, 0);
// Check that only 2 commands are shown in the prompt (ANSI codes may be in between)
assert!(
- normalized.contains("execute")
- && normalized.contains("2")
- && normalized.contains("command"),
+ output.contains("execute") && output.contains("2") && output.contains("command"),
"Should show 2 unapproved commands in prompt"
);
assert!(
- normalized.contains("First command"),
+ output.contains("First command"),
"Should execute first command"
);
assert!(
- normalized.contains("Second command"),
+ output.contains("Second command"),
"Should execute pre-approved second command"
);
assert!(
- normalized.contains("Third command"),
+ output.contains("Third command"),
"Should execute third command"
);
- assert_snapshot!(
- "approval_prompt_mixed_approved_unapproved_accept",
- normalized
- );
+ approval_pty_settings(&repo).bind(|| {
+ assert_snapshot!("approval_prompt_mixed_approved_unapproved_accept", &output);
+ });
}
#[rstest]
@@ -436,38 +377,33 @@ approved-commands = ["echo 'Second command'"]
"n\n",
);
- let normalized = normalize_output(&output);
-
assert_eq!(
exit_code, 0,
"Command should succeed even when declined (worktree still created)"
);
// Check that only 2 commands are shown in the prompt (ANSI codes may be in between)
assert!(
- normalized.contains("execute")
- && normalized.contains("2")
- && normalized.contains("command"),
+ output.contains("execute") && output.contains("2") && output.contains("command"),
"Should show only 2 unapproved commands in prompt (not 3)"
);
// When declined, ALL commands are skipped (including pre-approved ones)
assert!(
- normalized.contains("Commands declined"),
+ output.contains("Commands declined"),
"Should show 'Commands declined' message"
);
// Commands appear in the prompt, but should not be executed
// Check for "Running post-create" which indicates execution
assert!(
- !normalized.contains("Running post-create"),
+ !output.contains("Running post-create"),
"Should NOT execute any commands when declined"
);
assert!(
- normalized.contains("Created branch") && normalized.contains("and worktree"),
+ output.contains("Created branch") && output.contains("and worktree"),
"Should still create worktree even when commands declined"
);
- assert_snapshot!(
- "approval_prompt_mixed_approved_unapproved_decline",
- normalized
- );
+ approval_pty_settings(&repo).bind(|| {
+ assert_snapshot!("approval_prompt_mixed_approved_unapproved_decline", &output);
+ });
}
#[rstest]
@@ -500,14 +436,15 @@ fn test_approval_prompt_remove_decline(repo: TestRepo) {
"n\n",
);
- let normalized = normalize_output(&output);
assert_eq!(
exit_code, 0,
"Remove should succeed even when hooks declined"
);
assert!(
- normalized.contains("Commands declined"),
+ output.contains("Commands declined"),
"Should show 'Commands declined' message"
);
- assert_snapshot!("approval_prompt_remove_decline", normalized);
+ approval_pty_settings(&repo).bind(|| {
+ assert_snapshot!("approval_prompt_remove_decline", &output);
+ });
}
diff --git a/tests/integration_tests/shell_wrapper.rs b/tests/integration_tests/shell_wrapper.rs
index a8d59165a..7efc2b006 100644
--- a/tests/integration_tests/shell_wrapper.rs
+++ b/tests/integration_tests/shell_wrapper.rs
@@ -10,26 +10,17 @@
//!
//! ## Why Manual PTY Execution + File Snapshots (Not insta_cmd)?
//!
-//! These tests use a pattern that might seem redundant at first glance:
-//! - Manual command execution through PTY (`exec_in_pty`)
-//! - Manual output normalization (`normalized()`)
-//! - File snapshots via `assert_snapshot!(output.normalized())`
+//! These tests use PTY execution because testing shell wrappers requires real TTY behavior
+//! (streaming output, ANSI codes, signal handling). `insta_cmd` uses `std::process::Command`
+//! which doesn't provide a TTY to child processes.
//!
-//! This is the correct approach because:
-//!
-//! 1. **PTY execution is required** - Testing shell wrappers requires real TTY behavior
-//! (streaming output, ANSI codes, signal handling). `insta_cmd` uses `std::process::Command`
-//! which doesn't provide a TTY to child processes.
-//!
-//! 2. **File snapshots are appropriate** - The output contains ANSI escape codes and complex
-//! formatting. File snapshots keep these out of source files (unlike inline snapshots).
-//!
-//! 3. **Full output is valuable** - While specific assertions verify critical properties
-//! (no directive leaks, correct exit codes), file snapshots make it easy for humans to
-//! see the complete user experience at a glance.
-//!
-//! In summary: This isn't a case of "should use insta_cmd instead" - the manual execution
-//! is necessary, and file snapshots are the right storage format for escape-code-heavy output.
+//! Output normalization uses insta's `add_filter()` API via `shell_wrapper_settings()`,
+//! which is consistent with how other tests in the codebase handle path and hash
+//! normalization. The filters handle:
+//! - PTY-specific artifacts (CRLF, ^D control sequences, ANSI resets)
+//! - Temporary directory paths
+//! - Commit hashes (non-deterministic in PTY tests due to timing/environment)
+//! - Project root paths
// All shell integration tests and infrastructure gated by feature flag
// Unix-only for now - Windows shell integration is planned
@@ -38,6 +29,7 @@
use crate::common::TestRepo;
use crate::common::canonicalize;
use crate::common::wait_for_file_content;
+use crate::common::{add_pty_filters, add_pty_tmpdir_filters};
use insta::assert_snapshot;
use insta_cmd::get_cargo_bin;
use std::fs;
@@ -46,34 +38,6 @@ use std::process::Command;
use std::sync::LazyLock;
use worktrunk::shell;
-/// Regex for normalizing temporary directory paths in test snapshots
-static TMPDIR_REGEX: LazyLock<regex::Regex> = LazyLock::new(|| {
- regex::Regex::new(
- r#"(/private/var/folders/[^/]+/[^/]+/T/\.tmp[^\s/'"]+|/tmp/\.(?:tmp|psub)[^\s/'"]+)"#,
- )
- .unwrap()
-});
-
-/// Regex that collapses repeated TMPDIR placeholders (caused by nested mktemp paths)
-/// so `[TMPDIR][TMPDIR]/foo` becomes `[TMPDIR]/foo` and `[TMPDIR]/[TMPDIR]` becomes `[TMPDIR]`
-static TMPDIR_PLACEHOLDER_COLLAPSE_REGEX: LazyLock<regex::Regex> =
- LazyLock::new(|| regex::Regex::new(r"\[TMPDIR](?:/?\[TMPDIR])+").unwrap());
-
-/// Regex for normalizing workspace paths (dynamically built from CARGO_MANIFEST_DIR)
-/// Matches: <project_root>/tests/fixtures/
-/// Replaces with: [WORKSPACE]/tests/fixtures/
-static WORKSPACE_REGEX: LazyLock<regex::Regex> = LazyLock::new(|| {
- let manifest_dir = env!("CARGO_MANIFEST_DIR");
- let pattern = format!(r"{}/tests/fixtures/", regex::escape(manifest_dir));
- regex::Regex::new(&pattern).unwrap()
-});
-
-/// Regex for normalizing git commit hashes (7-character hex)
-/// Note: No word boundaries because ANSI codes (ending with 'm') directly precede hashes
-/// Shell wrapper tests produce non-deterministic SHAs due to PTY timing/environment
-static COMMIT_HASH_REGEX: LazyLock<regex::Regex> =
- LazyLock::new(|| regex::Regex::new(r"[0-9a-f]{7}").unwrap());
-
/// Output from executing a command through a shell wrapper
#[derive(Debug)]
struct ShellOutput {
@@ -124,41 +88,30 @@ impl ShellOutput {
self.exit_code, self.combined
);
}
+}
- /// Normalize paths and ANSI codes in output for snapshot testing
- fn normalized(&self) -> String {
- // First normalize temporary directory paths
- let tmpdir_normalized = TMPDIR_REGEX.replace_all(&self.combined, "[TMPDIR]");
-
- // Then normalize workspace paths (varying directory names)
- let workspace_normalized =
- WORKSPACE_REGEX.replace_all(&tmpdir_normalized, "[WORKSPACE]/tests/fixtures/");
-
- // Normalize commit hashes (shell wrapper tests produce non-deterministic SHAs)
- let hash_normalized = COMMIT_HASH_REGEX.replace_all(&workspace_normalized, "[HASH]");
-
- // Collapse duplicate TMPDIR placeholders that can appear with nested mktemp paths.
- let tmpdir_collapsed =
- TMPDIR_PLACEHOLDER_COLLAPSE_REGEX.replace_all(&hash_normalized, "[TMPDIR]");
-
- // Then normalize ANSI codes: remove redundant leading reset codes
- // This handles differences between macOS and Linux PTY ANSI generation
- let has_trailing_newline = tmpdir_collapsed.ends_with('\n');
- let mut result = tmpdir_collapsed
- .lines()
- .map(|line| {
- // Strip leading \x1b[0m reset codes (may appear as ESC[0m in the output)
- line.strip_prefix("\x1b[0m").unwrap_or(line)
- })
- .collect::<Vec<_>>()
- .join("\n");
-
- // Preserve trailing newline if it existed
- if has_trailing_newline {
- result.push('\n');
- }
- result
+/// Create insta settings configured for shell wrapper snapshot tests.
+///
+/// This sets up filters for:
+/// - PTY-specific artifacts (CRLF, ^D control sequences, ANSI resets)
+/// - Temporary directory paths
+/// - Project root paths (for fixture references)
+fn shell_wrapper_settings() -> insta::Settings {
+ let mut settings = insta::Settings::clone_current();
+ settings.set_snapshot_path("../snapshots");
+
+ // Add common PTY filters (CRLF, ^D, leading ANSI resets)
+ add_pty_filters(&mut settings);
+
+ // Add temp directory path filters
+ add_pty_tmpdir_filters(&mut settings, "[TMPDIR]");
+
+ // Normalize project root paths (for fixture references like tests/fixtures/)
+ if let Ok(manifest_dir) = std::env::var("CARGO_MANIFEST_DIR") {
+ settings.add_filter(&regex::escape(&manifest_dir), "[PROJECT_ROOT]");
}
+
+ settings
}
/// Generate a shell wrapper script using the actual `wt config shell init` command
@@ -719,9 +672,11 @@ mod tests {
);
// Consolidated snapshot - output should be identical across all shells
- insta::allow_duplicates! {
- assert_snapshot!("command_failure", output.normalized());
- }
+ shell_wrapper_settings().bind(|| {
+ insta::allow_duplicates! {
+ assert_snapshot!("command_failure", &output.combined);
+ }
+ });
}
#[rstest]
@@ -743,9 +698,11 @@ mod tests {
);
// Consolidated snapshot - output should be identical across all shells
- insta::allow_duplicates! {
- assert_snapshot!("switch_create", output.normalized());
- }
+ shell_wrapper_settings().bind(|| {
+ insta::allow_duplicates! {
+ assert_snapshot!("switch_create", &output.combined);
+ }
+ });
}
#[rstest]
@@ -763,9 +720,11 @@ mod tests {
output.assert_no_directive_leaks();
// Consolidated snapshot - output should be identical across all shells
- insta::allow_duplicates! {
- assert_snapshot!("remove", output.normalized());
- }
+ shell_wrapper_settings().bind(|| {
+ insta::allow_duplicates! {
+ assert_snapshot!("remove", &output.combined);
+ }
+ });
}
#[rstest]
@@ -824,9 +783,11 @@ mod tests {
);
// Consolidated snapshot - output should be identical across all shells
- insta::allow_duplicates! {
- assert_snapshot!("step_for_each", output.normalized());
- }
+ shell_wrapper_settings().bind(|| {
+ insta::allow_duplicates! {
+ assert_snapshot!("step_for_each", &output.combined);
+ }
+ });
}
#[rstest]
@@ -844,9 +805,11 @@ mod tests {
output.assert_no_directive_leaks();
// Consolidated snapshot - output should be identical across all shells
- insta::allow_duplicates! {
- assert_snapshot!("merge", output.normalized());
- }
+ shell_wrapper_settings().bind(|| {
+ insta::allow_duplicates! {
+ assert_snapshot!("merge", &output.combined);
+ }
+ });
}
#[rstest]
@@ -879,9 +842,11 @@ mod tests {
);
// Consolidated snapshot - output should be identical across all shells
- insta::allow_duplicates! {
- assert_snapshot!("switch_with_execute", output.normalized());
- }
+ shell_wrapper_settings().bind(|| {
+ insta::allow_duplicates! {
+ assert_snapshot!("switch_with_execute", &output.combined);
+ }
+ });
}
/// Test that --execute command exit codes are propagated
@@ -974,7 +939,9 @@ approved-commands = [
output.assert_no_directive_leaks();
// Shell-specific snapshot - output ordering varies due to PTY buffering
- assert_snapshot!(format!("switch_with_hooks_{}", shell), output.normalized());
+ shell_wrapper_settings().bind(|| {
+ assert_snapshot!(format!("switch_with_hooks_{}", shell), &output.combined);
+ });
}
/// Test merge with successful pre-merge validation
@@ -1022,10 +989,12 @@ approved-commands = [
output.assert_no_directive_leaks();
// Shell-specific snapshot - output ordering varies due to PTY buffering
- assert_snapshot!(
- format!("merge_with_pre_merge_success_{}", shell),
- output.normalized()
- );
+ shell_wrapper_settings().bind(|| {
+ assert_snapshot!(
+ format!("merge_with_pre_merge_success_{}", shell),
+ &output.combined
+ );
+ });
}
/// Test merge with failing pre-merge that aborts the merge
@@ -1076,10 +1045,12 @@ approved-commands = [
output.assert_no_directive_leaks();
// Shell-specific snapshot - output ordering varies due to PTY buffering
- assert_snapshot!(
- format!("merge_with_pre_merge_failure_{}", shell),
- output.normalized()
- );
+ shell_wrapper_settings().bind(|| {
+ assert_snapshot!(
+ format!("merge_with_pre_merge_failure_{}", shell),
+ &output.combined
+ );
+ });
}
/// Test merge with pre-merge commands that output to both stdout and stderr
@@ -1151,10 +1122,12 @@ approved-commands = [
// header1 → all check1 output (interleaved stdout/stderr) → header2 → all check2 output
// This ensures that stdout/stderr from child processes properly stream through
// to the terminal in real-time, maintaining correct ordering
- assert_snapshot!(
- format!("merge_with_mixed_stdout_stderr_{}", shell),
- output.normalized()
- );
+ shell_wrapper_settings().bind(|| {
+ assert_snapshot!(
+ format!("merge_with_mixed_stdout_stderr_{}", shell),
+ &output.combined
+ );
+ });
}
// ========================================================================
@@ -1197,7 +1170,7 @@ approved-commands = ["echo 'test command executed'"]
// Normalize paths in output for snapshot testing
// Snapshot the output
- assert_snapshot!(output.normalized());
+ shell_wrapper_settings().bind(|| assert_snapshot!(&output.combined));
}
#[rstest]
@@ -1228,7 +1201,7 @@ approved-commands = ["echo 'test command executed'"]
// Normalize paths in output for snapshot testing
// Snapshot the output
- assert_snapshot!(output.normalized());
+ shell_wrapper_settings().bind(|| assert_snapshot!(&output.combined));
}
#[rstest]
@@ -1250,7 +1223,7 @@ approved-commands = ["echo 'test command executed'"]
"Success message missing"
);
- assert_snapshot!(output.normalized());
+ shell_wrapper_settings().bind(|| assert_snapshot!(&output.combined));
}
#[rstest]
@@ -1263,7 +1236,7 @@ approved-commands = ["echo 'test command executed'"]
"Shell integration hint should be suppressed"
);
- assert_snapshot!(output.normalized());
+ shell_wrapper_settings().bind(|| assert_snapshot!(&output.combined));
}
#[rstest]
@@ -1283,7 +1256,7 @@ approved-commands = ["echo 'test command executed'"]
"Shell integration hint should be suppressed"
);
- assert_snapshot!(output.normalized());
+ shell_wrapper_settings().bind(|| assert_snapshot!(&output.combined));
}
#[rstest]
@@ -1301,7 +1274,7 @@ approved-commands = ["echo 'test command executed'"]
"Shell integration hint should be suppressed"
);
- assert_snapshot!(output.normalized());
+ shell_wrapper_settings().bind(|| assert_snapshot!(&output.combined));
}
#[rstest]
@@ -1335,7 +1308,7 @@ approved-commands = ["echo 'background task'"]
// Snapshot verifies progress messages appear to users
// (catches the bug where progress() was incorrectly suppressed)
- assert_snapshot!(output.normalized());
+ shell_wrapper_settings().bind(|| assert_snapshot!(&output.combined));
}
// ============================================================================
@@ -1382,7 +1355,7 @@ approved-commands = ["echo 'fish background task'"]
output.assert_success();
// Snapshot verifies progress messages appear to users through Fish wrapper
- assert_snapshot!(output.normalized());
+ shell_wrapper_settings().bind(|| assert_snapshot!(&output.combined));
}
#[cfg(unix)]
@@ -1418,7 +1391,7 @@ approved-commands = ["echo 'fish background task'"]
assert!(output.combined.contains("line 3"), "Third line missing");
// Normalize paths in output for snapshot testing
- assert_snapshot!(output.normalized());
+ shell_wrapper_settings().bind(|| assert_snapshot!(&output.combined));
}
#[cfg(unix)]
@@ -1440,7 +1413,7 @@ approved-commands = ["echo 'fish background task'"]
);
// Normalize paths in output for snapshot testing
- assert_snapshot!(output.normalized());
+ shell_wrapper_settings().bind(|| assert_snapshot!(&output.combined));
}
// ========================================================================
@@ -1551,9 +1524,11 @@ approved-commands = ["echo 'fish background task'"]
// Consolidated snapshot - output should be identical across shells
// (wt error messages are deterministic)
- insta::allow_duplicates! {
- assert_snapshot!("source_flag_error_passthrough", output.normalized());
- }
+ shell_wrapper_settings().bind(|| {
+ insta::allow_duplicates! {
+ assert_snapshot!("source_flag_error_passthrough", &output.combined);
+ }
+ });
}
// ========================================================================
@@ -2378,7 +2353,7 @@ command = "{}"
);
output.assert_success();
- assert_snapshot!(output.normalized());
+ shell_wrapper_settings().bind(|| assert_snapshot!(&output.combined));
}
/// README example: Creating worktree with post-create and post-start hooks
@@ -2458,7 +2433,7 @@ fi
);
output.assert_success();
- assert_snapshot!(output.normalized());
+ shell_wrapper_settings().bind(|| assert_snapshot!(&output.combined));
}
/// README example: approval prompt for post-create commands
@@ -2538,11 +2513,14 @@ test = "echo 'Running tests...'"
let ctrl_d_regex = regex::Regex::new(r"\^D\x08+").unwrap();
let output = ctrl_d_regex.replace_all(&output, "").to_string();
- // Normalize paths
- let output = TMPDIR_REGEX.replace_all(&output, "[TMPDIR]").to_string();
- let output = TMPDIR_PLACEHOLDER_COLLAPSE_REGEX
- .replace_all(&output, "[TMPDIR]")
- .to_string();
+ // Normalize paths (local regexes since we're extracting content, not snapshotting)
+ let tmpdir_regex = regex::Regex::new(
+ r#"(?:/private)?/var/folders/[^/]+/[^/]+/T/\.tmp[^\s/'\x1b\)]+|/tmp/\.tmp[^\s/'\x1b\)]+"#,
+ )
+ .unwrap();
+ let output = tmpdir_regex.replace_all(&output, "[TMPDIR]").to_string();
+ let collapse_regex = regex::Regex::new(r"\[TMPDIR](?:/?\[TMPDIR])+").unwrap();
+ let output = collapse_regex.replace_all(&output, "[TMPDIR]").to_string();
assert!(
output.contains("needs approval"),
diff --git a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_accept.snap b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_accept.snap
index 847aca5b1..55325896b 100644
--- a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_accept.snap
+++ b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_accept.snap
@@ -1,17 +1,17 @@
---
source: tests/integration_tests/approval_pty.rs
-expression: normalized
+expression: "&output"
---
y
▲ repo needs approval to execute 1 command:
○ post-create:
-  echo 'test command'
+  echo 'test command'
❯ Allow and remember? [y/N]
-◎ Running post-create project hook @ _REPO_/repo.BRANCH:
-  echo 'test command'
-test command
-✓ Created branch test-approve from main and worktree @ _REPO_/repo.BRANCH
+◎ Running post-create project hook @ _REPO_.test-approve:
+  echo 'test command'
+test command
+✓ Created branch test-approve from main and worktree @ _REPO_.test-approve
↳ To customize worktree locations, run wt config create
▲ Cannot change directory — ran [BIN]; shell integration wraps wt
diff --git a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_decline.snap b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_decline.snap
index 000e93835..128cd02f2 100644
--- a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_decline.snap
+++ b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_decline.snap
@@ -1,15 +1,15 @@
---
source: tests/integration_tests/approval_pty.rs
-expression: normalized
+expression: "&output"
---
n
▲ repo needs approval to execute 1 command:
○ post-create:
-  echo 'test command'
+  echo 'test command'
❯ Allow and remember? [y/N]
○ Commands declined, continuing worktree creation
-✓ Created branch test-decline from main and worktree @ _REPO_/repo.BRANCH
+✓ Created branch test-decline from main and worktree @ _REPO_.test-decline
↳ To customize worktree locations, run wt config create
▲ Cannot change directory — ran [BIN]; shell integration wraps wt
diff --git a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_accept.snap b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_accept.snap
index 8b4ed08d9..aed1d0a6a 100644
--- a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_accept.snap
+++ b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_accept.snap
@@ -1,25 +1,25 @@
---
source: tests/integration_tests/approval_pty.rs
-expression: normalized
+expression: "&output"
---
y
▲ repo needs approval to execute 2 commands:
○ post-create first:
-  echo 'First command'
+  echo 'First command'
○ post-create third:
-  echo 'Third command'
+  echo 'Third command'
❯ Allow and remember? [y/N]
-◎ Running post-create project:first @ _REPO_/repo.BRANCH:
-  echo 'First command'
-First command
-◎ Running post-create project:second @ _REPO_/repo.BRANCH:
-  echo 'Second command'
-Second command
-◎ Running post-create project:third @ _REPO_/repo.BRANCH:
-  echo 'Third command'
-Third command
-✓ Created branch test-mixed-accept from main and worktree @ _REPO_/repo.BRANCH
+◎ Running post-create project:first @ _REPO_.test-mixed-accept:
+  echo 'First command'
+First command
+◎ Running post-create project:second @ _REPO_.test-mixed-accept:
+  echo 'Second command'
+Second command
+◎ Running post-create project:third @ _REPO_.test-mixed-accept:
+  echo 'Third command'
+Third command
+✓ Created branch test-mixed-accept from main and worktree @ _REPO_.test-mixed-accept
↳ To customize worktree locations, run wt config create
▲ Cannot change directory — ran [BIN]; shell integration wraps wt
diff --git a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_decline.snap b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_decline.snap
index b787b519e..8a310f1e8 100644
--- a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_decline.snap
+++ b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_decline.snap
@@ -1,17 +1,17 @@
---
source: tests/integration_tests/approval_pty.rs
-expression: normalized
+expression: "&output"
---
n
▲ repo needs approval to execute 2 commands:
○ post-create first:
-  echo 'First command'
+  echo 'First command'
○ post-create third:
-  echo 'Third command'
+  echo 'Third command'
❯ Allow and remember? [y/N]
○ Commands declined, continuing worktree creation
-✓ Created branch test-mixed-decline from main and worktree @ _REPO_/repo.BRANCH
+✓ Created branch test-mixed-decline from main and worktree @ _REPO_.test-mixed-decline
↳ To customize worktree locations, run wt config create
▲ Cannot change directory — ran [BIN]; shell integration wraps wt
diff --git a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_multiple_commands.snap b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_multiple_commands.snap
index 51256c49f..d649e76d5 100644
--- a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_multiple_commands.snap
+++ b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_multiple_commands.snap
@@ -1,27 +1,27 @@
---
source: tests/integration_tests/approval_pty.rs
-expression: normalized
+expression: "&output"
---
y
▲ repo needs approval to execute 3 commands:
○ post-create first:
-  echo 'First command'
+  echo 'First command'
○ post-create second:
-  echo 'Second command'
+  echo 'Second command'
○ post-create third:
-  echo 'Third command'
+  echo 'Third command'
❯ Allow and remember? [y/N]
-◎ Running post-create project:first @ _REPO_/repo.BRANCH:
-  echo 'First command'
-First command
-◎ Running post-create project:second @ _REPO_/repo.BRANCH:
-  echo 'Second command'
-Second command
-◎ Running post-create project:third @ _REPO_/repo.BRANCH:
-  echo 'Third command'
-Third command
-✓ Created branch test-multi from main and worktree @ _REPO_/repo.BRANCH
+◎ Running post-create project:first @ _REPO_.test-multi:
+  echo 'First command'
+First command
+◎ Running post-create project:second @ _REPO_.test-multi:
+  echo 'Second command'
+Second command
+◎ Running post-create project:third @ _REPO_.test-multi:
+  echo 'Third command'
+Third command
+✓ Created branch test-multi from main and worktree @ _REPO_.test-multi
↳ To customize worktree locations, run wt config create
▲ Cannot change directory — ran [BIN]; shell integration wraps wt
diff --git a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_named_commands.snap b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_named_commands.snap
index fd6ae39a2..358ff7a79 100644
--- a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_named_commands.snap
+++ b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_named_commands.snap
@@ -1,27 +1,27 @@
---
source: tests/integration_tests/approval_pty.rs
-expression: normalized
+expression: "&output"
---
y
▲ repo needs approval to execute 3 commands:
○ post-create install:
-  echo 'Installing dependencies...'
+  echo 'Installing dependencies...'
○ post-create build:
-  echo 'Building project...'
+  echo 'Building project...'
○ post-create test:
-  echo 'Running tests...'
+  echo 'Running tests...'
❯ Allow and remember? [y/N]
-◎ Running post-create project:install @ _REPO_/repo.BRANCH:
-  echo 'Installing dependencies...'
-Installing dependencies...
-◎ Running post-create project:build @ _REPO_/repo.BRANCH:
-  echo 'Building project...'
-Building project...
-◎ Running post-create project:test @ _REPO_/repo.BRANCH:
-  echo 'Running tests...'
-Running tests...
-✓ Created branch test-named from main and worktree @ _REPO_/repo.BRANCH
+◎ Running post-create project:install @ _REPO_.test-named:
+  echo 'Installing dependencies...'
+Installing dependencies...
+◎ Running post-create project:build @ _REPO_.test-named:
+  echo 'Building project...'
+Building project...
+◎ Running post-create project:test @ _REPO_.test-named:
+  echo 'Running tests...'
+Running tests...
+✓ Created branch test-named from main and worktree @ _REPO_.test-named
↳ To customize worktree locations, run wt config create
▲ Cannot change directory — ran [BIN]; shell integration wraps wt
diff --git a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_permission_error.snap b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_permission_error.snap
index 0c533bfd5..d81b9102d 100644
--- a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_permission_error.snap
+++ b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_permission_error.snap
@@ -1,19 +1,19 @@
---
source: tests/integration_tests/approval_pty.rs
-expression: normalized
+expression: "&output"
---
y
▲ repo needs approval to execute 1 command:
○ post-create:
-  echo 'test command'
+  echo 'test command'
❯ Allow and remember? [y/N]
▲ Failed to save command approval: Failed to write config file: Permission denied (os error 13)
↳ Approval will be requested again next time.
-◎ Running post-create project hook @ _REPO_/repo.BRANCH:
-  echo 'test command'
-test command
-✓ Created branch test-permission from main and worktree @ _REPO_/repo.BRANCH
+◎ Running post-create project hook @ _REPO_.test-permission:
+  echo 'test command'
+test command
+✓ Created branch test-permission from main and worktree @ _REPO_.test-permission
↳ To customize worktree locations, run wt config create
▲ Cannot change directory — ran [BIN]; shell integration wraps wt
diff --git a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_remove_decline.snap b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_remove_decline.snap
index 242f481f8..0a8590552 100644
--- a/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_remove_decline.snap
+++ b/tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_remove_decline.snap
@@ -1,13 +1,13 @@
---
source: tests/integration_tests/approval_pty.rs
-expression: normalized
+expression: "&output"
---
n
▲ repo needs approval to execute 1 command:
○ pre-remove:
-  echo 'pre-remove hook'
+  echo 'pre-remove hook'
❯ Allow and remember? [y/N]
○ Commands declined, continuing removal
◎ Removing to-remove worktree & branch in background (ancestor of main, ⊂)
diff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__bash_shell_integration_hint_suppressed.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__bash_shell_integration_hint_suppressed.snap
index 7a9c8df59..f89de3f49 100644
--- a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__bash_shell_integration_hint_suppressed.snap
+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__bash_shell_integration_hint_suppressed.snap
@@ -1,6 +1,6 @@
---
source: tests/integration_tests/shell_wrapper.rs
-expression: output.normalized()
+expression: "&output.combined"
---
-✓ Created branch bash-test from main and worktree @ [TMPDIR]/repo.bash-test
+✓ Created branch bash-test from main and worktree @ _REPO_.bash-test
↳ To customize worktree locations, run wt config create
diff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_multiline_command_execution.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_multiline_command_execution.snap
index 03a8d5a68..a3a6d8c44 100644
--- a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_multiline_command_execution.snap
+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_multiline_command_execution.snap
@@ -1,8 +1,8 @@
---
source: tests/integration_tests/shell_wrapper.rs
-expression: output.normalized()
+expression: "&output.combined"
---
-✓ Created branch fish-multiline from main and worktree @ [TMPDIR]/repo.fish-multiline
+✓ Created branch fish-multiline from main and worktree @ _REPO_.fish-multiline
↳ To customize worktree locations, run wt config create
◎ Executing (--execute):
  echo 'line 1'; echo 'line 2'; echo 'line 3'
diff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_wrapper_handles_empty_chunks.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_wrapper_handles_empty_chunks.snap
index a8b4f3126..69001e3e8 100644
--- a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_wrapper_handles_empty_chunks.snap
+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_wrapper_handles_empty_chunks.snap
@@ -1,6 +1,6 @@
---
source: tests/integration_tests/shell_wrapper.rs
-expression: output.normalized()
+expression: "&output.combined"
---
-✓ Created branch fish-minimal from main and worktree @ [TMPDIR]/repo.fish-minimal
+✓ Created branch fish-minimal from main and worktree @ _REPO_.fish-minimal
↳ To customize worktree locations, run wt config create
diff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_wrapper_preserves_progress_messages.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_wrapper_preserves_progress_messages.snap
index 2b253b432..91dd5fc83 100644
--- a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_wrapper_preserves_progress_messages.snap
+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__fish_wrapper_preserves_progress_messages.snap
@@ -1,8 +1,8 @@
---
source: tests/integration_tests/shell_wrapper.rs
-expression: output.normalized()
+expression: "&output.combined"
---
-✓ Created branch fish-bg from main and worktree @ [TMPDIR]/repo.fish-bg
+✓ Created branch fish-bg from main and worktree @ _REPO_.fish-bg
↳ To customize worktree locations, run wt config create
◎ Running post-start project hook:
  echo 'fish background task'
diff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_bash.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_bash.snap
index 1c7773745..3f8fe27ff 100644
--- a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_bash.snap
+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_bash.snap
@@ -1,9 +1,9 @@
---
source: tests/integration_tests/shell_wrapper.rs
-expression: output.normalized()
+expression: "&output.combined"
---
◎ Running pre-merge project:check1:
-  [TMPDIR]/repo/mixed-output.sh check1 3
+  _REPO_/mixed-output.sh check1 3
[check1] stdout line 1
[check1] stderr line 1
[check1] stdout line 2
@@ -13,7 +13,7 @@ expression: output.normalized()
[check1] stdout complete
[check1] stderr complete
◎ Running pre-merge project:check2:
-  [TMPDIR]/repo/mixed-output.sh check2 3
+  _REPO_/mixed-output.sh check2 3
[check2] stdout line 1
[check2] stderr line 1
[check2] stdout line 2
@@ -28,4 +28,4 @@ expression: output.normalized()
  1 file changed, 1 insertion(+)
✓ Merged to main (1 commit, 1 file, +1)
◎ Removing feature worktree & branch in background (same commit as main, _)
-○ Switched to worktree for main @ [TMPDIR]/repo
+○ Switched to worktree for main @ _REPO_
diff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_zsh.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_zsh.snap
index 1c7773745..3f8fe27ff 100644
--- a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_zsh.snap
+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_mixed_stdout_stderr_zsh.snap
@@ -1,9 +1,9 @@
---
source: tests/integration_tests/shell_wrapper.rs
-expression: output.normalized()
+expression: "&output.combined"
---
◎ Running pre-merge project:check1:
-  [TMPDIR]/repo/mixed-output.sh check1 3
+  _REPO_/mixed-output.sh check1 3
[check1] stdout line 1
[check1] stderr line 1
[check1] stdout line 2
@@ -13,7 +13,7 @@ expression: output.normalized()
[check1] stdout complete
[check1] stderr complete
◎ Running pre-merge project:check2:
-  [TMPDIR]/repo/mixed-output.sh check2 3
+  _REPO_/mixed-output.sh check2 3
[check2] stdout line 1
[check2] stderr line 1
[check2] stdout line 2
@@ -28,4 +28,4 @@ expression: output.normalized()
  1 file changed, 1 insertion(+)
✓ Merged to main (1 commit, 1 file, +1)
◎ Removing feature worktree & branch in background (same commit as main, _)
-○ Switched to worktree for main @ [TMPDIR]/repo
+○ Switched to worktree for main @ _REPO_
diff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_bash.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_bash.snap
index 501943ef4..9113c99f6 100644
--- a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_bash.snap
+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_bash.snap
@@ -1,6 +1,6 @@
---
source: tests/integration_tests/shell_wrapper.rs
-expression: output.normalized()
+expression: "&output.combined"
---
◎ Running pre-merge project:format:
  echo '✓ Code formatting check passed'
@@ -17,4 +17,4 @@ expression: output.normalized()
  1 file changed, 1 insertion(+)
✓ Merged to main (1 commit, 1 file, +1)
◎ Removing feature worktree & branch in background (same commit as main, _)
-○ Switched to worktree for main @ [TMPDIR]/repo
+○ Switched to worktree for main @ _REPO_
diff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_zsh.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_zsh.snap
index 501943ef4..9113c99f6 100644
--- a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_zsh.snap
+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_zsh.snap
@@ -1,6 +1,6 @@
---
source: tests/integration_tests/shell_wrapper.rs
-expression: output.normalized()
+expression: "&output.combined"
---
◎ Running pre-merge project:format:
  echo '✓ Code formatting check passed'
@@ -17,4 +17,4 @@ expression: output.normalized()
  1 file changed, 1 insertion(+)
✓ Merged to main (1 commit, 1 file, +1)
◎ Removing feature worktree & branch in background (same commit as main, _)
-○ Switched to worktree for main @ [TMPDIR]/repo
+○ Switched to worktree for main @ _REPO_
diff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_hooks_post_create.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_hooks_post_create.snap
index 38f505552..5802cd781 100644
--- a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_hooks_post_create.snap
+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_hooks_post_create.snap
@@ -1,13 +1,13 @@
---
source: tests/integration_tests/shell_wrapper.rs
-expression: output.normalized()
+expression: "&output.combined"
---
◎ Running post-create project:install:
  uv sync
Resolved 24 packages in 145ms
Installed 24 packages in 1.2s
-✓ Created branch feature-x from main and worktree @ [TMPDIR]/repo.feature-x
+✓ Created branch feature-x from main and worktree @ _REPO_.feature-x
↳ To customize worktree locations, run wt config create
◎ Running post-start project:dev:
  uv run dev
diff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_hooks_pre_merge.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_hooks_pre_merge.snap
index dea291036..5dd5e609d 100644
--- a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_hooks_pre_merge.snap
+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_hooks_pre_merge.snap
@@ -1,6 +1,6 @@
---
source: tests/integration_tests/shell_wrapper.rs
-expression: output.normalized()
+expression: "&output.combined"
---
◎ Squashing 3 commits into a single commit (2 files, +45)...
◎ Generating squash commit message...
@@ -8,7 +8,7 @@ expression: output.normalized()
 
  Implement login and token refresh endpoints with JWT validation.
  Includes comprehensive test coverage and input validation.
-✓ Squashed @ [HASH]
+✓ Squashed @ [HASH]
◎ Running pre-merge project:test:
  uv run pytest
@@ -33,4 +33,4 @@ All checks passed!
  2 files changed, 45 insertions(+)
✓ Merged to main (1 commit, 2 files, +45)
◎ Removing feature-auth worktree & branch in background (same commit as main, _)
-○ Switched to worktree for main @ [TMPDIR]/repo
+○ Switched to worktree for main @ _REPO_
diff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_remove.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_remove.snap
index c9850e0d8..8689e36cf 100644
--- a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_remove.snap
+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_remove.snap
@@ -1,6 +1,6 @@
---
source: tests/integration_tests/shell_wrapper.rs
-expression: output.normalized()
+expression: "&output.combined"
---
◎ Removing feature-api worktree & branch in background (same commit as main, _)
-○ Switched to worktree for main @ [TMPDIR]/repo
+○ Switched to worktree for main @ _REPO_
diff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_simple_switch.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_simple_switch.snap
index 47c7d8553..3342fb64f 100644
--- a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_simple_switch.snap
+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_simple_switch.snap
@@ -1,6 +1,6 @@
---
source: tests/integration_tests/shell_wrapper.rs
-expression: output.normalized()
+expression: "&output.combined"
---
-✓ Created branch fix-auth from main and worktree @ [TMPDIR]/repo.fix-auth
+✓ Created branch fix-auth from main and worktree @ _REPO_.fix-auth
↳ To customize worktree locations, run wt config create
diff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_switch_back.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_switch_back.snap
index cca3a274d..310c47f92 100644
--- a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_switch_back.snap
+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__readme_example_switch_back.snap
@@ -1,5 +1,5 @@
---
source: tests/integration_tests/shell_wrapper.rs
-expression: output.normalized()
+expression: "&output.combined"
---
-○ Switched to worktree for feature-api @ [TMPDIR]/repo.feature-api
+○ Switched to worktree for feature-api @ _REPO_.feature-api
diff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_create.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_create.snap
index 58a392240..a509263f0 100644
--- a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_create.snap
+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_create.snap
@@ -1,6 +1,6 @@
---
source: tests/integration_tests/shell_wrapper.rs
-expression: output.normalized()
+expression: "&output.combined"
---
-✓ Created branch feature from main and worktree @ [TMPDIR]/repo.feature
+✓ Created branch feature from main and worktree @ _REPO_.feature
↳ To customize worktree locations, run wt config create
diff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_execute.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_execute.snap
index bb43bfd2d..befe27829 100644
--- a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_execute.snap
+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_execute.snap
@@ -1,8 +1,8 @@
---
source: tests/integration_tests/shell_wrapper.rs
-expression: output.normalized()
+expression: "&output.combined"
---
-✓ Created branch test-exec from main and worktree @ [TMPDIR]/repo.test-exec
+✓ Created branch test-exec from main and worktree @ _REPO_.test-exec
↳ To customize worktree locations, run wt config create
◎ Executing (--execute):
  echo executed
diff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_execute_through_wrapper.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_execute_through_wrapper.snap
index bb43bfd2d..befe27829 100644
--- a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_execute_through_wrapper.snap
+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_execute_through_wrapper.snap
@@ -1,8 +1,8 @@
---
source: tests/integration_tests/shell_wrapper.rs
-expression: output.normalized()
+expression: "&output.combined"
---
-✓ Created branch test-exec from main and worktree @ [TMPDIR]/repo.test-exec
+✓ Created branch test-exec from main and worktree @ _REPO_.test-exec
↳ To customize worktree locations, run wt config create
◎ Executing (--execute):
  echo executed
diff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_hooks_zsh.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_hooks_zsh.snap
index ef03f3e13..914d80178 100644
--- a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_hooks_zsh.snap
+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_hooks_zsh.snap
@@ -1,6 +1,6 @@
---
source: tests/integration_tests/shell_wrapper.rs
-expression: output.normalized()
+expression: "&output.combined"
---
◎ Running post-create project:install:
  echo 'Installing dependencies...'
@@ -8,7 +8,7 @@ Installing dependencies...
◎ Running post-create project:build:
  echo 'Building project...'
Building project...
-✓ Created branch feature-hooks from main and worktree @ [TMPDIR]/repo.feature-hooks
+✓ Created branch feature-hooks from main and worktree @ _REPO_.feature-hooks
↳ To customize worktree locations, run wt config create
◎ Running post-start project:server:
  echo 'Starting dev server on port 3000'
diff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_post_start_command_no_directive_leak.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_post_start_command_no_directive_leak.snap
index b6d3b7764..2374bc038 100644
--- a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_post_start_command_no_directive_leak.snap
+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_post_start_command_no_directive_leak.snap
@@ -1,8 +1,8 @@
---
source: tests/integration_tests/shell_wrapper.rs
-expression: output.normalized()
+expression: "&output.combined"
---
-✓ Created branch feature-with-hooks from main and worktree @ [TMPDIR]/repo.feature-with-hooks
+✓ Created branch feature-with-hooks from main and worktree @ _REPO_.feature-with-hooks
↳ To customize worktree locations, run wt config create
◎ Running post-start project hook:
  echo 'test command executed'
diff --git a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__wrapper_preserves_progress_messages.snap b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__wrapper_preserves_progress_messages.snap
index d0ad8917f..1fb574b4b 100644
--- a/tests/snapshots/integration__integration_tests__shell_wrapper__tests__wrapper_preserves_progress_messages.snap
+++ b/tests/snapshots/integration__integration_tests__shell_wrapper__tests__wrapper_preserves_progress_messages.snap
@@ -1,8 +1,8 @@
---
source: tests/integration_tests/shell_wrapper.rs
-expression: output.normalized()
+expression: "&output.combined"
---
-✓ Created branch feature-bg from main and worktree @ [TMPDIR]/repo.feature-bg
+✓ Created branch feature-bg from main and worktree @ _REPO_.feature-bg
↳ To customize worktree locations, run wt config create
◎ Running post-start project hook:
  echo 'background task'