| 16 | /// from a PKGBUILD with an existing .SRCINFO file. |
| 17 | #[test] |
| 18 | fn compare() -> TestResult { |
| 19 | // Write the PKGBUILD to a temporary directory |
| 20 | let mut tempdir = tempdir()?; |
| 21 | let pkgbuild_path = tempdir.path().join("PKGBUILD"); |
| 22 | let mut file = File::create_new(&pkgbuild_path)?; |
| 23 | file.write_all(TEST_PKGBUILD.as_bytes())?; |
| 24 | |
| 25 | // Write the .SRCINFO to a temporary directory |
| 26 | let srcinfo_path = tempdir.path().join(".SRCINFO"); |
| 27 | let mut file = File::create_new(&srcinfo_path)?; |
| 28 | file.write_all(TEST_SRCINFO.as_bytes())?; |
| 29 | |
| 30 | // Call the bridge on the that PKGBUILD file. |
| 31 | let mut cmd = cargo_bin_cmd!("dev-scripts"); |
| 32 | cmd.args(vec![ |
| 33 | "compare-srcinfo", |
| 34 | "--pkgbuild", |
| 35 | "PKGBUILD", |
| 36 | "--srcinfo", |
| 37 | ".SRCINFO", |
| 38 | ]); |
| 39 | |
| 40 | cmd.current_dir(tempdir.path()); |
| 41 | |
| 42 | // Make sure the command was successful, which implies that the file matched!. |
| 43 | let assert = cmd.assert(); |
| 44 | // Disable the cleanup so that users may investigate the output files. |
| 45 | if let Err(err) = assert.try_success() { |
| 46 | println!( |
| 47 | "Output files of this test can be found at: {}", |
| 48 | tempdir.path().to_string_lossy() |
| 49 | ); |
| 50 | tempdir.disable_cleanup(true); |
| 51 | // Now we may error. |
| 52 | panic!("srcinfo compare failed: {err}"); |
| 53 | } |
| 54 | |
| 55 | Ok(()) |
| 56 | } |
| 57 | } |