MCPcopy Create free account
hub / github.com/archlinux/alpm / ensure_parse_errors

Function ensure_parse_errors

alpm-srcinfo/tests/parse_errors.rs:17–43  ·  view source on GitHub ↗
(#[files("tests/parse_errors/*")] case: PathBuf)

Source from the content-addressed store, hash-verified

15/// This test tests parse errors during the first step.
16#[rstest]
17fn 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}

Callers

nothing calls this directly

Calls 1

as_strMethod · 0.45

Tested by

no test coverage detected