Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Reject adding new UI tests directly under tests/ui/
As we want future UI tests to be added under a more meaningful
subdirectory instead.
  • Loading branch information
jieyouxu committed Aug 2, 2025
commit 0b1547e9c052b29d246a8e5cb3d6408407e88dab
30 changes: 30 additions & 0 deletions src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pub fn check(root_path: &Path, bless: bool, bad: &mut bool) {
);
}

deny_new_top_level_ui_tests(bad, &path.join("ui"));

let remaining_issue_names = recursively_check_ui_tests(bad, path, &allowed_issue_names);

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

fn deny_new_top_level_ui_tests(bad: &mut bool, tests_path: &Path) {
// See <https://github.com/rust-lang/compiler-team/issues/902> where we propose banning adding
// new ui tests *directly* under `tests/ui/`. For more context, see:
//
// - <https://github.com/rust-lang/rust/issues/73494>
// - <https://github.com/rust-lang/rust/issues/133895>

let top_level_ui_tests = walkdir::WalkDir::new(tests_path)
.min_depth(1)
.max_depth(1)
.follow_links(false)
.same_file_system(true)
.into_iter()
.flatten()
.filter(|e| {
let file_name = e.file_name();
file_name != ".gitattributes" && file_name != "README.md"
})
.filter(|e| !e.file_type().is_dir());
for entry in top_level_ui_tests {
tidy_error!(
bad,
"ui tests should be added under meaningful subdirectories: `{}`",
entry.path().display()
)
}
}

fn recursively_check_ui_tests<'issues>(
bad: &mut bool,
path: &Path,
Expand Down
Loading