Skip to content

Commit d1ab3be

Browse files
committed
Avoid panicking in test with bad terminal
1 parent cac67cb commit d1ab3be

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tests/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,15 @@ fn check_files(files: Vec<PathBuf>) -> (Vec<FormatReport>, u32, u32) {
330330
}
331331

332332
fn print_mismatches_default_message(result: HashMap<PathBuf, Vec<Mismatch>>) {
333-
let mut t = term::stdout().unwrap();
334333
for (file_name, diff) in result {
335334
let mismatch_msg_formatter =
336335
|line_num| format!("\nMismatch at {}:{}:", file_name.display(), line_num);
337336
print_diff(diff, &mismatch_msg_formatter, Color::Auto);
338337
}
339338

340-
t.reset().unwrap();
339+
if let Some(mut t) = term::stdout() {
340+
t.reset().unwrap();
341+
}
341342
}
342343

343344
fn print_mismatches<T: Fn(u32) -> String>(

0 commit comments

Comments
 (0)