Skip to content

Commit d98cce1

Browse files
committed
Make mir opt unused file check blessable
1 parent 6718ea1 commit d98cce1

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/tools/tidy/src/mir_opt_tests.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::collections::HashSet;
44
use std::path::{Path, PathBuf};
55

6-
fn check_unused_files(path: &Path, bad: &mut bool) {
6+
fn check_unused_files(path: &Path, bless: bool, bad: &mut bool) {
77
let mut rs_files = Vec::<PathBuf>::new();
88
let mut output_files = HashSet::<PathBuf>::new();
99
let files = walkdir::WalkDir::new(&path.join("test/mir-opt")).into_iter();
@@ -27,11 +27,15 @@ fn check_unused_files(path: &Path, bad: &mut bool) {
2727

2828
for extra in output_files {
2929
if extra.file_name() != Some("README.md".as_ref()) {
30-
tidy_error!(
31-
bad,
32-
"the following output file is not associated with any mir-opt test, you can remove it: {}",
33-
extra.display()
34-
);
30+
if !bless {
31+
tidy_error!(
32+
bad,
33+
"the following output file is not associated with any mir-opt test, you can remove it: {}",
34+
extra.display()
35+
);
36+
} else {
37+
let _ = std::fs::remove_file(extra);
38+
}
3539
}
3640
}
3741
}
@@ -65,6 +69,6 @@ fn check_dash_files(path: &Path, bless: bool, bad: &mut bool) {
6569
}
6670

6771
pub fn check(path: &Path, bless: bool, bad: &mut bool) {
68-
check_unused_files(path, bad);
72+
check_unused_files(path, bless, bad);
6973
check_dash_files(path, bless, bad);
7074
}

0 commit comments

Comments
 (0)