| 15 | /// This test tests parse errors during the first step. |
| 16 | #[rstest] |
| 17 | fn ensure_parse_errors(#[files("tests/parse_errors/*")] case: PathBuf) -> TestResult { |
| 18 | // Read the input file and parse it. |
| 19 | let input = read_to_string(&case)?; |
| 20 | let result = SourceInfoV1::from_string(input.as_str()); |
| 21 | |
| 22 | // Make sure there're no parse errors |
| 23 | let Err(error) = result else { |
| 24 | panic!("The parser succeeded even though it should've failed parsing."); |
| 25 | }; |
| 26 | |
| 27 | let name = case.file_stem().unwrap().to_str().unwrap(); |
| 28 | |
| 29 | // Run the tests with the input being displayed as the description. |
| 30 | // This makes reviewing this whole stuff a lot easier. |
| 31 | // Also remove the usual module prefix by explicitly setting the snapshot path. |
| 32 | // This isn't necessary, as we're already manually sorting snapshots by test scenario. |
| 33 | let input_clone = input.clone(); |
| 34 | insta::with_settings!({ |
| 35 | description => input_clone, |
| 36 | snapshot_path => "parse_error_snapshots", |
| 37 | prepend_module_to_snapshot => false, |
| 38 | }, { |
| 39 | assert_snapshot!(name, format!("{error}")); |
| 40 | }); |
| 41 | |
| 42 | Ok(()) |
| 43 | } |