Skip to content

Commit 86a41bc

Browse files
tests: add test for panic on new_parser_from_file
1 parent 9faba45 commit 86a41bc

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/test/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,22 @@ fn format_lines_errors_are_reported_with_tabs() {
483483
assert!(session.has_formatting_errors());
484484
}
485485

486+
#[test]
487+
fn parser_creation_errors_on_entry_new_parser_from_file_panic() {
488+
// See also https://github.com/rust-lang/rustfmt/issues/4418
489+
let filename = "tests/parser/issue_4418.rs";
490+
let file = PathBuf::from(filename);
491+
let (config, operation, _) = read_config(&file);
492+
if let Err(OperationError::ParseError { input, is_panic }) =
493+
format_file(&file, operation, config)
494+
{
495+
assert_eq!(input.as_path().unwrap(), file);
496+
assert!(is_panic);
497+
} else {
498+
panic!("Expected ParseError operation error");
499+
}
500+
}
501+
486502
// For each file, run rustfmt and collect the output.
487503
// Returns the number of files checked and the number of failures.
488504
fn check_files(files: Vec<PathBuf>, opt_config: &Option<PathBuf>) -> (Vec<FormatReport>, u32, u32) {

tests/parser/issue_4418.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
}

0 commit comments

Comments
 (0)