]>
git.proxmox.com Git - pmg-log-tracker.git/blob - tests/utils.rs
1d14c88254e2ffeca9a60570ff98590c8860b1e3
4 use std
::path
::PathBuf
;
6 fn get_target_dir() -> PathBuf
{
7 let bin
= env
::current_exe().expect("exe path");
8 let mut target_dir
= PathBuf
::from(bin
.parent().expect("bin parent"));
13 pub fn log_tracker_path() -> String
{
14 let mut target_dir
= get_target_dir();
15 target_dir
.push("pmg-log-tracker");
16 target_dir
.to_str().unwrap().to_string()
20 pub fn compare_output
<R
: BufRead
, R2
: BufRead
>(command
: R
, expected
: R2
) {
21 let expected_lines
: Vec
<String
> = expected
.lines().map(|l
| l
.unwrap()).collect();
22 let command_lines
: Vec
<String
> = command
.lines().map(|l
| l
.unwrap()).collect();
26 "expected: {}, command: {}",
30 for (old
, new
) in expected_lines
.iter().zip(command_lines
.iter())
32 if new
.starts_with("# ") && old
.starts_with("# ") {
34 } else if new
.starts_with("# ") {
37 "comment line found in command output, but not in expected output"
39 } else if old
.starts_with("# ") {
42 "comment line found in expected output, but not in command output"