Skip to content

Commit 0b1547e

Browse files
committed
Reject adding new UI tests directly under tests/ui/
As we want future UI tests to be added under a more meaningful subdirectory instead.
1 parent fa31c7d commit 0b1547e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/tools/tidy/src/ui_tests.rs

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

43+
deny_new_top_level_ui_tests(bad, &path.join("ui"));
44+
4345
let remaining_issue_names = recursively_check_ui_tests(bad, path, &allowed_issue_names);
4446

4547
// if there are any file names remaining, they were moved on the fs.
@@ -71,6 +73,34 @@ pub fn check(root_path: &Path, bless: bool, bad: &mut bool) {
7173
}
7274
}
7375

76+
fn deny_new_top_level_ui_tests(bad: &mut bool, tests_path: &Path) {
77+
// See <https://github.com/rust-lang/compiler-team/issues/902> where we propose banning adding
78+
// new ui tests *directly* under `tests/ui/`. For more context, see:
79+
//
80+
// - <https://github.com/rust-lang/rust/issues/73494>
81+
// - <https://github.com/rust-lang/rust/issues/133895>
82+
83+
let top_level_ui_tests = walkdir::WalkDir::new(tests_path)
84+
.min_depth(1)
85+
.max_depth(1)
86+
.follow_links(false)
87+
.same_file_system(true)
88+
.into_iter()
89+
.flatten()
90+
.filter(|e| {
91+
let file_name = e.file_name();
92+
file_name != ".gitattributes" && file_name != "README.md"
93+
})
94+
.filter(|e| !e.file_type().is_dir());
95+
for entry in top_level_ui_tests {
96+
tidy_error!(
97+
bad,
98+
"ui tests should be added under meaningful subdirectories: `{}`",
99+
entry.path().display()
100+
)
101+
}
102+
}
103+
74104
fn recursively_check_ui_tests<'issues>(
75105
bad: &mut bool,
76106
path: &Path,

0 commit comments

Comments
 (0)