Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 10b9afa

Browse files
committed
Add test asserting we catch Rust parser panics
1 parent 66c98db commit 10b9afa

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/test/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,18 @@ fn stdin_formatting_smoke_test() {
288288
assert_eq!(buf, "fn main() {}\r\n".as_bytes());
289289
}
290290

291+
#[test]
292+
fn stdin_parser_panic_caught() {
293+
// https://github.com/rust-lang/rustfmt/issues/3239
294+
for text in ["{", "}"].iter().cloned().map(String::from) {
295+
let mut buf = vec![];
296+
let mut session = Session::new(Default::default(), Some(&mut buf));
297+
let _ = session.format(Input::Text(text));
298+
299+
assert!(session.has_parsing_errors());
300+
}
301+
}
302+
291303
#[test]
292304
fn stdin_disable_all_formatting_test() {
293305
match option_env!("CFG_RELEASE_CHANNEL") {

0 commit comments

Comments
 (0)