Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tidy: Issue an error when UI test limits are too high #110241

Merged
merged 1 commit into from
Apr 12, 2023
Merged
Changes from all commits
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
28 changes: 22 additions & 6 deletions src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::path::{Path, PathBuf};

// FIXME: The following limits should be reduced eventually.
const ENTRY_LIMIT: usize = 885;
const ROOT_ENTRY_LIMIT: usize = 881;
const ROOT_ENTRY_LIMIT: usize = 880;
const ISSUES_ENTRY_LIMIT: usize = 1978;

fn check_entries(tests_path: &Path, bad: &mut bool) {
Expand All @@ -22,18 +22,19 @@ fn check_entries(tests_path: &Path, bad: &mut bool) {
}
}

let (mut max, mut max_root, mut max_issues) = (0usize, 0usize, 0usize);
for (dir_path, count) in directories {
// Use special values for these dirs.
let is_root = tests_path.join("ui") == dir_path;
let is_issues_dir = tests_path.join("ui/issues") == dir_path;
let limit = if is_root {
ROOT_ENTRY_LIMIT
let (limit, maxcnt) = if is_root {
(ROOT_ENTRY_LIMIT, &mut max_root)
} else if is_issues_dir {
ISSUES_ENTRY_LIMIT
(ISSUES_ENTRY_LIMIT, &mut max_issues)
} else {
ENTRY_LIMIT
(ENTRY_LIMIT, &mut max)
};

*maxcnt = (*maxcnt).max(count);
if count > limit {
tidy_error!(
bad,
Expand All @@ -45,6 +46,21 @@ fn check_entries(tests_path: &Path, bad: &mut bool) {
);
}
}
if ENTRY_LIMIT > max {
tidy_error!(bad, "`ENTRY_LIMIT` is too high (is {ENTRY_LIMIT}, should be {max})");
}
if ROOT_ENTRY_LIMIT > max_root {
tidy_error!(
bad,
"`ROOT_ENTRY_LIMIT` is too high (is {ROOT_ENTRY_LIMIT}, should be {max_root})"
);
}
if ISSUES_ENTRY_LIMIT > max_issues {
tidy_error!(
bad,
"`ISSUES_ENTRY_LIMIT` is too high (is {ISSUES_ENTRY_LIMIT}, should be {max_issues})"
);
}
}

pub fn check(path: &Path, bad: &mut bool) {
Expand Down