mirror of
https://github.com/jmcorgan/fips.git
synced 2026-08-11 09:07:44 +00:00
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.
This commit is contained in:
@@ -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!(
|
||||
|
||||
Reference in New Issue
Block a user