| 38 | /// Run the `srcinfo format` subcommand to convert a PKGBUILD into a .SRCINFO file. |
| 39 | #[test] |
| 40 | fn format() -> TestResult { |
| 41 | // Write the PKGBUILD to a temporary directory |
| 42 | let tempdir = tempdir()?; |
| 43 | let path = tempdir.path().join("PKGBUILD"); |
| 44 | let mut file = File::create_new(&path)?; |
| 45 | file.write_all(TEST_PKGBUILD.as_bytes())?; |
| 46 | |
| 47 | // Generate the .SRCINFO file from the that PKGBUILD file. |
| 48 | let mut cmd = cargo_bin_cmd!("alpm-srcinfo"); |
| 49 | cmd.args(vec!["create".into(), path.to_string_lossy().to_string()]); |
| 50 | |
| 51 | // Make sure the command was successful and get the output. |
| 52 | let output = cmd.assert().success(); |
| 53 | let output = String::from_utf8_lossy(&output.get_output().stdout); |
| 54 | |
| 55 | let srcinfo = SourceInfoV1::from_string(&output)?; |
| 56 | |
| 57 | assert_eq!(srcinfo.base.name.inner(), "example"); |
| 58 | |
| 59 | Ok(()) |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | mod validate { |