forked from pacman-repo-builder/pacman-repo-builder
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatch_makepkg.rs
44 lines (40 loc) · 1.34 KB
/
patch_makepkg.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use command_extra::CommandExtra;
use pacman_repo_builder::utils::MAKEPKG_PATCHES;
use pipe_trait::*;
use std::process::Command;
const EXE: &str = env!("CARGO_BIN_EXE_build-pacman-repo");
fn init() -> Command {
Command::new(EXE).with_arg("patch-makepkg")
}
fn output(mut command: Command) -> (String, String, bool) {
let output = command.output().expect("get output from a command");
let stdout = output
.stdout
.pipe(String::from_utf8)
.expect("convert stdout to UTF-8");
let stderr = output
.stderr
.pipe(String::from_utf8)
.expect("convert stderr to UTF-8");
let success = output.status.success();
(stdout, stderr, success)
}
#[test]
fn print_makepkg() {
let (stdout, stderr, success) = output(init());
let actual_stderr_lines = stderr.lines().collect::<Vec<_>>();
let actual = (actual_stderr_lines.as_slice(), success);
let expected_stderr_lines: &[&str] = &[
"",
"# NOTE: Above is the content of custom makepkg script",
"# NOTE: Run again with --replace flag to replace system's makepkg",
];
let expected = (expected_stderr_lines, true);
assert!(
MAKEPKG_PATCHES
.iter()
.any(|patch| patch.custom_content == stdout.as_str()),
"find a matching makepkg patch",
);
assert_eq!(actual, expected);
}