Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Re-enable shell wrapper tests with correct fish snapshots (#3)
Maximilian Roosee9cf057caa8
diff --git a/tests/integration_tests/shell_wrapper.rs b/tests/integration_tests/shell_wrapper.rsindex 205845a03..dcc2a7ae1 100644--- a/tests/integration_tests/shell_wrapper.rs+++ b/tests/integration_tests/shell_wrapper.rs@@ -45,9 +45,28 @@ impl ShellOutput {);}- /// Normalize paths in output for snapshot testing- fn normalized(&self) -> std::borrow::Cow<'_, str> {- TMPDIR_REGEX.replace_all(&self.combined, "[TMPDIR]")+ /// Normalize paths and ANSI codes in output for snapshot testing+ fn normalized(&self) -> String {+ // First normalize paths+ let path_normalized = TMPDIR_REGEX.replace_all(&self.combined, "[TMPDIR]");++ // Then normalize ANSI codes: remove redundant leading reset codes+ // This handles differences between macOS and Linux PTY ANSI generation+ let has_trailing_newline = path_normalized.ends_with('\n');+ let mut result = path_normalized+ .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}}@@ -283,6 +302,10 @@ fn exec_through_wrapper_from("WORKTRUNK_CONFIG_PATH".to_string(),repo.test_config_path().to_string_lossy().to_string(),),+ // Set TERM for consistent terminal behavior across local and CI environments+ // Without this, macOS and Linux PTYs have different defaults which causes+ // different ANSI escape sequence generation (different reset placements)+ ("TERM".to_string(), "xterm".to_string()),// Git config from configure_git_cmd("GIT_AUTHOR_NAME".to_string(), "Test User".to_string()),(@@ -372,7 +395,7 @@ mod tests {// Consolidated snapshot - output should be identical across all shellsinsta::allow_duplicates! {- assert_snapshot!("command_failure", output.normalized().as_ref());+ assert_snapshot!("command_failure", output.normalized());}}@@ -398,7 +421,7 @@ mod tests {// Consolidated snapshot - output should be identical across all shellsinsta::allow_duplicates! {- assert_snapshot!("switch_create", output.normalized().as_ref());+ assert_snapshot!("switch_create", output.normalized());}}@@ -421,7 +444,7 @@ mod tests {// Consolidated snapshot - output should be identical across all shellsinsta::allow_duplicates! {- assert_snapshot!("remove", output.normalized().as_ref());+ assert_snapshot!("remove", output.normalized());}}@@ -444,7 +467,7 @@ mod tests {// Consolidated snapshot - output should be identical across all shellsinsta::allow_duplicates! {- assert_snapshot!("merge", output.normalized().as_ref());+ assert_snapshot!("merge", output.normalized());}}@@ -482,20 +505,16 @@ mod tests {// Consolidated snapshot - output should be identical across all shellsinsta::allow_duplicates! {- assert_snapshot!("switch_with_execute", output.normalized().as_ref());+ assert_snapshot!("switch_with_execute", output.normalized());}}/// Test switch --create with post-create-command (blocking) and post-start-command (background)- // TODO: Fix non-deterministic test - PTY buffering causes inconsistent output ordering- // All shells (bash/zsh/fish) have varying output order due to background post-start commands- // Fish fails ~50% in CI, bash/zsh also use shell-specific snapshots due to ordering issues- // #[rstest]- // #[case("bash")]- // #[case("zsh")]- // #[case("fish")]- #[allow(dead_code)]- fn test_wrapper_switch_with_hooks(shell: &str) {+ #[rstest]+ #[case("bash")]+ #[case("zsh")]+ #[case("fish")]+ fn test_wrapper_switch_with_hooks(#[case] shell: &str) {let repo = TestRepo::new();repo.commit("Initial commit");@@ -542,21 +561,15 @@ 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().as_ref()- );+ assert_snapshot!(format!("switch_with_hooks_{}", shell), output.normalized());}/// Test merge with successful pre-merge-command validation- // TODO: Fix non-deterministic test - PTY buffering causes inconsistent output ordering- // Shell-specific snapshots exist but still produce inconsistent results across runs- // #[rstest]- // #[case("bash")]- // #[case("zsh")]- // #[case("fish")]- #[allow(dead_code)]- fn test_wrapper_merge_with_pre_merge_success(shell: &str) {+ #[rstest]+ #[case("bash")]+ #[case("zsh")]+ #[case("fish")]+ fn test_wrapper_merge_with_pre_merge_success(#[case] shell: &str) {let mut repo = TestRepo::new();repo.commit("Initial commit");repo.setup_remote("main");@@ -628,19 +641,16 @@ approved-commands = [// Shell-specific snapshot - output ordering varies due to PTY bufferingassert_snapshot!(format!("merge_with_pre_merge_success_{}", shell),- output.normalized().as_ref()+ output.normalized());}/// Test merge with failing pre-merge-command that aborts the merge- // TODO: Fix non-deterministic test - PTY buffering causes inconsistent output ordering- // Shell-specific snapshots exist but still produce inconsistent results across runs- // #[rstest]- // #[case("bash")]- // #[case("zsh")]- // #[case("fish")]- #[allow(dead_code)]- fn test_wrapper_merge_with_pre_merge_failure(shell: &str) {+ #[rstest]+ #[case("bash")]+ #[case("zsh")]+ #[case("fish")]+ fn test_wrapper_merge_with_pre_merge_failure(#[case] shell: &str) {let mut repo = TestRepo::new();repo.commit("Initial commit");repo.setup_remote("main");@@ -709,7 +719,7 @@ approved-commands = [// Shell-specific snapshot - output ordering varies due to PTY bufferingassert_snapshot!(format!("merge_with_pre_merge_failure_{}", shell),- output.normalized().as_ref()+ output.normalized());}@@ -757,7 +767,7 @@ approved-commands = ["echo 'test command executed'"]// Normalize paths in output for snapshot testing// Snapshot the output- assert_snapshot!(output.normalized().as_ref());+ assert_snapshot!(output.normalized());}#[test]@@ -792,7 +802,7 @@ approved-commands = ["echo 'test command executed'"]// Normalize paths in output for snapshot testing// Snapshot the output- assert_snapshot!(output.normalized().as_ref());+ assert_snapshot!(output.normalized());}#[test]@@ -817,7 +827,7 @@ approved-commands = ["echo 'test command executed'"]"Success message missing");- assert_snapshot!(output.normalized().as_ref());+ assert_snapshot!(output.normalized());}#[test]@@ -871,7 +881,7 @@ approved-commands = ["echo 'background task'"]// Normalize paths in output for snapshot testing// Snapshot the full output- assert_snapshot!(output.normalized().as_ref());+ assert_snapshot!(output.normalized());}// ============================================================================@@ -936,7 +946,7 @@ approved-commands = ["echo 'fish background task'"]"Background command content missing from output");- assert_snapshot!(output.normalized().as_ref());+ assert_snapshot!(output.normalized());}#[test]@@ -974,7 +984,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().as_ref());+ assert_snapshot!(output.normalized());}#[test]@@ -998,6 +1008,6 @@ approved-commands = ["echo 'fish background task'"]);// Normalize paths in output for snapshot testing- assert_snapshot!(output.normalized().as_ref());+ assert_snapshot!(output.normalized());}}diff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_bash.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_bash.snapindex 0cca67b19..e4dc9053c 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_bash.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_bash.snap@@ -1,14 +1,14 @@---source: tests/integration_tests/shell_wrapper.rs-expression: output.normalized().as_ref()+expression: output.normalized()---π [36mRunning pre-merge: [1mformat[0m[0m-[0m[40m [0m [1m[34mecho[0m [32m'β Code formatting check passed'[0m[0m+[40m [0m [1m[34mecho[0m [32m'β Code formatting check passed'[0m[0mβ Code formatting check passedπ [36mRunning pre-merge: [1mtest[0m[0m-[0m[40m [0m [1m[34mecho[0m [32m'β Test suite failed: 3 tests failing'[0m [36m&&[0m [1m[34mexit[0m 1[0m+[40m [0m [1m[34mecho[0m [32m'β Test suite failed: 3 tests failing'[0m [36m&&[0m [1m[34mexit[0m 1[0mβ Test suite failed: 3 tests failingβ [31mpre-merge command failed: [1m[31mtest[0m[0mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_fish.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_fish.snapindex 2849fdfc0..94d4d5b49 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_fish.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_fish.snap@@ -1,13 +1,13 @@---source: tests/integration_tests/shell_wrapper.rs-expression: output.normalized().as_ref()+expression: output.normalized()---π [36mRunning pre-merge: [1mformat[0m[0m-[0m[40m [0m [1m[34mecho[0m [32m'β Code formatting check passed'[0m[0m+[40m [0m [1m[34mecho[0m [32m'β Code formatting check passed'[0m[0mβ Code formatting check passedπ [36mRunning pre-merge: [1mtest[0m[0m-[0m[40m [0m [1m[34mecho[0m [32m'β Test suite failed: 3 tests failing'[0m [36m&&[0m [1m[34mexit[0m 1[0m+[40m [0m [1m[34mecho[0m [32m'β Test suite failed: 3 tests failing'[0m [36m&&[0m [1m[34mexit[0m 1[0mβ Test suite failed: 3 tests failingβ [31mpre-merge command failed: [1m[31mtest[0m[0mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_zsh.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_zsh.snapindex 2da246f6d..afd04eb9c 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_zsh.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_failure_zsh.snap@@ -1,9 +1,9 @@---source: tests/integration_tests/shell_wrapper.rs-expression: output.normalized().as_ref()+expression: output.normalized()----[0mβ Code formatting check passed-[0mβ Test suite failed: 3 tests failing+β Code formatting check passed+β Test suite failed: 3 tests failingβ [31mpre-merge command failed: [1m[31mtest[0m[0mCommand failed with exit code: exit status: 1diff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_bash.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_bash.snapindex 338b14c10..0211ddbca 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_bash.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_bash.snap@@ -1,19 +1,19 @@---source: tests/integration_tests/shell_wrapper.rs-expression: output.normalized().as_ref()+expression: output.normalized()---π [36mRunning pre-merge: [1mformat[0m[0m-[0m[40m [0m [1m[34mecho[0m [32m'β Code formatting check passed'[0m[0m+[40m [0m [1m[34mecho[0m [32m'β Code formatting check passed'[0m[0mβ Code formatting check passedπ [36mRunning pre-merge: [1mlint[0m[0m-[0m[40m [0m [1m[34mecho[0m [32m'β Linting passed - no warnings'[0m[0m+[40m [0m [1m[34mecho[0m [32m'β Linting passed - no warnings'[0m[0mβ Linting passed - no warningsπ [36mRunning pre-merge: [1mtest[0m[0m-[0m[40m [0m [1m[34mecho[0m [32m'β All 47 tests passed in 2.3s'[0m[0m+[40m [0m [1m[34mecho[0m [32m'β All 47 tests passed in 2.3s'[0m[0mβ All 47 tests passed in 2.3sdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_fish.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_fish.snapindex 31c1b925b..a0f3caff6 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_fish.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_fish.snap@@ -1,19 +1,19 @@---source: tests/integration_tests/shell_wrapper.rs-expression: output.normalized().as_ref()+expression: output.normalized()---π [36mRunning pre-merge: [1mformat[0m[0m-[0m[40m [0m [1m[34mecho[0m [32m'β Code formatting check passed'[0m[0m+[40m [0m [1m[34mecho[0m [32m'β Code formatting check passed'[0m[0mβ Code formatting check passedπ [36mRunning pre-merge: [1mlint[0m[0m-[0mβ Linting passed - no warnings[40m [0m [1m[34mecho[0m [32m'β Linting passed - no warnings'[0m[0m+β Linting passed - no warningsπ [36mRunning pre-merge: [1mtest[0m[0m[40m [0m [1m[34mecho[0m [32m'β All 47 tests passed in 2.3s'[0m[0m-[0mβ All 47 tests passed in 2.3s+β All 47 tests passed in 2.3sπ [36mMerging 1 commit to [1m[36mmain[0m @ [2m[36md067f01[0m[0m (no commit/squash/rebase needed)* [33md067f01[m[33m ([m[1;36mHEAD[m[33m -> [m[1;32mfeature[m[33m)[m Add featurediff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_zsh.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_zsh.snapindex cb769dfa0..1a3aab5ba 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_zsh.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__merge_with_pre_merge_success_zsh.snap@@ -1,10 +1,10 @@---source: tests/integration_tests/shell_wrapper.rs-expression: output.normalized().as_ref()+expression: output.normalized()----[0mβ Code formatting check passed-[0mβ Linting passed - no warnings-[0mβ All 47 tests passed in 2.3s+β Code formatting check passed+β Linting passed - no warnings+β All 47 tests passed in 2.3sπ [36mRunning pre-merge: [1mformat[0m[0m[40m [0m [1m[34mecho[0m [32m'β Code formatting check passed'[0m[0mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_hooks_bash.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_hooks_bash.snapindex d9fa41c43..6647c48c7 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_hooks_bash.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_hooks_bash.snap@@ -1,14 +1,14 @@---source: tests/integration_tests/shell_wrapper.rs-expression: output.normalized().as_ref()+expression: output.normalized()---π [36mRunning post-create: [1m1[0m[0m-[0m[40m [0m [1m[34mecho[0m [32m'Installing dependencies...'[0m[0m+[40m [0m [1m[34mecho[0m [32m'Installing dependencies...'[0m[0mInstalling dependencies...π [36mRunning post-create: [1m2[0m[0m-[0m[40m [0m [1m[34mecho[0m [32m'Building project...'[0m[0m+[40m [0m [1m[34mecho[0m [32m'Building project...'[0m[0mBuilding project...diff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_hooks_fish.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_hooks_fish.snapnew file mode 100644index 000000000..838a3c958--- /dev/null+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_hooks_fish.snap@@ -0,0 +1,18 @@+---+source: tests/integration_tests/shell_wrapper.rs+expression: output.normalized()+---+π [36mRunning post-create: [1m1[0m[0m+[40m [0m [1m[34mecho[0m [32m'Installing dependencies...'[0m[0m++Installing dependencies...+π [36mRunning post-create: [1m2[0m[0m+[40m [0m [1m[34mecho[0m [32m'Building project...'[0m[0m++Building project...+β [32mCreated new worktree for [1m[32mfeature-hooks[0m[32m, changed directory to [1m[32m[TMPDIR]/test-repo.feature-hooks[0m[0m+π [36mRunning post-start: [1mserver[0m[0m+[40m [0m [1m[34mecho[0m [32m'Starting dev server on port 3000'[0m[0m++π [36mRunning post-start: [1mwatch[0m[0m+[40m [0m [1m[34mecho[0m [32m'Watching for file changes'[0m[0mdiff --git a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_hooks_zsh.snap b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_hooks_zsh.snapindex a5f593977..a257429dc 100644--- a/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_hooks_zsh.snap+++ b/tests/integration_tests/snapshots/integration__integration_tests__shell_wrapper__tests__switch_with_hooks_zsh.snap@@ -1,9 +1,9 @@---source: tests/integration_tests/shell_wrapper.rs-expression: output.normalized().as_ref()+expression: output.normalized()----[0mInstalling dependencies...-[0mBuilding project...+Installing dependencies...+Building project...π [36mRunning post-create: [1m1[0m[0m[40m [0m [1m[34mecho[0m [32m'Installing dependencies...'[0m[0m