Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/ofborg
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 79d8023a8727
Choose a base ref
...
head repository: NixOS/ofborg
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: bfa6af69291f
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on Apr 10, 2018

  1. fix nix tests with nix 2.0

    LnL7 committed Apr 10, 2018
    Copy the full SHA
    5b54989 View commit details
  2. fix build tests with nix 2.0

    LnL7 committed Apr 10, 2018
    Copy the full SHA
    1ef2b3c View commit details
  3. Merge pull request #153 from LnL7/nix-test-ansi

    fix tests with nix 2.0
    grahamc authored Apr 10, 2018
    Copy the full SHA
    bfa6af6 View commit details
Showing with 27 additions and 11 deletions.
  1. +11 −3 ofborg/src/nix.rs
  2. +16 −8 ofborg/src/tasks/build.rs
14 changes: 11 additions & 3 deletions ofborg/src/nix.rs
Original file line number Diff line number Diff line change
@@ -304,6 +304,14 @@ mod tests {
return cwd;
}

fn strip_ansi(string: &str) -> String {
string
.replace("‘", "'")
.replace("’", "'")
.replace("\u{1b}[31;1m", "") // red
.replace("\u{1b}[0m", "") // reset
}

#[derive(Debug)]
enum Expect {
Pass,
@@ -325,7 +333,7 @@ mod tests {

let buildlog = lines
.into_iter()
.map(|line| line.replace("\u{1b}[0m", "")) // ANSI reset
.map(|line| strip_ansi(&line))
.map(|line| format!(" | {}", line))
.collect::<Vec<String>>()
.join("\n");
@@ -588,10 +596,10 @@ mod tests {
assert_eq!(ret.0, vec!["passes-instantiation"]);

assert_eq!(ret.1[0].0, "fails-instantiation");
assert_eq!(ret.1[0].1[0], "trace: You just can\'t frooble the frozz on this particular system.");
assert_eq!(ret.1[0].1[0], "trace: You just can't frooble the frozz on this particular system.");

assert_eq!(ret.1[1].0, "missing-attr");
assert_eq!(ret.1[1].1[0], "error: attribute missing-attr in selection path missing-attr not found");
assert_eq!(strip_ansi(&ret.1[1].1[0]), "error: attribute 'missing-attr' in selection path 'missing-attr' not found");
}

#[test]
24 changes: 16 additions & 8 deletions ofborg/src/tasks/build.rs
Original file line number Diff line number Diff line change
@@ -397,7 +397,6 @@ impl notifyworker::SimpleNotifyWorker for BuildWorker {
}
}


#[cfg(test)]
mod tests {
use super::*;
@@ -442,22 +441,31 @@ mod tests {
return hash.trim().to_owned();
}

fn strip_escaped_ansi(string: &str) -> String {
string
.replace("‘", "'")
.replace("’", "'")
.replace("\\u001b[31;1m", "") // red
.replace("\\u001b[0m", "") // reset
}

fn assert_contains_job(actions: &mut IntoIter<worker::Action>, text_to_match: &str) {
println!("\n\nSearching for {:?}", text_to_match);
println!("\n\n Searching: {:?}", text_to_match);
actions
.position(|job| match job {
worker::Action::Publish(ref body) => {
let mystr = String::from_utf8(body.content.clone()).unwrap();
if mystr.contains(text_to_match) {
println!(" Matched: {:?}", mystr);
let content = String::from_utf8(body.content.clone()).unwrap();
let text = strip_escaped_ansi(&content);
if text.contains(text_to_match) {
println!(" ok");
return true;
} else {
println!(" miss: {:?}", mystr);
println!(" notContains: {:?}", text);
return false;
}
}
e => {
println!(" notPublish: {:?}", e);
println!(" notPublish: {:?}", e);
return false;
}
})
@@ -554,7 +562,7 @@ mod tests {
println!("Total actions: {:?}", dummyreceiver.actions.len());
let mut actions = dummyreceiver.actions.into_iter();
assert_contains_job(&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, "\"line_number\":2,\"output\":\"error: 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));