Skip to content

Commit

Permalink
Switch from non-test expect to explicit panic!s
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannier committed Sep 3, 2024
1 parent 84312b4 commit 8e9db2e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ mod test {
let file_name = format!(
"{}.expected",
path.file_name()
.expect(&format!(
.unwrap_or_else(|| panic!(
"cannot get filename component of {}",
path.display()
))
Expand All @@ -198,10 +198,9 @@ mod test {
o.join(file_name)
};

let formatted = format(&input, false, false).expect(&format!(
"cannot format source file {}",
t.path().to_string_lossy()
));
let formatted = format(&input, false, false).unwrap_or_else(|_| {
panic!("cannot format source file {}", t.path().to_string_lossy())
});

if !update_baseline {
let expected = std::fs::read_to_string(output).expect("cannot read baseline");
Expand Down

0 comments on commit 8e9db2e

Please sign in to comment.