mirror of
https://github.com/helix-editor/tree-house.git
synced 2025-10-06 00:12:46 +02:00
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.
This commit is contained in:
@@ -26,9 +26,10 @@ macro_rules! wln {
|
||||
|
||||
pub fn check_fixture(path: impl AsRef<Path>, roundtrip: impl FnOnce(&str) -> String) {
|
||||
let path = path.as_ref();
|
||||
let snapshot = fs::read_to_string(path)
|
||||
.unwrap_or_default()
|
||||
.replace("\r\n", "\n");
|
||||
let snapshot = match fs::read_to_string(path) {
|
||||
Ok(content) => content.replace("\r\n", "\n"),
|
||||
Err(err) => panic!("Failed to read fixture {path:?}: {err}"),
|
||||
};
|
||||
let snapshot = snapshot.trim_end();
|
||||
let roundtrip = roundtrip(snapshot);
|
||||
if snapshot != roundtrip.trim_end() {
|
||||
|
Reference in New Issue
Block a user