diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-07-10 16:44:37 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-10 20:44:37 +0000 |
commit | ad8d265e29e66e04082bc5d4bf6f68130ac8f6d6 (patch) | |
tree | d7c224318ee0f33e03fdd9095f8f9e3fdf291eec /tests/util/server/src/lib.rs | |
parent | a49d0bd10ba2a4745c291f3f413d97396213e4ec (diff) |
chore: fix flaky publish::npm_workspace test (#24511)
Diffstat (limited to 'tests/util/server/src/lib.rs')
-rw-r--r-- | tests/util/server/src/lib.rs | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/tests/util/server/src/lib.rs b/tests/util/server/src/lib.rs index d23fde0dd..f09e7c224 100644 --- a/tests/util/server/src/lib.rs +++ b/tests/util/server/src/lib.rs @@ -846,25 +846,45 @@ pub fn wildcard_match_detailed( ); return WildcardMatchResult::Fail(output_lines.join("\n")); } - for (actual, expected) in actual_lines.iter().zip(expected_lines.iter()) + + if let Some(invalid_expected) = + expected_lines.iter().find(|e| e.contains("[WILDCARD]")) { - if actual != expected { + panic!( + concat!( + "Cannot use [WILDCARD] inside [UNORDERED_START]. Use [WILDLINE] instead.\n", + " Invalid expected line: {}" + ), + invalid_expected + ); + } + + for actual_line in actual_lines { + let maybe_found_index = + expected_lines.iter().position(|expected_line| { + actual_line == *expected_line + || wildcard_match(expected_line, actual_line) + }); + if let Some(found_index) = maybe_found_index { + let expected = expected_lines.remove(found_index); + output_lines.push(format!( + "<FOUND>{}</FOUND>", + colors::gray(annotate_whitespace(expected)) + )); + } else { output_lines .push("==== UNORDERED LINE DID NOT MATCH ====".to_string()); output_lines.push(format!( " ACTUAL: {}", - colors::red(annotate_whitespace(actual)) - )); - output_lines.push(format!( - "EXPECTED: {}", - colors::green(annotate_whitespace(expected)) + colors::red(annotate_whitespace(actual_line)) )); + for expected in expected_lines { + output_lines.push(format!( + " EXPECTED ANY: {}", + colors::green(annotate_whitespace(expected)) + )); + } return WildcardMatchResult::Fail(output_lines.join("\n")); - } else { - output_lines.push(format!( - "<FOUND>{}</FOUND>", - colors::gray(annotate_whitespace(expected)) - )); } } } |