Skip to content

Commit 070b035

Browse files
committed
Improve error if rustfix coverage test spuriously fails
1 parent 318ed05 commit 070b035

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tests/compile-test.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,19 +413,21 @@ fn check_rustfix_coverage() {
413413
if let Ok(missing_coverage_contents) = std::fs::read_to_string(missing_coverage_path) {
414414
assert!(RUSTFIX_COVERAGE_KNOWN_EXCEPTIONS.iter().is_sorted_by_key(Path::new));
415415

416-
for rs_path in missing_coverage_contents.lines() {
417-
if Path::new(rs_path).starts_with("tests/ui/crashes") {
416+
for rs_file in missing_coverage_contents.lines() {
417+
let rs_path = Path::new(rs_file);
418+
if rs_path.starts_with("tests/ui/crashes") {
418419
continue;
419420
}
420-
let filename = Path::new(rs_path).strip_prefix("tests/ui/").unwrap();
421+
assert!(rs_path.starts_with("tests/ui/"), "{:?}", rs_file);
422+
let filename = rs_path.strip_prefix("tests/ui/").unwrap();
421423
assert!(
422424
RUSTFIX_COVERAGE_KNOWN_EXCEPTIONS
423425
.binary_search_by_key(&filename, Path::new)
424426
.is_ok(),
425427
"`{}` runs `MachineApplicable` diagnostics but is missing a `run-rustfix` annotation. \
426428
Please either add `// run-rustfix` at the top of the file or add the file to \
427429
`RUSTFIX_COVERAGE_KNOWN_EXCEPTIONS` in `tests/compile-test.rs`.",
428-
rs_path,
430+
rs_file,
429431
);
430432
}
431433
}

0 commit comments

Comments
 (0)