Skip to content

Commit

Permalink
test: fix cli tests with cross
Browse files Browse the repository at this point in the history
  • Loading branch information
vthib committed Sep 12, 2023
1 parent 2e41baa commit aaf5dbe
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion boreal-cli/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,29 @@ use predicates::prelude::*;
use tempfile::{NamedTempFile, TempDir};

fn cmd() -> Command {
Command::cargo_bin("boreal").unwrap()
fn find_runner() -> Option<String> {
for (key, value) in std::env::vars() {
if key.starts_with("CARGO_TARGET_") && key.ends_with("_RUNNER") && !value.is_empty() {
return Some(value);
}
}
None
}

let path = assert_cmd::cargo::cargo_bin("boreal");
// This is done to handle cross in CI tests.
// See <https://github.com/assert-rs/assert_cmd/issues/139>.
if let Some(runner) = find_runner() {
let mut runner = runner.split_whitespace();
let mut cmd = Command::new(runner.next().unwrap());
for arg in runner {
cmd.arg(arg);
}
cmd.arg(path);
cmd
} else {
Command::new(path)
}
}

fn test_file(contents: &str) -> NamedTempFile {
Expand Down

0 comments on commit aaf5dbe

Please sign in to comment.