Skip to content

Commit fa31c7d

Browse files
committed
Pull out recursive ui test check into its own function
1 parent a97d0aa commit fa31c7d

File tree

1 file changed

+37
-28
lines changed

1 file changed

+37
-28
lines changed

src/tools/tidy/src/ui_tests.rs

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -40,34 +40,7 @@ pub fn check(root_path: &Path, bless: bool, bad: &mut bool) {
4040
);
4141
}
4242

43-
let mut remaining_issue_names: BTreeSet<&str> = allowed_issue_names.clone();
44-
45-
let (ui, ui_fulldeps) = (path.join("ui"), path.join("ui-fulldeps"));
46-
let paths = [ui.as_path(), ui_fulldeps.as_path()];
47-
crate::walk::walk_no_read(&paths, |_, _| false, &mut |entry| {
48-
let file_path = entry.path();
49-
if let Some(ext) = file_path.extension().and_then(OsStr::to_str) {
50-
check_unexpected_extension(bad, file_path, ext);
51-
52-
// NB: We do not use file_stem() as some file names have multiple `.`s and we
53-
// must strip all of them.
54-
let testname =
55-
file_path.file_name().unwrap().to_str().unwrap().split_once('.').unwrap().0;
56-
if ext == "stderr" || ext == "stdout" || ext == "fixed" {
57-
check_stray_output_snapshot(bad, file_path, testname);
58-
check_empty_output_snapshot(bad, file_path);
59-
}
60-
61-
deny_new_nondescriptive_test_names(
62-
bad,
63-
path,
64-
&mut remaining_issue_names,
65-
file_path,
66-
testname,
67-
ext,
68-
);
69-
}
70-
});
43+
let remaining_issue_names = recursively_check_ui_tests(bad, path, &allowed_issue_names);
7144

7245
// if there are any file names remaining, they were moved on the fs.
7346
// our data must remain up to date, so it must be removed from issues.txt
@@ -98,6 +71,42 @@ pub fn check(root_path: &Path, bless: bool, bad: &mut bool) {
9871
}
9972
}
10073

74+
fn recursively_check_ui_tests<'issues>(
75+
bad: &mut bool,
76+
path: &Path,
77+
allowed_issue_names: &'issues BTreeSet<&'issues str>,
78+
) -> BTreeSet<&'issues str> {
79+
let mut remaining_issue_names: BTreeSet<&str> = allowed_issue_names.clone();
80+
81+
let (ui, ui_fulldeps) = (path.join("ui"), path.join("ui-fulldeps"));
82+
let paths = [ui.as_path(), ui_fulldeps.as_path()];
83+
crate::walk::walk_no_read(&paths, |_, _| false, &mut |entry| {
84+
let file_path = entry.path();
85+
if let Some(ext) = file_path.extension().and_then(OsStr::to_str) {
86+
check_unexpected_extension(bad, file_path, ext);
87+
88+
// NB: We do not use file_stem() as some file names have multiple `.`s and we
89+
// must strip all of them.
90+
let testname =
91+
file_path.file_name().unwrap().to_str().unwrap().split_once('.').unwrap().0;
92+
if ext == "stderr" || ext == "stdout" || ext == "fixed" {
93+
check_stray_output_snapshot(bad, file_path, testname);
94+
check_empty_output_snapshot(bad, file_path);
95+
}
96+
97+
deny_new_nondescriptive_test_names(
98+
bad,
99+
path,
100+
&mut remaining_issue_names,
101+
file_path,
102+
testname,
103+
ext,
104+
);
105+
}
106+
});
107+
remaining_issue_names
108+
}
109+
101110
fn check_unexpected_extension(bad: &mut bool, file_path: &Path, ext: &str) {
102111
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
103112
"rs", // test source files

0 commit comments

Comments
 (0)