make tests a bit less platform dependent
NOTE The tests that use nix don't work with nixUnstable since <nix/config.nix> was removed, which the test expressions depend on.
This commit is contained in:
parent
524cd74056
commit
2ddee3c3ff
|
@ -268,8 +268,9 @@ mod tests {
|
|||
}
|
||||
|
||||
fn make_pr_repo(bare: &Path, co: &Path) -> String {
|
||||
let output = Command::new("./make-pr.sh")
|
||||
let output = Command::new("bash")
|
||||
.current_dir(tpath("./test-srcs"))
|
||||
.arg("./make-pr.sh")
|
||||
.arg(bare)
|
||||
.arg(co)
|
||||
.stdout(Stdio::piped())
|
||||
|
|
|
@ -136,13 +136,19 @@ mod tests {
|
|||
use std::process::Command;
|
||||
use std::process::Stdio;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
const SYSTEM: &str = "x86_64-linux";
|
||||
#[cfg(target_os = "macos")]
|
||||
const SYSTEM: &str = "x86_64-darwin";
|
||||
|
||||
fn tpath(component: &str) -> PathBuf {
|
||||
return Path::new(env!("CARGO_MANIFEST_DIR")).join(component);
|
||||
}
|
||||
|
||||
fn make_pr_repo(bare: &Path, co: &Path) -> String {
|
||||
let output = Command::new("./make-maintainer-pr.sh")
|
||||
let output = Command::new("bash")
|
||||
.current_dir(tpath("./test-srcs"))
|
||||
.arg("./make-maintainer-pr.sh")
|
||||
.arg(bare)
|
||||
.arg(co)
|
||||
.stdout(Stdio::piped())
|
||||
|
@ -183,7 +189,7 @@ mod tests {
|
|||
working_co.checkout_ref(&OsStr::new(&hash)).unwrap();
|
||||
|
||||
let remote = env::var("NIX_REMOTE").unwrap_or("".to_owned());
|
||||
let nix = Nix::new("x86_64-linux".to_owned(), remote, 1800, None);
|
||||
let nix = Nix::new(SYSTEM.to_owned(), remote, 1800, None);
|
||||
|
||||
let parsed =
|
||||
ImpactedMaintainers::calculate(&nix, &working_co.clone_to(), &paths, &attributes);
|
||||
|
|
|
@ -380,9 +380,18 @@ pub fn wait_for_build_status(spawned: SpawnedAsyncCmd) -> BuildStatus {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
const SYSTEM: &str = "x86_64-linux";
|
||||
#[cfg(target_os = "macos")]
|
||||
const SYSTEM: &str = "x86_64-darwin";
|
||||
|
||||
fn nix() -> Nix {
|
||||
let remote = env::var("NIX_REMOTE").unwrap_or("".to_owned());
|
||||
Nix::new("x86_64-linux".to_owned(), remote, 1800, None)
|
||||
Nix::new(SYSTEM.to_owned(), remote, 1800, None)
|
||||
}
|
||||
|
||||
fn noop(operation: Operation) -> Operation {
|
||||
|
@ -508,10 +517,6 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
use super::*;
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[test]
|
||||
fn test_build_operations() {
|
||||
let nix = nix();
|
||||
|
@ -608,7 +613,7 @@ mod tests {
|
|||
fn safe_command_custom_gc() {
|
||||
let remote = env::var("NIX_REMOTE").unwrap_or("".to_owned());
|
||||
let nix = Nix::new(
|
||||
"x86_64-linux".to_owned(),
|
||||
SYSTEM.to_owned(),
|
||||
remote,
|
||||
1800,
|
||||
Some("4g".to_owned()),
|
||||
|
|
|
@ -391,6 +391,11 @@ mod tests {
|
|||
use std::process::{Command, Stdio};
|
||||
use std::vec::IntoIter;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
const SYSTEM: &str = "x86_64-linux";
|
||||
#[cfg(target_os = "macos")]
|
||||
const SYSTEM: &str = "x86_64-darwin";
|
||||
|
||||
fn nix() -> nix::Nix {
|
||||
let remote = env::var("NIX_REMOTE").unwrap_or("".to_owned());
|
||||
nix::Nix::new("x86_64-linux".to_owned(), remote, 1800, None)
|
||||
|
@ -406,7 +411,7 @@ mod tests {
|
|||
let worker = BuildWorker::new(
|
||||
cloner,
|
||||
nix,
|
||||
"x86_64-linux".to_owned(),
|
||||
SYSTEM.to_owned(),
|
||||
"cargo-test-build".to_owned(),
|
||||
);
|
||||
|
||||
|
@ -414,8 +419,9 @@ mod tests {
|
|||
}
|
||||
|
||||
fn make_pr_repo(bare: &Path, co: &Path) -> String {
|
||||
let output = Command::new("./make-pr.sh")
|
||||
let output = Command::new("bash")
|
||||
.current_dir(tpath("./test-srcs"))
|
||||
.arg("make-pr.sh")
|
||||
.arg(bare)
|
||||
.arg(co)
|
||||
.stderr(Stdio::null())
|
||||
|
@ -442,11 +448,12 @@ mod tests {
|
|||
worker::Action::Publish(ref body) => {
|
||||
let content = String::from_utf8(body.content.clone()).unwrap();
|
||||
let text = strip_escaped_ansi(&content);
|
||||
eprintln!("{}", text);
|
||||
if text.contains(text_to_match) {
|
||||
println!(" ok");
|
||||
return true;
|
||||
} else {
|
||||
println!(" notContains: {:?}", text);
|
||||
println!(" notContains: {}", text);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -456,8 +463,8 @@ mod tests {
|
|||
}
|
||||
})
|
||||
.expect(&format!(
|
||||
"Actions should contain a job matching {:?}, after the previous check",
|
||||
text_to_match
|
||||
"Actions should contain a job matching {}, after the previous check",
|
||||
text_to_match,
|
||||
));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue