Skip to content

Commit 48cb816

Browse files
committed
Handle CARGO_TARGET_DIR not being set in compile-test
1 parent 18c6818 commit 48cb816

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tests/compile-test.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,12 @@ const RUSTFIX_COVERAGE_KNOWN_EXCEPTIONS: &[&str] = &[
403403
];
404404

405405
fn check_rustfix_coverage() {
406-
let target_dir = PathBuf::from(std::env::var("CARGO_TARGET_DIR").unwrap());
407-
let missing_coverage_path = target_dir.join("debug/test/ui/rustfix_missing_coverage.txt");
406+
let missing_coverage_path = Path::new("debug/test/ui/rustfix_missing_coverage.txt");
407+
let missing_coverage_path = if let Ok(target_dir) = std::env::var("CARGO_TARGET_DIR") {
408+
PathBuf::from(target_dir).join(missing_coverage_path)
409+
} else {
410+
missing_coverage_path.to_path_buf()
411+
};
408412

409413
if let Ok(missing_coverage_contents) = std::fs::read_to_string(missing_coverage_path) {
410414
assert!(RUSTFIX_COVERAGE_KNOWN_EXCEPTIONS.iter().is_sorted_by_key(Path::new));

0 commit comments

Comments
 (0)