Skip to content

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

Fix: Make CI tests deterministic across environments (#77)

Maximilian Roos6a0533282ec7
diff --git a/src/commands/config.rs b/src/commands/config.rs
index cafd97d01..c9b15051b 100644
--- a/src/commands/config.rs
+++ b/src/commands/config.rs
@@ -347,6 +347,11 @@ fn check_zsh_compinit_missing() -> bool {
return false; // Assume compinit is configured
}
+ // Force compinit to be missing (for tests that expect the warning)
+ if std::env::var("WT_ASSUME_NO_COMPINIT").is_ok() {
+ return true; // Force warning to appear
+ }
+
// Probe zsh to check if compdef function exists (indicates compinit has run)
// Use --no-globalrcs to skip system files (like /etc/zshrc on macOS which enables compinit)
// This ensures we're checking the USER's configuration, not system defaults
diff --git a/src/shell.rs b/src/shell.rs
index 176747c3d..d2ae085bb 100644
--- a/src/shell.rs
+++ b/src/shell.rs
@@ -289,6 +289,11 @@ pub fn detect_zsh_compinit() -> Option<bool> {
return Some(true); // Assume compinit is configured
}
+ // Force compinit to be missing (for tests that expect the warning)
+ if std::env::var("WT_ASSUME_NO_COMPINIT").is_ok() {
+ return Some(false); // Force warning to appear
+ }
+
// Probe command: check if compdef function exists (proof compinit ran).
// We use unique markers (__WT_COMPINIT_*) to avoid false matches from any
// output the user's zshrc might produce during startup.
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index e47224364..666781a8a 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -799,8 +799,8 @@ pub fn setup_snapshot_settings(repo: &TestRepo) -> insta::Settings {
// 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", "");
+ // The gutter is: ESC[107m (bright white bg) ESC[0m followed by spaces
+ settings.add_filter(r"(?m)^\x1b\[107m \x1b\[0m {1,2}hint:.*\n", "");
// Normalize Git error message format differences across versions
// Older Git (< 2.43): "Could not apply SHA... # commit message"
diff --git a/tests/integration_tests/approval_pty.rs b/tests/integration_tests/approval_pty.rs
index e5881a744..5eabdbc18 100644
--- a/tests/integration_tests/approval_pty.rs
+++ b/tests/integration_tests/approval_pty.rs
@@ -122,10 +122,18 @@ fn normalize_output(output: &str) -> String {
}
// 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⚪");
+ // 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
}
diff --git a/tests/integration_tests/config_show.rs b/tests/integration_tests/config_show.rs
index b8539f98f..c3152ea01 100644
--- a/tests/integration_tests/config_show.rs
+++ b/tests/integration_tests/config_show.rs
@@ -176,6 +176,8 @@ if command -v wt >/dev/null 2>&1; then eval "$(command wt config shell init zsh)
settings.bind(|| {
let mut cmd = wt_command();
repo.clean_cli_env(&mut cmd);
+ // Force compinit warning for deterministic tests across environments
+ cmd.env("WT_ASSUME_NO_COMPINIT", "1");
cmd.arg("config").arg("show").current_dir(repo.root_path());
set_temp_home_env(&mut cmd, temp_home.path());
diff --git a/tests/integration_tests/configure_shell.rs b/tests/integration_tests/configure_shell.rs
index 3a593c2be..da7e65eda 100644
--- a/tests/integration_tests/configure_shell.rs
+++ b/tests/integration_tests/configure_shell.rs
@@ -19,6 +19,8 @@ fn test_configure_shell_with_yes() {
repo.clean_cli_env(&mut cmd);
set_temp_home_env(&mut cmd, temp_home.path());
cmd.env("SHELL", "/bin/zsh");
+ // Force compinit warning for deterministic tests across environments
+ cmd.env("WT_ASSUME_NO_COMPINIT", "1");
cmd.arg("config")
.arg("shell")
.arg("install")
@@ -63,6 +65,8 @@ fn test_configure_shell_specific_shell() {
repo.clean_cli_env(&mut cmd);
set_temp_home_env(&mut cmd, temp_home.path());
cmd.env("SHELL", "/bin/zsh");
+ // Force compinit warning for deterministic tests across environments
+ cmd.env("WT_ASSUME_NO_COMPINIT", "1");
cmd.arg("config")
.arg("shell")
.arg("install")
@@ -287,6 +291,8 @@ fn test_configure_shell_multiple_configs() {
repo.clean_cli_env(&mut cmd);
set_temp_home_env(&mut cmd, temp_home.path());
cmd.env("SHELL", "/bin/zsh");
+ // Force compinit warning for deterministic tests across environments
+ cmd.env("WT_ASSUME_NO_COMPINIT", "1");
cmd.arg("config")
.arg("shell")
.arg("install")
@@ -348,6 +354,8 @@ fn test_configure_shell_mixed_states() {
repo.clean_cli_env(&mut cmd);
set_temp_home_env(&mut cmd, temp_home.path());
cmd.env("SHELL", "/bin/zsh");
+ // Force compinit warning for deterministic tests across environments
+ cmd.env("WT_ASSUME_NO_COMPINIT", "1");
cmd.arg("config")
.arg("shell")
.arg("install")
diff --git a/tests/integration_tests/select.rs b/tests/integration_tests/select.rs
index df47eee05..d043dacf0 100644
--- a/tests/integration_tests/select.rs
+++ b/tests/integration_tests/select.rs
@@ -40,8 +40,9 @@ const STABILIZE_TIMEOUT: Duration = Duration::from_secs(5);
/// How long screen must be unchanged to consider it "stable".
/// Must be long enough for preview content to load (preview commands run async).
-/// 300ms balances reliability (allows preview to complete) with speed.
-const STABLE_DURATION: Duration = Duration::from_millis(300);
+/// 500ms balances reliability (allows preview to complete) with speed.
+/// Panel switches trigger async git commands that may take time.
+const STABLE_DURATION: Duration = Duration::from_millis(500);
/// Polling interval when waiting for output.
/// Fast polling ensures tests complete quickly when ready.