From 6adddcf9e96d18700fbddccc86b1e3c4e2099e93 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Wed, 1 Jan 2020 23:07:25 +0000 Subject: [PATCH] tests ~ fix CICD 'linux' test variations (whitespace variations) --- tests/test_pinky.rs | 28 +++++++++++++++++++++++----- tests/test_who.rs | 10 +++++++++- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/tests/test_pinky.rs b/tests/test_pinky.rs index 377abe74d..45c1ccc0a 100644 --- a/tests/test_pinky.rs +++ b/tests/test_pinky.rs @@ -36,14 +36,32 @@ fn test_long_format() { #[cfg(target_os = "linux")] #[test] -fn test_short_format() { - let scene = TestScenario::new(util_name!()); - +fn test_short_format_i() { + // allow whitespace variation + // * minor whitespace differences occur between platform built-in outputs; specifically, the number of trailing TABs may be variant let args = ["-i"]; - scene.ucmd().args(&args).run().stdout_is(expected_result(&args)); + let actual = TestScenario::new(util_name!()).ucmd().args(&args).run().stdout; + let expect = expected_result(&args); + println!("actual: {:?}", actual); + println!("expect: {:?}", expect); + let v_actual: Vec<&str> = actual.split_whitespace().collect(); + let v_expect: Vec<&str> = expect.split_whitespace().collect(); + assert_eq!(v_actual, v_expect); +} +#[cfg(target_os = "linux")] +#[test] +fn test_short_format_q() { + // allow whitespace variation + // * minor whitespace differences occur between platform built-in outputs; specifically, the number of trailing TABs may be variant let args = ["-q"]; - scene.ucmd().args(&args).run().stdout_is(expected_result(&args)); + let actual = TestScenario::new(util_name!()).ucmd().args(&args).run().stdout; + let expect = expected_result(&args); + println!("actual: {:?}", actual); + println!("expect: {:?}", expect); + let v_actual: Vec<&str> = actual.split_whitespace().collect(); + let v_expect: Vec<&str> = expect.split_whitespace().collect(); + assert_eq!(v_actual, v_expect); } #[cfg(target_os = "linux")] diff --git a/tests/test_who.rs b/tests/test_who.rs index 539b3fe9c..32f5230a0 100644 --- a/tests/test_who.rs +++ b/tests/test_who.rs @@ -22,7 +22,15 @@ fn test_boot() { #[test] fn test_heading() { for opt in vec!["-H"] { - new_ucmd!().arg(opt).run().stdout_is(expected_result(opt)); + // allow whitespace variation + // * minor whitespace differences occur between platform built-in outputs; specfically number of TABs between "TIME" and "COMMENT" may be variant + let actual = new_ucmd!().arg(opt).run().stdout; + let expect = expected_result(opt); + println!("actual: {:?}", actual); + println!("expect: {:?}", expect); + let v_actual: Vec<&str> = actual.split_whitespace().collect(); + let v_expect: Vec<&str> = expect.split_whitespace().collect(); + assert_eq!(v_actual, v_expect); } }