From edbd25f67cc6737eb5aaf3bc37857906f319600f Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Thu, 23 Jul 2026 11:19:01 -0400 Subject: [PATCH] fix(test): strip inherited color-forcing env vars in brew upgrade tests The brew_command helper inherits the developer's environment (unlike context.command(), which env_clears), so an exported FORCE_COLOR or CLICOLOR_FORCE overrides the NO_COLOR=1 the harness sets and the CLI renders ANSI codes into snapshot output, failing upgrade_brew_install_refuses_and_prints_brew_command and upgrade_brew_install_rejects_version_flag on any machine with FORCE_COLOR exported. Remove FORCE_COLOR, CLICOLOR_FORCE, and CLICOLOR from the spawned command's env, and add the FORCE_COLOR constant to EnvVars. Co-Authored-By: Claude Fable 5 --- lib/crates/fabro-cli/tests/it/cmd/upgrade.rs | 6 ++++++ lib/crates/fabro-static/src/env_vars.rs | 2 ++ 2 files changed, 8 insertions(+) diff --git a/lib/crates/fabro-cli/tests/it/cmd/upgrade.rs b/lib/crates/fabro-cli/tests/it/cmd/upgrade.rs index 7a3a35576..b75ebb779 100644 --- a/lib/crates/fabro-cli/tests/it/cmd/upgrade.rs +++ b/lib/crates/fabro-cli/tests/it/cmd/upgrade.rs @@ -49,6 +49,12 @@ fn brew_command(context: &TestContext, formula: &str, version: &str) -> Command } } cmd.env(EnvVars::NO_COLOR, "1"); + // Unlike context.command(), this command inherits the developer's + // environment, and inherited FORCE_COLOR/CLICOLOR_FORCE override NO_COLOR + // in the CLI's color detection — breaking these snapshots. + cmd.env_remove(EnvVars::FORCE_COLOR); + cmd.env_remove(EnvVars::CLICOLOR_FORCE); + cmd.env_remove(EnvVars::CLICOLOR); cmd.env(EnvVars::HOME, &context.home_dir); cmd.env(EnvVars::FABRO_NO_UPGRADE_CHECK, "true") .env(EnvVars::FABRO_HTTP_PROXY_POLICY, "disabled") diff --git a/lib/crates/fabro-static/src/env_vars.rs b/lib/crates/fabro-static/src/env_vars.rs index 4ed7585ca..b2921b045 100644 --- a/lib/crates/fabro-static/src/env_vars.rs +++ b/lib/crates/fabro-static/src/env_vars.rs @@ -114,6 +114,7 @@ impl EnvVars { pub const CI: &'static str = "CI"; pub const CLICOLOR: &'static str = "CLICOLOR"; pub const CLICOLOR_FORCE: &'static str = "CLICOLOR_FORCE"; + pub const FORCE_COLOR: &'static str = "FORCE_COLOR"; pub const HOME: &'static str = "HOME"; pub const KUBERNETES_SERVICE_HOST: &'static str = "KUBERNETES_SERVICE_HOST"; pub const LANG: &'static str = "LANG"; @@ -251,6 +252,7 @@ mod tests { EnvVars::CI, EnvVars::CLICOLOR, EnvVars::CLICOLOR_FORCE, + EnvVars::FORCE_COLOR, EnvVars::HOME, EnvVars::KUBERNETES_SERVICE_HOST, EnvVars::LANG,