From 5b5498955a251dc76e5c92a952bde073504795dc Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Wed, 4 Apr 2018 00:00:54 +0200 Subject: [PATCH] fix nix tests with nix 2.0 --- ofborg/src/nix.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ofborg/src/nix.rs b/ofborg/src/nix.rs index 91b78a2..0f2e890 100644 --- a/ofborg/src/nix.rs +++ b/ofborg/src/nix.rs @@ -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::>() .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]