Merge pull request #937 from tmccombs/less-flaky-tests

Less flaky tests
This commit is contained in:
Tavian Barnes 2022-01-07 10:11:54 -05:00 committed by GitHub
commit 03548a847f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 9 deletions

View File

@ -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 {

View File

@ -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,