Skip to content

Commit 1a053fa

Browse files
committed
minor: Eagerly panic when a fixture file can't be read
This has a more direct error message when you typo the filename in a highlighter test.
1 parent 959309a commit 1a053fa

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

highlighter/src/fixtures.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ macro_rules! wln {
2626

2727
pub fn check_fixture(path: impl AsRef<Path>, roundtrip: impl FnOnce(&str) -> String) {
2828
let path = path.as_ref();
29-
let snapshot = fs::read_to_string(path)
30-
.unwrap_or_default()
31-
.replace("\r\n", "\n");
29+
let snapshot = match fs::read_to_string(path) {
30+
Ok(content) => content.replace("\r\n", "\n"),
31+
Err(err) => panic!("Failed to read fixture {path:?}: {err}"),
32+
};
3233
let snapshot = snapshot.trim_end();
3334
let roundtrip = roundtrip(snapshot);
3435
if snapshot != roundtrip.trim_end() {

0 commit comments

Comments
 (0)