Skip to content

Commit

Permalink
tests: add test for panic on new_parser_from_file
Browse files Browse the repository at this point in the history
  • Loading branch information
calebcartwright committed Oct 7, 2020
1 parent b4f8351 commit 19e3caa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,22 @@ fn parser_errors_in_submods_are_surfaced() {
}
}

#[test]
fn parser_creation_errors_on_entry_new_parser_from_file_panic() {
// See also https://github.com/rust-lang/rustfmt/issues/4418
let filename = "tests/parser/issue_4418.rs";
let file = PathBuf::from(filename);
let (config, operation, _) = read_config(&file);
if let Err(OperationError::ParseError { input, is_panic }) =
format_file(&file, operation, config)
{
assert_eq!(input.as_path().unwrap(), file);
assert!(is_panic);
} else {
panic!("Expected ParseError operation error");
}
}

// For each file, run rustfmt and collect the output.
// Returns the number of files checked and the number of failures.
fn check_files(files: Vec<PathBuf>, opt_config: &Option<PathBuf>) -> (Vec<FormatReport>, u32, u32) {
Expand Down
1 change: 1 addition & 0 deletions tests/parser/issue_4418.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
}

0 comments on commit 19e3caa

Please sign in to comment.