From 6a2d95ba3d10d7482c3e95090b135c202ca23144 Mon Sep 17 00:00:00 2001 From: Hunter Bown Date: Sun, 3 May 2026 08:37:53 -0500 Subject: [PATCH] =?UTF-8?q?fix(truncate):=20Windows=20test=20fixes=20?= =?UTF-8?q?=E2=80=94=20path=20components=20+=20cfg(unix)=20on=20mtime=20te?= =?UTF-8?q?st?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI surfaced two Windows-only failures in `tools::truncate::tests`: 1. `write_spillover_creates_directory_and_writes_file` asserted `path.to_string_lossy().contains(".deepseek/tool_outputs")`. On Windows the path separator is `\`, so the substring match never matched even though the file lived in the correct directory. Replace with a `path.components()` walk that checks for the two directory names individually — passes on Windows, Linux, and macOS. 2. `prune_older_than_keeps_fresh_files_drops_stale_ones` relied on `filetime_set_modified` to backdate a file by 30 days. The helper is implemented with `utimensat` on Unix and is a no-op on Windows, which means the prune step had no stale file to drop and the `assert_eq!(pruned, 1)` always failed. The mtime invariant is already covered by Linux + macOS in CI; gate the test on `cfg(unix)` rather than ship a no-op Windows variant that can't fail meaningfully. Restores PR #519 CI to green so the v0.8.8 release can land. --- crates/tui/src/tools/truncate.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/tui/src/tools/truncate.rs b/crates/tui/src/tools/truncate.rs index 1484e8ad..ff1a52dd 100644 --- a/crates/tui/src/tools/truncate.rs +++ b/crates/tui/src/tools/truncate.rs @@ -337,7 +337,17 @@ mod tests { let body = fs::read_to_string(&path).unwrap(); assert_eq!(body, "hello world"); // Directory landed under `/.deepseek/tool_outputs/`. - assert!(path.to_string_lossy().contains(".deepseek/tool_outputs")); + // Compare components instead of a substring on `to_string_lossy` + // — Windows uses `\` as the separator so a `/` substring match + // would falsely fail there. + let components: Vec<&str> = path + .components() + .filter_map(|c| c.as_os_str().to_str()) + .collect(); + assert!( + components.contains(&".deepseek") && components.contains(&"tool_outputs"), + "spillover path missing expected `.deepseek/tool_outputs/...` segments: {path:?}" + ); }); } @@ -412,7 +422,12 @@ mod tests { }); } + // The mtime backdate uses utimensat (Unix-only). On Windows the + // filetime_set_modified helper is a no-op, so the prune wouldn't see + // any stale files. Gate the whole test on `cfg(unix)` instead of + // testing a no-op path that can't fail meaningfully. #[test] + #[cfg(unix)] fn prune_older_than_keeps_fresh_files_drops_stale_ones() { let _g = setup(); let tmp = tempdir().unwrap();