From f66be793b8c873ba3721cfa6bb5b623aabcafc2b Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Sun, 3 May 2026 23:30:18 +0000 Subject: [PATCH] Fix snapshot-test CRLF mismatch on Windows runners The control-query snapshot tests panicked on the Windows GitHub runner because git's default core.autocrlf=true converted fixture files (src/control/snapshots/*.json) to CRLF on checkout, while the in-memory JSON output is LF. trim_end() only strips trailing newlines, not interior \r, so every snapshot comparison mismatched. Two defenses: 1. .gitattributes: pin src/control/snapshots/*.json to text eol=lf so future Windows checkouts keep the fixtures LF-only regardless of local git config. 2. src/control/queries.rs (assert_snapshot): replace \r\n with \n in the expected text before comparison, so any future re-introduction of CRLF (a contributor with non-LF editor settings, a different runner, etc.) doesn't surface as a snapshot mismatch. --- .gitattributes | 5 +++++ src/control/queries.rs | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..2688725 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +# Keep snapshot test fixtures LF-only across all platforms so that +# Windows checkouts with core.autocrlf=true don't convert them to CRLF +# (which would mismatch the actual JSON serialization output during +# snapshot comparison). +src/control/snapshots/*.json text eol=lf diff --git a/src/control/queries.rs b/src/control/queries.rs index 8e4fcdc..7547192 100644 --- a/src/control/queries.rs +++ b/src/control/queries.rs @@ -1272,6 +1272,9 @@ mod tests { } let expected = std::fs::read_to_string(&path) .unwrap_or_else(|e| panic!("failed to read snapshot {}: {e}", path.display())); + // Normalize line endings: Windows checkouts with core.autocrlf=true + // convert fixture files to CRLF; the in-memory JSON output is LF. + let expected = expected.replace("\r\n", "\n"); // Tolerate trailing newline differences from editors. if expected.trim_end() != actual.trim_end() { panic!(