From b8c78c3a6b40e8cc9e0cc75ce267f9163e754bc6 Mon Sep 17 00:00:00 2001 From: JamBalaya56562 Date: Sun, 23 Aug 2026 10:58:36 +0900 Subject: [PATCH] test(windows): let the suite run where zsh, fish and bash-completion are not MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two things stop `cargo test -p usage-cli` on Windows that are the tests' own doing rather than anything about usage. `a_failed_install_says_what_the_system_said` builds its target with `join("data/zsh/site-functions")`, and `Path::join` keeps the slashes it was given: join("data/zsh/site-functions") = C:\tmp\scratch\data/zsh/site-functions join chained = C:\tmp\scratch\data\zsh\site-functions The error it then matches against says `data\zsh\site-functions`, so the assertion compared two spellings of one path and failed. Joined a segment at a time, it renders the same way the error does. Unix is unaffected — the same string either way. And `bash_completion_or_skip` refuses to skip under `CI`, which cannot hold on Windows: Git for Windows does not ship the bash-completion library, and usage stopped carrying its own copy in 6.0 (#1176). Unlike a missing zsh, this is not something a runner could be configured to have, so the rule is now Unix-only. `skip_if_shell_missing` gets the same treatment for the weaker version of the same reason: the workflow installs zsh and fish for the Linux job alone, so absence is a configuration bug there and the expected state on Windows. mise draws the same line, installing no POSIX shells on its Windows runners. The mount guard in `complete_word.rs` is deliberately left strict. bash exists on Windows and the fixtures do run once `USAGECLI_SHELL_BASH` names one — 50 of 50, nothing skipped — so relaxing it would hide something that works. Measured: `completion_install` 13/13 on Windows, and on Linux the guard still panics under `CI=1` when a shell is made unusable. --- cli/tests/completion_install.rs | 7 ++++++- cli/tests/shell_completions_integration.rs | 12 ++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/cli/tests/completion_install.rs b/cli/tests/completion_install.rs index 32c367fc3..70dbdd574 100644 --- a/cli/tests/completion_install.rs +++ b/cli/tests/completion_install.rs @@ -335,7 +335,12 @@ fn a_failed_install_says_what_the_system_said() { let scratch = Scratch::new("io_cause"); // A file where a directory has to go: deterministic, and the same failure for root, which is // who a container runs as. - let target = scratch.dir.join("data/zsh/site-functions"); + // + // Joined a segment at a time. `join("data/zsh/site-functions")` keeps the slashes it was + // given, so on Windows `display()` renders `…\data/zsh/site-functions` while the error + // being matched against says `…\data\zsh\site-functions` — the same path, spelled two + // ways, and the assertion below compares spellings. + let target = scratch.dir.join("data").join("zsh").join("site-functions"); std::fs::create_dir_all(target.parent().unwrap()).unwrap(); std::fs::write(&target, "not a directory\n").unwrap(); diff --git a/cli/tests/shell_completions_integration.rs b/cli/tests/shell_completions_integration.rs index a1126deb0..82de345f2 100644 --- a/cli/tests/shell_completions_integration.rs +++ b/cli/tests/shell_completions_integration.rs @@ -101,7 +101,11 @@ fn skip_if_shell_missing(shell: &str) -> bool { if shell_can_run_a_script(shell) { return false; } - if env::var("CI").is_ok_and(|v| !v.is_empty()) { + // Unix only. The workflow installs zsh and fish for the Linux job alone, so a shell missing + // there is a configuration bug and refusing to skip is what catches it. Nothing installs them + // on Windows, where their absence is the expected state rather than a mistake — mise draws the + // same line, installing no POSIX shells on its Windows runners at all. + if cfg!(unix) && env::var("CI").is_ok_and(|v| !v.is_empty()) { panic!("shell `{shell}` cannot run a script but CI is set — refusing to skip"); } eprintln!( @@ -178,7 +182,11 @@ fn bash_completion_or_skip() -> Option { if let Some(path) = system_bash_completion() { return Some(path); } - if env::var("CI").is_ok_and(|v| !v.is_empty()) { + // Unix only, for the same reason as `skip_if_shell_missing` and a stronger one: there is no + // bash-completion to install on Windows. Git for Windows does not ship the library, and usage + // stopped carrying its own copy in 6.0 (#1176) — so unlike a missing zsh, this is not a thing + // a runner could be configured to have. + if cfg!(unix) && env::var("CI").is_ok_and(|v| !v.is_empty()) { panic!( "no usable bash-completion but CI is set — refusing to skip. Tried: {:?}", bash_completion_candidates()