Skip to content

Commit 76d2d53

Browse files
committed
fix(revealjs): normalize EOL in vendored-asset drift test
The test byte-compared the include_str!-embedded reveal assets against the npm dist copy. On a Windows checkout, core.autocrlf rewrites the committed-LF vendored files to CRLF on disk, so the embedded bytes gain CRLF while the npm copy stays LF -- a false mismatch on line endings alone. These assets are served verbatim and CRLF vs LF is irrelevant to browsers; the test's job is to catch content drift when reveal.js is bumped, not line endings. Normalize both sides before comparing so only real drift fails.
1 parent 37f249c commit 76d2d53

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

crates/quarto-core/src/revealjs/assemble.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,10 @@ mod tests {
555555
/// pipelines drift on reveal version/CSS. This test compares the embedded
556556
/// constants to the npm dist and fails if the vendored copy is stale —
557557
/// re-sync `resources/revealjs/` from `node_modules/reveal.js/dist/` (see
558-
/// `resources/revealjs/README.md`). Skips when node_modules is absent
559-
/// (fresh checkout before `npm install`).
558+
/// `resources/revealjs/README.md`). Line endings are normalized before the
559+
/// compare, so a Windows checkout (`core.autocrlf` rewriting the committed-LF
560+
/// files to CRLF) does not false-positive on EOL — only real content drift
561+
/// fails. Skips when node_modules is absent (fresh checkout before `npm install`).
560562
#[test]
561563
fn vendored_reveal_assets_match_npm_package() {
562564
let npm_dist = concat!(
@@ -569,12 +571,20 @@ mod tests {
569571
);
570572
return;
571573
}
574+
// Compare content only, with line endings normalized. These assets are
575+
// served verbatim, but CRLF vs LF is irrelevant to every browser, and a
576+
// Windows checkout (core.autocrlf) rewrites the committed-LF vendored
577+
// files to CRLF on disk — a byte-exact compare against the always-LF npm
578+
// copy would then false-positive on line endings alone. This test's job
579+
// is to catch *content* drift (a reveal.js version bump), not EOL noise.
580+
let norm = |s: &str| s.replace("\r\n", "\n");
572581
let check = |embedded: &str, rel: &str| {
573582
let path = format!("{npm_dist}/{rel}");
574583
let npm =
575584
std::fs::read_to_string(&path).unwrap_or_else(|e| panic!("reading {path}: {e}"));
576585
assert_eq!(
577-
embedded, npm,
586+
norm(embedded),
587+
norm(&npm),
578588
"vendored resources/revealjs/{rel} has drifted from \
579589
node_modules/reveal.js/dist/{rel} — re-sync the vendored copy \
580590
(q2 render and q2 preview must use identical reveal assets)"

0 commit comments

Comments
 (0)