Skip to content

Commit 4f61ce2

Browse files
authored
Rollup merge of #109323 - joboet:ignore_ds_store_tidy, r=ozkanonur
Ignore files in .gitignore in mir opt check This caused `./x test tidy` to fail for me when Finder (macOS) added `.DS_Store` files. They are ignored by git, so tidy should ignore them, too.
2 parents 7c69f98 + 500ad26 commit 4f61ce2

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

src/tools/tidy/src/mir_opt_tests.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,24 @@
33
use std::collections::HashSet;
44
use std::path::{Path, PathBuf};
55

6+
use crate::walk::walk_no_read;
7+
68
fn check_unused_files(path: &Path, bless: bool, bad: &mut bool) {
79
let mut rs_files = Vec::<PathBuf>::new();
810
let mut output_files = HashSet::<PathBuf>::new();
9-
let files = walkdir::WalkDir::new(&path.join("mir-opt")).into_iter();
1011

11-
for file in files.filter_map(Result::ok).filter(|e| e.file_type().is_file()) {
12-
let filepath = file.path();
13-
if filepath.extension() == Some("rs".as_ref()) {
14-
rs_files.push(filepath.to_owned());
15-
} else {
16-
output_files.insert(filepath.to_owned());
17-
}
18-
}
12+
walk_no_read(
13+
&[&path.join("mir-opt")],
14+
|path| path.file_name() == Some("README.md".as_ref()),
15+
&mut |file| {
16+
let filepath = file.path();
17+
if filepath.extension() == Some("rs".as_ref()) {
18+
rs_files.push(filepath.to_owned());
19+
} else {
20+
output_files.insert(filepath.to_owned());
21+
}
22+
},
23+
);
1924

2025
for file in rs_files {
2126
for bw in [32, 64] {
@@ -26,16 +31,14 @@ fn check_unused_files(path: &Path, bless: bool, bad: &mut bool) {
2631
}
2732

2833
for extra in output_files {
29-
if extra.file_name() != Some("README.md".as_ref()) {
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-
}
34+
if !bless {
35+
tidy_error!(
36+
bad,
37+
"the following output file is not associated with any mir-opt test, you can remove it: {}",
38+
extra.display()
39+
);
40+
} else {
41+
let _ = std::fs::remove_file(extra);
3942
}
4043
}
4144
}

0 commit comments

Comments
 (0)