Skip to content

Commit 26ff5a3

Browse files
committed
Fix commonmark regression test to check the FileId it actually protects
roborev review (job 1730) caught that commonmark_reader_source_context_uses_forward_slashes asserted FileId(0), but ASTContext::with_filename populates FileId(0) internally before commonmark::read's own add_file call ever runs — the entry that call actually writes is FileId(1). The test passed regardless of whether that call normalized its filename, giving zero protection for the fix in f5a93fa. Verified by reverting just that one line and confirming the test still passed; asserting FileId(1) instead now fails correctly when reverted.
1 parent f5a93fa commit 26ff5a3

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

crates/pampa/tests/integration/test_diagnostic_path_normalization.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,14 @@ fn commonmark_reader_source_context_uses_forward_slashes() {
102102
let (_, context) =
103103
pampa::readers::commonmark::read("hello\n", "tests\\snapshots\\commonmark\\001.qmd");
104104

105+
// FileId(0) is the entry `ASTContext::with_filename` creates internally
106+
// (already normalized, unrelated to this reader's own fix). The fix
107+
// this test protects is commonmark::read's own second `add_file` call,
108+
// which lands at FileId(1) — asserting FileId(0) here would pass
109+
// regardless of whether that second call normalizes its filename.
105110
let file = context
106111
.source_context
107-
.get_file(FileId(0))
108-
.expect("file 0 should exist");
112+
.get_file(FileId(1))
113+
.expect("file 1 should exist");
109114
assert_eq!(file.path, "tests/snapshots/commonmark/001.qmd");
110115
}

0 commit comments

Comments
 (0)