diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2022-01-07 10:11:54 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-07 10:11:54 -0500 |
commit | 03548a847f9aff8b1c7824d0e3e3e5b523e101a7 (patch) | |
tree | c87e83737caf6023ec98ba80350361ad09ec45b9 | |
parent | 72895675efa5842a4fe9049dfbad5736d1bf23a1 (diff) | |
parent | 06cd391845c0039dc70bd8dd972bdaf36b454872 (diff) |
Merge pull request #937 from tmccombs/less-flaky-tests
Less flaky tests
-rw-r--r-- | tests/testenv/mod.rs | 21 | ||||
-rw-r--r-- | tests/tests.rs | 4 |
2 files changed, 16 insertions, 9 deletions
diff --git a/tests/testenv/mod.rs b/tests/testenv/mod.rs index cc439bc..510a7b2 100644 --- a/tests/testenv/mod.rs +++ b/tests/testenv/mod.rs @@ -203,6 +203,19 @@ impl TestEnv { output } + pub fn assert_success_and_get_normalized_output<P: AsRef<Path>>( + &self, + path: P, + args: &[&str], + ) -> String { + let output = self.assert_success_and_get_output(path, args); + normalize_output( + &String::from_utf8_lossy(&output.stdout), + false, + self.normalize_line, + ) + } + /// Assert that calling *fd* with the specified arguments produces the expected output. pub fn assert_output(&self, args: &[&str], expected: &str) { self.assert_output_subdirectory(".", args, expected) @@ -224,15 +237,9 @@ impl TestEnv { args: &[&str], expected: &str, ) { - let output = self.assert_success_and_get_output(path, args); - // Normalize both expected and actual output. let expected = normalize_output(expected, true, self.normalize_line); - let actual = normalize_output( - &String::from_utf8_lossy(&output.stdout), - false, - self.normalize_line, - ); + let actual = self.assert_success_and_get_normalized_output(path, args); // Compare actual output to expected output. if expected != actual { diff --git a/tests/tests.rs b/tests/tests.rs index e6cee6c..fb0535c 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -1970,8 +1970,8 @@ fn test_opposing(flag: &str, opposing_flags: &[&str]) { let mut flags = vec![flag]; flags.extend_from_slice(opposing_flags); - let out_no_flags = te.assert_success_and_get_output(".", &[]); - let out_opposing_flags = te.assert_success_and_get_output(".", &flags); + let out_no_flags = te.assert_success_and_get_normalized_output(".", &[]); + let out_opposing_flags = te.assert_success_and_get_normalized_output(".", &flags); assert_eq!( out_no_flags, |