about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorCaleb Cartwright <caleb.cartwright@outlook.com>2020-09-26 00:01:21 -0500
committerCaleb Cartwright <calebcartwright@users.noreply.github.com>2020-11-02 18:31:51 -0600
commit86a41bc80befae44ef8f59625c6225da9f955c83 (patch)
tree6fc72942ea15286c4f4498c7c0ae0d7e31c3cc36 /src/test
parent9faba4539b24ac2db69edd385774d085bb0fd120 (diff)
tests: add test for panic on new_parser_from_file
Diffstat (limited to 'src/test')
-rw-r--r--src/test/mod.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/mod.rs b/src/test/mod.rs
index 9b3ca717152..7d2e8c18e9c 100644
--- a/src/test/mod.rs
+++ b/src/test/mod.rs
@@ -483,6 +483,22 @@ fn format_lines_errors_are_reported_with_tabs() {
     assert!(session.has_formatting_errors());
 }
 
+#[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) {