diff --git a/tests/specs/publish/npm_workspace/publish.out b/tests/specs/publish/npm_workspace/publish.out index 21c91ae191..25f81a7e9e 100644 --- a/tests/specs/publish/npm_workspace/publish.out +++ b/tests/specs/publish/npm_workspace/publish.out @@ -4,6 +4,7 @@ Check file:///[WILDLINE]/npm_workspace/subtract/index.ts Checking for slow types in the public API... Check file:///[WILDLINE]/npm_workspace/add/index.ts Check file:///[WILDLINE]/npm_workspace/subtract/index.ts +[UNORDERED_START] Simulating publish of @scope/add@1.0.0 with files: file:///[WILDLINE]/npm_workspace/add/index.ts ([WILDLINE]) file:///[WILDLINE]/npm_workspace/add/jsr.json ([WILDLINE]) @@ -12,4 +13,5 @@ Simulating publish of @scope/subtract@1.0.0 with files: file:///[WILDLINE]/npm_workspace/subtract/index.ts ([WILDLINE]) file:///[WILDLINE]/npm_workspace/subtract/jsr.json ([WILDLINE]) file:///[WILDLINE]/npm_workspace/subtract/package.json ([WILDLINE]) +[UNORDERED_END] Warning Aborting due to --dry-run diff --git a/tests/util/server/src/lib.rs b/tests/util/server/src/lib.rs index d23fde0ddf..f09e7c2249 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 { - 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)) - )); - return WildcardMatchResult::Fail(output_lines.join("\n")); - } else { + 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!( "{}", 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_line)) + )); + for expected in expected_lines { + output_lines.push(format!( + " EXPECTED ANY: {}", + colors::green(annotate_whitespace(expected)) + )); + } + return WildcardMatchResult::Fail(output_lines.join("\n")); } } }