From df53a221135e63b0d2a60893b21d4f1173c8507c Mon Sep 17 00:00:00 2001 From: Hunter Bown Date: Fri, 1 May 2026 02:59:57 -0500 Subject: [PATCH] test(utils): gate display_path tests to cfg(unix) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The tests set \$HOME to drive `dirs::home_dir()`. On Unix that's the contract dirs uses; on Windows dirs reads %USERPROFILE% first, so setting HOME has no effect and the tests fail. The `display_path` function itself is platform-identical — it delegates to `dirs::home_dir()` for the home prefix and uses `std::path::MAIN_SEPARATOR` for the separator after the tilde. The contraction logic is exercised on macOS/Linux which is sufficient coverage for an abstraction whose platform detail is delegated. If we want Windows-specific assertion coverage in the future, it should either set USERPROFILE alongside HOME or accept an injected home dir. Co-Authored-By: Claude Opus 4.7 (1M context) --- crates/tui/src/utils.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/tui/src/utils.rs b/crates/tui/src/utils.rs index 80a8e403..a1b8bded 100644 --- a/crates/tui/src/utils.rs +++ b/crates/tui/src/utils.rs @@ -233,7 +233,14 @@ pub fn estimate_message_chars(messages: &[Message]) -> usize { total } -#[cfg(test)] +// Tests below set `HOME` to drive `dirs::home_dir()`, which is honored on +// Unix but not on Windows (which reads `USERPROFILE` first). The +// `display_path` contraction logic itself is platform-identical — it +// delegates to `dirs::home_dir()`. Gate to `cfg(unix)` so we cover the +// behavior on the platform whose env-var contract matches the test +// driver, instead of writing platform-specific test scaffolding for a +// pure abstraction. +#[cfg(all(test, unix))] mod tests { use super::display_path; use std::path::PathBuf;