Skip to content

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

fix: Normalize PTY control sequences in approval tests for Linux compatibility

Maximilian Roosd8f22b642441
diff --git a/tests/integration_tests/approval_pty.rs b/tests/integration_tests/approval_pty.rs
index ef3bc9e33..116724e95 100644
--- a/tests/integration_tests/approval_pty.rs
+++ b/tests/integration_tests/approval_pty.rs
@@ -92,10 +92,18 @@ fn exec_in_pty_with_input(
/// 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
let output = regex::Regex::new(r"/[^\s]+\.tmp[^\s/]+")
.unwrap()
- .replace_all(output, "[REPO]");
+ .replace_all(&output, "[REPO]");
// Remove config paths
let output = regex::Regex::new(r"/var/folders/[^\s]+/test-config\.toml")
diff --git a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_accept.snap b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_accept.snap
index b3cfbb4dd..7a998bd94 100644
--- a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_accept.snap
+++ b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_accept.snap
@@ -4,7 +4,7 @@ expression: normalized
---
y
-^D🟑 test-repo needs approval to execute 1 command:
+🟑 test-repo needs approval to execute 1 command:
πŸ”„ post-create:
  echo 'test command'
diff --git a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_decline.snap b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_decline.snap
index 75e722eea..8aca362b5 100644
--- a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_decline.snap
+++ b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_decline.snap
@@ -4,7 +4,7 @@ expression: normalized
---
n
-^D🟑 test-repo needs approval to execute 1 command:
+🟑 test-repo needs approval to execute 1 command:
πŸ”„ post-create:
  echo 'test command'
diff --git a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_accept.snap b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_accept.snap
index 7da78e90a..9be8f95a0 100644
--- a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_accept.snap
+++ b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_accept.snap
@@ -4,7 +4,7 @@ expression: normalized
---
y
-^D🟑 test-repo needs approval to execute 2 commands:
+🟑 test-repo needs approval to execute 2 commands:
πŸ”„ post-create:
  echo 'First command'
diff --git a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_decline.snap b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_decline.snap
index d9ac249a2..3f4b7eaf4 100644
--- a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_decline.snap
+++ b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_mixed_approved_unapproved_decline.snap
@@ -4,7 +4,7 @@ expression: normalized
---
n
-^D🟑 test-repo needs approval to execute 2 commands:
+🟑 test-repo needs approval to execute 2 commands:
πŸ”„ post-create:
  echo 'First command'
diff --git a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_multiple_commands.snap b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_multiple_commands.snap
index 02fc3e55c..ad9c09961 100644
--- a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_multiple_commands.snap
+++ b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_multiple_commands.snap
@@ -4,7 +4,7 @@ expression: normalized
---
y
-^D🟑 test-repo needs approval to execute 3 commands:
+🟑 test-repo needs approval to execute 3 commands:
πŸ”„ post-create:
  echo 'First command'
diff --git a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_named_commands.snap b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_named_commands.snap
index 19b48ab21..fcf7362ca 100644
--- a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_named_commands.snap
+++ b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_named_commands.snap
@@ -4,7 +4,7 @@ expression: normalized
---
y
-^D🟑 test-repo needs approval to execute 3 commands:
+🟑 test-repo needs approval to execute 3 commands:
πŸ”„ post-create install:
  echo 'Installing dependencies...'
diff --git a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_permission_error.snap b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_permission_error.snap
index 1744285d0..bcaab2c32 100644
--- a/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_permission_error.snap
+++ b/tests/integration_tests/snapshots/integration__integration_tests__approval_pty__approval_prompt_permission_error.snap
@@ -4,7 +4,7 @@ expression: normalized
---
y
-^D🟑 test-repo needs approval to execute 1 command:
+🟑 test-repo needs approval to execute 1 command:
πŸ”„ post-create:
  echo 'test command'