Skip to content

Commit 62a0d31

Browse files
committed
test: normalize CRLF in preset-config golden comparison
Force LF on golden files via .gitattributes and strip CRLF in the snapshot comparison so the test passes on Windows runners (core.autocrlf rewrites the text golden to CRLF on checkout).
1 parent b440328 commit 62a0d31

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Golden reference files are compared byte-for-byte against generated output
2+
# that always uses LF. Force LF on checkout so Windows runners (core.autocrlf=true)
3+
# don't rewrite them to CRLF and break the snapshot tests.
4+
tests/golden/** text eol=lf

tests/preset_config_snapshot.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ fn preset_assembled_configs_match_golden() {
7373
std::fs::write(GOLDEN, &buf).expect("write golden");
7474
return;
7575
}
76-
let golden = std::fs::read_to_string(GOLDEN).unwrap_or_default();
76+
// Normalize CRLF: git may check the golden out with CRLF on Windows
77+
// (core.autocrlf), while `buf` is always built with LF.
78+
let golden = std::fs::read_to_string(GOLDEN)
79+
.unwrap_or_default()
80+
.replace("\r\n", "\n");
7781
assert_eq!(buf, golden, "assembled preset configs differ from golden");
7882
}

0 commit comments

Comments
 (0)