Skip to content

Commit 28faec9

Browse files
Suggest pattern in meaningful test diagnostic
1 parent 742a9c1 commit 28faec9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/tools/tidy/src/ui_tests.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,17 @@ pub fn check(path: &Path, bad: &mut bool) {
148148
if ext == "rs" {
149149
lazy_static! {
150150
static ref ISSUE_NAME_REGEX: Regex =
151-
Regex::new(r"^issues?[-_]?\d{3,}").unwrap();
151+
Regex::new(r"^issues?[-_]?(\d{3,})").unwrap();
152152
}
153153

154-
if ISSUE_NAME_REGEX.is_match(testname) {
154+
if let Some(test_name) = ISSUE_NAME_REGEX.captures(testname) {
155155
// these paths are always relative to the passed `path` and always UTF8
156156
let stripped_path = file_path.strip_prefix(path).unwrap().to_str().unwrap();
157157
if !allowed_issue_filenames.remove(stripped_path) {
158158
tidy_error!(
159159
bad,
160-
"UI test `{}` should use a name that describes the test and link the issue in a comment instead.",
161-
file_path.display(),
160+
"file `{stripped_path}` must begin with a descriptive name, consider `{{reason}}-issue-{issue_n}.rs`",
161+
issue_n = &test_name[1],
162162
);
163163
}
164164
}

0 commit comments

Comments
 (0)