Skip to content

Commit 19e3caa

Browse files
tests: add test for panic on new_parser_from_file
1 parent b4f8351 commit 19e3caa

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Diff for: src/test/mod.rs

+16
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,22 @@ fn parser_errors_in_submods_are_surfaced() {
545545
}
546546
}
547547

548+
#[test]
549+
fn parser_creation_errors_on_entry_new_parser_from_file_panic() {
550+
// See also https://github.com/rust-lang/rustfmt/issues/4418
551+
let filename = "tests/parser/issue_4418.rs";
552+
let file = PathBuf::from(filename);
553+
let (config, operation, _) = read_config(&file);
554+
if let Err(OperationError::ParseError { input, is_panic }) =
555+
format_file(&file, operation, config)
556+
{
557+
assert_eq!(input.as_path().unwrap(), file);
558+
assert!(is_panic);
559+
} else {
560+
panic!("Expected ParseError operation error");
561+
}
562+
}
563+
548564
// For each file, run rustfmt and collect the output.
549565
// Returns the number of files checked and the number of failures.
550566
fn check_files(files: Vec<PathBuf>, opt_config: &Option<PathBuf>) -> (Vec<FormatReport>, u32, u32) {

Diff for: tests/parser/issue_4418.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
}

0 commit comments

Comments
 (0)