(#[files("tests/parse_errors/desc/*")] case: PathBuf)
| 18 | /// and the file's contents as description. |
| 19 | #[rstest] |
| 20 | fn ensure_desc_parse_errors(#[files("tests/parse_errors/desc/*")] case: PathBuf) -> TestResult { |
| 21 | let input = read_to_string(&case)?; |
| 22 | let name = case |
| 23 | .file_stem() |
| 24 | .and_then(|s| s.to_str()) |
| 25 | .unwrap_or("unknown_case"); |
| 26 | |
| 27 | // Try both V1 and V2 constructors, as syntax errors should fail on either. |
| 28 | let res_v1 = DbDescFileV1::from_str(&input); |
| 29 | let res_v2 = DbDescFileV2::from_str(&input); |
| 30 | |
| 31 | // ensure at least one parser fails |
| 32 | if res_v1.is_ok() || res_v2.is_ok() { |
| 33 | unreachable!("parser unexpectedly succeeded"); |
| 34 | } |
| 35 | |
| 36 | let error = res_v1 |
| 37 | .err() |
| 38 | .map(|e| e.to_string()) |
| 39 | .or_else(|| res_v2.err().map(|e| e.to_string())) |
| 40 | .unwrap_or_else(|| "unknown parser failure".to_string()); |
| 41 | |
| 42 | let input_clone = input.clone(); |
| 43 | insta::with_settings!({ |
| 44 | description => input_clone, |
| 45 | snapshot_path => "parse_errors/desc/snapshots", |
| 46 | prepend_module_to_snapshot => false, |
| 47 | }, { |
| 48 | assert_snapshot!(name, error); |
| 49 | }); |
| 50 | |
| 51 | Ok(()) |
| 52 | } |
| 53 | |
| 54 | /// Each `.files` file in `tests/parse_errors/files` is expected to fail parsing. |
| 55 | /// |
nothing calls this directly
no test coverage detected