Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Fix integration tests for Git version and PTY environment differences (#22)
Maximilian Roosf847645719c9
diff --git a/tests/common/mod.rs b/tests/common/mod.rsindex 5104a5e29..e9e5db7ab 100644--- a/tests/common/mod.rs+++ b/tests/common/mod.rs@@ -687,6 +687,19 @@ pub fn setup_snapshot_settings(repo: &TestRepo) -> insta::Settings {"post-start-[NAME]-[TIMESTAMP].log",);+ // Filter out Git hint messages that vary across Git versions+ // These hints appear during rebase conflicts and can differ between versions+ // Pattern matches lines with gutter formatting + "hint:" + message + newline+ // The gutter is: ESC[40m ESC[0m followed by spaces+ settings.add_filter(r"(?m)^\x1b\[40m \x1b\[0m {1,2}hint:.*\n", "");++ // Normalize Git error message format differences across versions+ // Older Git (< 2.43): "Could not apply [SHA]... # commit message"+ // Newer Git (>= 2.43): "Could not apply [SHA]... commit message"+ // Add the "# " prefix to newer Git output for consistency with snapshots+ // Match if followed by a letter/character (not "#")+ settings.add_filter(r"(Could not apply \[SHA\]\.\.\.) ([A-Za-z])", "$1 # $2");+settings}diff --git a/tests/integration_tests/approval_pty.rs b/tests/integration_tests/approval_pty.rsindex ee92c1be2..355ad496e 100644--- a/tests/integration_tests/approval_pty.rs+++ b/tests/integration_tests/approval_pty.rs@@ -114,7 +114,30 @@ fn normalize_output(output: &str) -> String {.unwrap().replace_all(&output, "[CONFIG]");- output.to_string()+ // 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);+ }+ }++ // Remove blank line between prompt and subsequent message+ // The prompt ends with "] " followed by newline, then we may have blank line+ // Pattern: [y/N] followed by ANSI codes, space, newline, blank line, then emoji+ output_str = output_str.replace("[y/N]\x1b[0m \n\n🔄", "[y/N]\x1b[0m \n🔄");+ output_str = output_str.replace("[y/N]\x1b[0m \n\n⚪", "[y/N]\x1b[0m \n⚪");++ output_str}#[test]