commit
d39605727d
|
@ -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,21 @@ 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 path = env::var("PATH").unwrap();
|
||||
let test_path = format!("{}/test-nix/bin:{}", env!("CARGO_MANIFEST_DIR"), path);
|
||||
env::set_var("PATH", test_path);
|
||||
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 +520,6 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
use super::*;
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[test]
|
||||
fn test_build_operations() {
|
||||
let nix = nix();
|
||||
|
@ -607,12 +615,7 @@ mod tests {
|
|||
#[test]
|
||||
fn safe_command_custom_gc() {
|
||||
let remote = env::var("NIX_REMOTE").unwrap_or("".to_owned());
|
||||
let nix = Nix::new(
|
||||
"x86_64-linux".to_owned(),
|
||||
remote,
|
||||
1800,
|
||||
Some("4g".to_owned()),
|
||||
);
|
||||
let nix = Nix::new(SYSTEM.to_owned(), remote, 1800, Some("4g".to_owned()));
|
||||
|
||||
let ret: Result<fs::File, fs::File> = nix.run(
|
||||
nix.safe_command::<&OsStr>(&env_noop(), build_path().as_path(), &[], &[]),
|
||||
|
@ -752,10 +755,12 @@ mod tests {
|
|||
"trace: You just can't frooble the frozz on this particular system."
|
||||
);
|
||||
|
||||
eprintln!("{:?}", ret.1[1].1);
|
||||
assert_eq!(ret.1[1].0, "missing-attr");
|
||||
let s = strip_ansi(&ret.1[1].1.last().unwrap());
|
||||
assert_eq!(
|
||||
strip_ansi(&ret.1[1].1[0]),
|
||||
"error: attribute 'missing-attr' in selection path 'missing-attr' not found"
|
||||
s.trim_start_matches("error: "),
|
||||
"attribute 'missing-attr' in selection path 'missing-attr' not found"
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -817,11 +822,7 @@ mod tests {
|
|||
assert_run(
|
||||
ret,
|
||||
Expect::Fail,
|
||||
vec![
|
||||
"error: while evaluating the attribute",
|
||||
"access to path",
|
||||
"is forbidden in restricted mode",
|
||||
],
|
||||
vec!["access to path", "is forbidden in restricted mode"],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -544,7 +551,10 @@ mod tests {
|
|||
&mut actions,
|
||||
"\"line_number\":1,\"output\":\"Cannot nix-instantiate `not-real\' because:\"",
|
||||
);
|
||||
assert_contains_job(&mut actions, "\"line_number\":2,\"output\":\"error: attribute 'not-real' in selection path 'not-real' not found\"}");
|
||||
assert_contains_job(
|
||||
&mut actions,
|
||||
"attribute 'not-real' in selection path 'not-real' not found\"}",
|
||||
);
|
||||
assert_contains_job(&mut actions, "skipped_attrs\":[\"not-real"); // First one to the github poster
|
||||
assert_contains_job(&mut actions, "skipped_attrs\":[\"not-real"); // This one to the logs
|
||||
assert_eq!(actions.next(), Some(worker::Action::Ack));
|
||||
|
|
4
ofborg/test-nix/bin/nix-build
Executable file
4
ofborg/test-nix/bin/nix-build
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
export PATH=${PATH#*:}
|
||||
exec nix-build "$@" -I "ofborg-test-bash=$(command -v bash)"
|
4
ofborg/test-nix/bin/nix-instantiate
Executable file
4
ofborg/test-nix/bin/nix-instantiate
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
export PATH=${PATH#*:}
|
||||
exec nix-instantiate "$@" -I "ofborg-test-bash=$(command -v bash)"
|
|
@ -1,27 +1,26 @@
|
|||
let
|
||||
nix = import <nix/config.nix>;
|
||||
in {
|
||||
builder = builtins.storePath <ofborg-test-bash>;
|
||||
in
|
||||
{
|
||||
success = derivation {
|
||||
name = "success";
|
||||
system = builtins.currentSystem;
|
||||
builder = builtins.storePath nix.shell;
|
||||
args = [
|
||||
"-c"
|
||||
"echo hi; printf '1\n2\n3\n4\n'; echo ${toString builtins.currentTime} > $out" ];
|
||||
inherit builder;
|
||||
args = [ "-c" "echo hi; printf '1\n2\n3\n4\n'; echo ${toString builtins.currentTime} > $out" ];
|
||||
};
|
||||
|
||||
failed = derivation {
|
||||
name = "failed";
|
||||
system = builtins.currentSystem;
|
||||
builder = builtins.storePath nix.shell;
|
||||
args = [
|
||||
"-c"
|
||||
"echo hi; echo ${toString builtins.currentTime}" ];
|
||||
inherit builder;
|
||||
args = [ "-c" "echo hi; echo ${toString builtins.currentTime}" ];
|
||||
};
|
||||
|
||||
sandbox-violation = derivation {
|
||||
name = "sandbox-violation";
|
||||
system = builtins.currentSystem;
|
||||
builder = ./../../src;
|
||||
inherit builder;
|
||||
args = [ "-c" "echo hi; echo ${toString builtins.currentTime} > $out" ];
|
||||
src = ./../../src;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,27 +1,26 @@
|
|||
let
|
||||
nix = import <nix/config.nix>;
|
||||
in {
|
||||
builder = builtins.storePath <ofborg-test-bash>;
|
||||
in
|
||||
{
|
||||
success = derivation {
|
||||
name = "success";
|
||||
system = builtins.currentSystem;
|
||||
builder = builtins.storePath nix.shell;
|
||||
args = [
|
||||
"-c"
|
||||
"echo hi; echo ${toString builtins.currentTime} > $out" ];
|
||||
inherit builder;
|
||||
args = [ "-c" "echo hi; echo ${toString builtins.currentTime} > $out" ];
|
||||
};
|
||||
|
||||
failed = derivation {
|
||||
name = "failed";
|
||||
system = builtins.currentSystem;
|
||||
builder = builtins.storePath nix.shell;
|
||||
args = [
|
||||
"-c"
|
||||
"echo hi; echo ${toString builtins.currentTime}" ];
|
||||
inherit builder;
|
||||
args = [ "-c" "echo hi; echo ${toString builtins.currentTime}" ];
|
||||
};
|
||||
|
||||
sandbox-violation = derivation {
|
||||
name = "sandbox-violation";
|
||||
system = builtins.currentSystem;
|
||||
builder = ./../../src;
|
||||
src = ./../../src;
|
||||
inherit builder;
|
||||
args = [ "-c" "echo hi; echo ${toString builtins.currentTime} > $out" ];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,51 +1,44 @@
|
|||
let
|
||||
fetchGit = builtins.fetchGit or (path: assert builtins.trace ''
|
||||
error: access to path '/fake' is forbidden in restricted mode
|
||||
'' false; path);
|
||||
''
|
||||
false; path);
|
||||
|
||||
nix = import <nix/config.nix>;
|
||||
builder = builtins.storePath <ofborg-test-bash>;
|
||||
in
|
||||
|
||||
{ nixpkgs ? fetchGit /fake }:
|
||||
|
||||
rec {
|
||||
success = derivation {
|
||||
name = "success";
|
||||
system = builtins.currentSystem;
|
||||
builder = builtins.storePath nix.shell;
|
||||
args = [
|
||||
"-c"
|
||||
"echo hi; echo ${toString builtins.currentTime} > $out" ];
|
||||
inherit builder;
|
||||
args = [ "-c" "echo hi; echo ${toString builtins.currentTime} > $out" ];
|
||||
};
|
||||
|
||||
failed = derivation {
|
||||
name = "failed";
|
||||
system = builtins.currentSystem;
|
||||
builder = builtins.storePath nix.shell;
|
||||
args = [
|
||||
"-c"
|
||||
"echo hi; echo ${toString builtins.currentTime}; echo ${success}" ];
|
||||
inherit builder;
|
||||
args = [ "-c" "echo hi; echo ${toString builtins.currentTime}; echo ${success}" ];
|
||||
};
|
||||
|
||||
passes-instantiation = derivation {
|
||||
name = "passes-instantiation";
|
||||
system = builtins.currentSystem;
|
||||
builder = builtins.storePath nix.shell;
|
||||
args = [
|
||||
"-c"
|
||||
"echo this ones cool" ];
|
||||
inherit builder;
|
||||
args = [ "-c" "echo this ones cool" ];
|
||||
};
|
||||
|
||||
nixpkgs-restricted-mode = derivation {
|
||||
name = "nixpkgs-restricted-mode-fetchgit";
|
||||
system = builtins.currentSystem;
|
||||
builder = nix.shell;
|
||||
args = [
|
||||
"-c"
|
||||
"echo hi; echo ${toString nixpkgs} > $out" ];
|
||||
inherit builder;
|
||||
args = [ "-c" "echo hi; echo ${toString nixpkgs} > $out" ];
|
||||
};
|
||||
|
||||
fails-instantiation = assert builtins.trace ''
|
||||
You just can't frooble the frozz on this particular system.
|
||||
'' false; {};
|
||||
''
|
||||
false; { };
|
||||
}
|
||||
|
|
|
@ -1,21 +1,18 @@
|
|||
let
|
||||
nix = import <nix/config.nix>;
|
||||
in rec {
|
||||
builder = builtins.storePath <ofborg-test-bash>;
|
||||
in
|
||||
rec {
|
||||
success = derivation {
|
||||
name = "success";
|
||||
system = builtins.currentSystem;
|
||||
builder = builtins.storePath nix.shell;
|
||||
args = [
|
||||
"-c"
|
||||
"echo hi; echo ${toString builtins.currentTime} > $out" ];
|
||||
inherit builder;
|
||||
args = [ "-c" "echo hi; echo ${toString builtins.currentTime} > $out" ];
|
||||
};
|
||||
|
||||
failed = derivation {
|
||||
name = "failed";
|
||||
system = builtins.currentSystem;
|
||||
builder = builtins.storePath nix.shell;
|
||||
args = [
|
||||
"-c"
|
||||
"echo hi; echo ${toString builtins.currentTime}; echo ${success}" ];
|
||||
inherit builder;
|
||||
args = [ "-c" "echo hi; echo ${toString builtins.currentTime}; echo ${success}" ];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{ ... }:
|
||||
{
|
||||
lib = import ./lib;
|
||||
foo.bar.packageA = {
|
||||
};
|
||||
foo.bar.packageA = { };
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue