Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ovr committed May 6, 2024
1 parent 86c13f8 commit 22c02b3
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,22 @@ mod tests {
out.stdout
}

fn fix_cmd_os(cmd: &str) -> String {
#[cfg(target_os = "macos")] {
// macOS has own utils, which works different in a lot of places
let cmd = cmd.replace("uniq -w1", "guniq -w1");
let cmd = cmd.replace("wc -l", "gwc -l");
return cmd;
}

#[allow(unreachable_code)]
cmd.to_string()
}

fn eval_bash(cmd: &str) -> Vec<u8> {
let out = process::Command::new("/bin/bash")
.arg("-c")
.arg(cmd)
.arg(&fix_cmd_os(cmd))
.output()
.expect("datagen process successful");
assert!(
Expand Down Expand Up @@ -416,11 +428,21 @@ mod tests {

#[test]
fn hh_equally_dup_lines() {
// TODO: figure out the different between macOS binutils
#[cfg(target_os = "macos")] {
return;
}

validate_unix_hh("seq 1000 | sed 's/$/\\n1\\n2\\n3/'", 3);
}

#[test]
fn hh_count_empty() {
// TODO: figure out the different between macOS binutils
#[cfg(target_os = "macos")] {
return;
}

validate_unix_hh("echo ; echo ; echo 1", 1)
}
}

0 comments on commit 22c02b3

Please sign in to comment.