forked from the-distro/ofborg
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 {
|
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"))
|
.current_dir(tpath("./test-srcs"))
|
||||||
|
.arg("./make-pr.sh")
|
||||||
.arg(bare)
|
.arg(bare)
|
||||||
.arg(co)
|
.arg(co)
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
|
|
|
@ -136,13 +136,19 @@ mod tests {
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::process::Stdio;
|
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 {
|
fn tpath(component: &str) -> PathBuf {
|
||||||
return Path::new(env!("CARGO_MANIFEST_DIR")).join(component);
|
return Path::new(env!("CARGO_MANIFEST_DIR")).join(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_pr_repo(bare: &Path, co: &Path) -> String {
|
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"))
|
.current_dir(tpath("./test-srcs"))
|
||||||
|
.arg("./make-maintainer-pr.sh")
|
||||||
.arg(bare)
|
.arg(bare)
|
||||||
.arg(co)
|
.arg(co)
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
|
@ -183,7 +189,7 @@ mod tests {
|
||||||
working_co.checkout_ref(&OsStr::new(&hash)).unwrap();
|
working_co.checkout_ref(&OsStr::new(&hash)).unwrap();
|
||||||
|
|
||||||
let remote = env::var("NIX_REMOTE").unwrap_or("".to_owned());
|
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 =
|
let parsed =
|
||||||
ImpactedMaintainers::calculate(&nix, &working_co.clone_to(), &paths, &attributes);
|
ImpactedMaintainers::calculate(&nix, &working_co.clone_to(), &paths, &attributes);
|
||||||
|
|
|
@ -380,9 +380,18 @@ pub fn wait_for_build_status(spawned: SpawnedAsyncCmd) -> BuildStatus {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
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 {
|
fn nix() -> Nix {
|
||||||
let remote = env::var("NIX_REMOTE").unwrap_or("".to_owned());
|
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 {
|
fn noop(operation: Operation) -> Operation {
|
||||||
|
@ -508,10 +517,6 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use super::*;
|
|
||||||
use std::env;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_build_operations() {
|
fn test_build_operations() {
|
||||||
let nix = nix();
|
let nix = nix();
|
||||||
|
@ -608,7 +613,7 @@ mod tests {
|
||||||
fn safe_command_custom_gc() {
|
fn safe_command_custom_gc() {
|
||||||
let remote = env::var("NIX_REMOTE").unwrap_or("".to_owned());
|
let remote = env::var("NIX_REMOTE").unwrap_or("".to_owned());
|
||||||
let nix = Nix::new(
|
let nix = Nix::new(
|
||||||
"x86_64-linux".to_owned(),
|
SYSTEM.to_owned(),
|
||||||
remote,
|
remote,
|
||||||
1800,
|
1800,
|
||||||
Some("4g".to_owned()),
|
Some("4g".to_owned()),
|
||||||
|
|
|
@ -391,6 +391,11 @@ mod tests {
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
use std::vec::IntoIter;
|
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 {
|
fn nix() -> nix::Nix {
|
||||||
let remote = env::var("NIX_REMOTE").unwrap_or("".to_owned());
|
let remote = env::var("NIX_REMOTE").unwrap_or("".to_owned());
|
||||||
nix::Nix::new("x86_64-linux".to_owned(), remote, 1800, None)
|
nix::Nix::new("x86_64-linux".to_owned(), remote, 1800, None)
|
||||||
|
@ -406,7 +411,7 @@ mod tests {
|
||||||
let worker = BuildWorker::new(
|
let worker = BuildWorker::new(
|
||||||
cloner,
|
cloner,
|
||||||
nix,
|
nix,
|
||||||
"x86_64-linux".to_owned(),
|
SYSTEM.to_owned(),
|
||||||
"cargo-test-build".to_owned(),
|
"cargo-test-build".to_owned(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -414,8 +419,9 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_pr_repo(bare: &Path, co: &Path) -> String {
|
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"))
|
.current_dir(tpath("./test-srcs"))
|
||||||
|
.arg("make-pr.sh")
|
||||||
.arg(bare)
|
.arg(bare)
|
||||||
.arg(co)
|
.arg(co)
|
||||||
.stderr(Stdio::null())
|
.stderr(Stdio::null())
|
||||||
|
@ -442,11 +448,12 @@ mod tests {
|
||||||
worker::Action::Publish(ref body) => {
|
worker::Action::Publish(ref body) => {
|
||||||
let content = String::from_utf8(body.content.clone()).unwrap();
|
let content = String::from_utf8(body.content.clone()).unwrap();
|
||||||
let text = strip_escaped_ansi(&content);
|
let text = strip_escaped_ansi(&content);
|
||||||
|
eprintln!("{}", text);
|
||||||
if text.contains(text_to_match) {
|
if text.contains(text_to_match) {
|
||||||
println!(" ok");
|
println!(" ok");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
println!(" notContains: {:?}", text);
|
println!(" notContains: {}", text);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -456,8 +463,8 @@ mod tests {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.expect(&format!(
|
.expect(&format!(
|
||||||
"Actions should contain a job matching {:?}, after the previous check",
|
"Actions should contain a job matching {}, after the previous check",
|
||||||
text_to_match
|
text_to_match,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue