-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
add tidy check that forbids issue-XXXX test filenames #113583
Conversation
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
This comment has been minimized.
This comment has been minimized.
src/tools/tidy/src/ui_tests.rs
Outdated
if let Some(m) = regex.find(name) { | ||
tidy_error!( | ||
bad, | ||
"test file {} should not use {} in its name. link the issue in a comment in the test and use a more descriptive name for the test instead.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"test file {} should not use {} in its name. link the issue in a comment in the test and use a more descriptive name for the test instead.", | |
"test file `{}` should not use `{}` in its name. link the issue in a comment in the test and use a more descriptive name for the test instead.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be slightly clearer that it isn't the issue number that is totally forbidden from the filename, but that the filename needs to actually identify what the test is about at-a-glance, i.e. what-it-tests-issue-\d+
is acceptable, strictly speaking (if the reviewer accepts it, at least)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
src/tools/tidy/src/ui_tests.rs
Outdated
@@ -128,4 +132,44 @@ pub fn check(path: &Path, bad: &mut bool) { | |||
} | |||
} | |||
}); | |||
|
|||
// Check that any test files modified don't have a useless name | |||
for changed_file in git::get_git_modified_files(None, &vec!["rs"]).unwrap().unwrap() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hahah unrelated but why does get_git_modified_files
take a &Vec<_>
:thonk:
Wondering if it would make sense to actually go the other way around; if a test file contains something like |
That would break on the very likely case that a test resolves two issues and thus mentions two issues. No, I am not going to tolerate tests named |
What purpose do numbers in filenames serve? @matthiaskrgr |
Ooh right :D but we could special case that and make sure it contains one of them in the filename? |
@Nilstrieb when I am triaging my icemaker reports, I can see right away "issue-12345.rs" crashed with the Its just much more useful to have the issue number right away to open the ticket and see the related discussion/status etc than having something only something like Entering the code of the testcase in the github search does not always work because of minimization, and going through git log / git blame to find the a |
you could modify your code to try to extract issue numbers from the source, I think that short work in most cases too. |
src/tools/tidy/src/ui_tests.rs
Outdated
if let Some(m) = regex.find(name) { | ||
tidy_error!( | ||
bad, | ||
"test file {} should not use {} in its name. link the issue in a comment in the test and use a more descriptive name for the test instead.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be slightly clearer that it isn't the issue number that is totally forbidden from the filename, but that the filename needs to actually identify what the test is about at-a-glance, i.e. what-it-tests-issue-\d+
is acceptable, strictly speaking (if the reviewer accepts it, at least)?
It would be nice to somehow enforce an attribute style so they're easily extractable, regardless of whether or not the issue number is in the title // issue:12345
// issue:6789
// ice:1234 |
I do not think we should enforce that issue numbers be in filenames for the benefit of automation. The directory structures are for humans, and machines can deal with skimming through raw inodes and bytes if they must. It is specifically because the issue numbers are effectively just a table of pointers to allocations of real data that we are discussing this lint. |
Exactly! and by having the issue number in the title/filename, you only need a single lookup to access the data 🙂 |
And it's a ton of unnecessary overhead, when you are actually trying to examine the "deep history" of a bug, to have to open a bunch of files and examine each one for its purpose, rather than seeing the filename identifying things at a glance. And if a test relates to two or more issues, which is not at all uncommon now that we have over 50 thousand closed issues and over 8000 open issues, then having only one issue in the filename is equally useless if it's not the one you know the matter by. @matthiaskrgr If you need me to PR code to you for extracting issue numbers from file contents, I am happy to put it on my todo list if you name the repo. |
@tgross35 Would you be so kind as to open an issue for that? |
Also note that it seems that the current consent is to actually prefer "issue-xyz in filename" over "issue number somewhere inside the file": Looking just in issuenr in file: issuenr in comment:
|
I rest my case. |
@workingjubilee oh maybe there is a bit of a misunderstanding, fwiw I have nothing against descriptive file names in addition to the issue number next to it, like |
That is why I asked to refine the regex to allow |
Oh, and this will only affect ui tests, right? subrepo'd tools like clippy and rustfmt are still free to follow their own habits, right? |
If tidy is currently running on subtrees we already have a problem, please take that up in a new issue. |
@rustbot author |
💔 Test failed - checks-actions |
huh? |
💔 windows paths (I'm doing string operations on hard coded paths) |
Oh, right. |
fadc565
to
13e2abf
Compare
Sure, let's give this another go. |
@bors r+ |
shouldn't this go through an mcp at least so that more than 5 people are aware of this? |
MCP was opened in rust-lang/compiler-team#658. I don't think this warrants stopping the merge, though. |
☀️ Test successful - checks-actions |
Finished benchmarking commit (cf34adb): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 650.304s -> 650.76s (0.07%) |
…t-name-lint, r=compiler-errors Reimpl meaningful test name lint MCP658 This reintroduces the tidy rule originally proposed in rust-lang#113583 that then became an MCP in rust-lang/compiler-team#658 which eventually surfaced a quite-reasonable request for a diagnostic enhancement. I have added that to the rule. It produces output like this: ``` tidy error: file `ui/unsized/issue-115809.rs` must begin with a descriptive name, try `{reason}-issue-115809.rs` tidy error: file `ui/unsized/issue-115203.rs` must begin with a descriptive name, try `{reason}-issue-115203.rs` tidy error: file `ui/privacy/issue-113860-2.rs` must begin with a descriptive name, try `{reason}-issue-113860.rs` tidy error: file `ui/privacy/issue-117997.rs` must begin with a descriptive name, try `{reason}-issue-117997.rs` tidy error: file `ui/privacy/issue-119463.rs` must begin with a descriptive name, try `{reason}-issue-119463.rs` tidy error: file `ui/privacy/auxiliary/issue-117997.rs` must begin with a descriptive name, try `{reason}-issue-117997.rs` tidy error: file `ui/privacy/auxiliary/issue-119463-extern.rs` must begin with a descriptive name, try `{reason}-issue-119463.rs` tidy error: file `ui/privacy/issue-113860-1.rs` must begin with a descriptive name, try `{reason}-issue-113860.rs` tidy error: file `ui/privacy/issue-113860.rs` must begin with a descriptive name, try `{reason}-issue-113860.rs` tidy error: file `ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.rs` must begin with a descriptive name, try `{reason}-issue-114151.rs` tidy error: file `ui/did_you_mean/issue-114112.rs` must begin with a descriptive name, try `{reason}-issue-114112.rs` tidy error: file `ui/did_you_mean/issue-105225.rs` must begin with a descriptive name, try `{reason}-issue-105225.rs` tidy error: file `ui/did_you_mean/issue-105225-named-args.rs` must begin with a descriptive name, try `{reason}-issue-105225.rs` ``` You get the idea. There are some tests which merely would require reordering of the name according to the rule. I could modify the diagnostic further to identify those, but doing such would make it prone to bad suggestions. I have opted to trust contributors to recognize the diagnostic is robotic, as the pattern we are linting on is easier to match if we do not speculate on what parts of the name are meaningful: sometimes a word is a reason, but sometimes it is a mere "tag", such as with a pair like: - issue-314159265-blue.rs - issue-314159265-red.rs Starting them with `red-` and `blue-` means they do not sort together, despite being related, and the color names are still not very descriptive. Recognizing a good name is an open-ended task, though this pair might be: - colored-circle-gen-blue.rs - colored-circle-gen-red.rs Deciding exactly *how* to solve this is not the business of tidy, only recognizing a what. r? `@compiler-errors`
…nt, r=compiler-errors Reimpl meaningful test name lint MCP658 This reintroduces the tidy rule originally proposed in rust-lang/rust#113583 that then became an MCP in rust-lang/compiler-team#658 which eventually surfaced a quite-reasonable request for a diagnostic enhancement. I have added that to the rule. It produces output like this: ``` tidy error: file `ui/unsized/issue-115809.rs` must begin with a descriptive name, try `{reason}-issue-115809.rs` tidy error: file `ui/unsized/issue-115203.rs` must begin with a descriptive name, try `{reason}-issue-115203.rs` tidy error: file `ui/privacy/issue-113860-2.rs` must begin with a descriptive name, try `{reason}-issue-113860.rs` tidy error: file `ui/privacy/issue-117997.rs` must begin with a descriptive name, try `{reason}-issue-117997.rs` tidy error: file `ui/privacy/issue-119463.rs` must begin with a descriptive name, try `{reason}-issue-119463.rs` tidy error: file `ui/privacy/auxiliary/issue-117997.rs` must begin with a descriptive name, try `{reason}-issue-117997.rs` tidy error: file `ui/privacy/auxiliary/issue-119463-extern.rs` must begin with a descriptive name, try `{reason}-issue-119463.rs` tidy error: file `ui/privacy/issue-113860-1.rs` must begin with a descriptive name, try `{reason}-issue-113860.rs` tidy error: file `ui/privacy/issue-113860.rs` must begin with a descriptive name, try `{reason}-issue-113860.rs` tidy error: file `ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.rs` must begin with a descriptive name, try `{reason}-issue-114151.rs` tidy error: file `ui/did_you_mean/issue-114112.rs` must begin with a descriptive name, try `{reason}-issue-114112.rs` tidy error: file `ui/did_you_mean/issue-105225.rs` must begin with a descriptive name, try `{reason}-issue-105225.rs` tidy error: file `ui/did_you_mean/issue-105225-named-args.rs` must begin with a descriptive name, try `{reason}-issue-105225.rs` ``` You get the idea. There are some tests which merely would require reordering of the name according to the rule. I could modify the diagnostic further to identify those, but doing such would make it prone to bad suggestions. I have opted to trust contributors to recognize the diagnostic is robotic, as the pattern we are linting on is easier to match if we do not speculate on what parts of the name are meaningful: sometimes a word is a reason, but sometimes it is a mere "tag", such as with a pair like: - issue-314159265-blue.rs - issue-314159265-red.rs Starting them with `red-` and `blue-` means they do not sort together, despite being related, and the color names are still not very descriptive. Recognizing a good name is an open-ended task, though this pair might be: - colored-circle-gen-blue.rs - colored-circle-gen-red.rs Deciding exactly *how* to solve this is not the business of tidy, only recognizing a what. r? `@compiler-errors`
…nt, r=compiler-errors Reimpl meaningful test name lint MCP658 This reintroduces the tidy rule originally proposed in rust-lang/rust#113583 that then became an MCP in rust-lang/compiler-team#658 which eventually surfaced a quite-reasonable request for a diagnostic enhancement. I have added that to the rule. It produces output like this: ``` tidy error: file `ui/unsized/issue-115809.rs` must begin with a descriptive name, try `{reason}-issue-115809.rs` tidy error: file `ui/unsized/issue-115203.rs` must begin with a descriptive name, try `{reason}-issue-115203.rs` tidy error: file `ui/privacy/issue-113860-2.rs` must begin with a descriptive name, try `{reason}-issue-113860.rs` tidy error: file `ui/privacy/issue-117997.rs` must begin with a descriptive name, try `{reason}-issue-117997.rs` tidy error: file `ui/privacy/issue-119463.rs` must begin with a descriptive name, try `{reason}-issue-119463.rs` tidy error: file `ui/privacy/auxiliary/issue-117997.rs` must begin with a descriptive name, try `{reason}-issue-117997.rs` tidy error: file `ui/privacy/auxiliary/issue-119463-extern.rs` must begin with a descriptive name, try `{reason}-issue-119463.rs` tidy error: file `ui/privacy/issue-113860-1.rs` must begin with a descriptive name, try `{reason}-issue-113860.rs` tidy error: file `ui/privacy/issue-113860.rs` must begin with a descriptive name, try `{reason}-issue-113860.rs` tidy error: file `ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.rs` must begin with a descriptive name, try `{reason}-issue-114151.rs` tidy error: file `ui/did_you_mean/issue-114112.rs` must begin with a descriptive name, try `{reason}-issue-114112.rs` tidy error: file `ui/did_you_mean/issue-105225.rs` must begin with a descriptive name, try `{reason}-issue-105225.rs` tidy error: file `ui/did_you_mean/issue-105225-named-args.rs` must begin with a descriptive name, try `{reason}-issue-105225.rs` ``` You get the idea. There are some tests which merely would require reordering of the name according to the rule. I could modify the diagnostic further to identify those, but doing such would make it prone to bad suggestions. I have opted to trust contributors to recognize the diagnostic is robotic, as the pattern we are linting on is easier to match if we do not speculate on what parts of the name are meaningful: sometimes a word is a reason, but sometimes it is a mere "tag", such as with a pair like: - issue-314159265-blue.rs - issue-314159265-red.rs Starting them with `red-` and `blue-` means they do not sort together, despite being related, and the color names are still not very descriptive. Recognizing a good name is an open-ended task, though this pair might be: - colored-circle-gen-blue.rs - colored-circle-gen-red.rs Deciding exactly *how* to solve this is not the business of tidy, only recognizing a what. r? `@compiler-errors`
…nt, r=compiler-errors Reimpl meaningful test name lint MCP658 This reintroduces the tidy rule originally proposed in rust-lang/rust#113583 that then became an MCP in rust-lang/compiler-team#658 which eventually surfaced a quite-reasonable request for a diagnostic enhancement. I have added that to the rule. It produces output like this: ``` tidy error: file `ui/unsized/issue-115809.rs` must begin with a descriptive name, try `{reason}-issue-115809.rs` tidy error: file `ui/unsized/issue-115203.rs` must begin with a descriptive name, try `{reason}-issue-115203.rs` tidy error: file `ui/privacy/issue-113860-2.rs` must begin with a descriptive name, try `{reason}-issue-113860.rs` tidy error: file `ui/privacy/issue-117997.rs` must begin with a descriptive name, try `{reason}-issue-117997.rs` tidy error: file `ui/privacy/issue-119463.rs` must begin with a descriptive name, try `{reason}-issue-119463.rs` tidy error: file `ui/privacy/auxiliary/issue-117997.rs` must begin with a descriptive name, try `{reason}-issue-117997.rs` tidy error: file `ui/privacy/auxiliary/issue-119463-extern.rs` must begin with a descriptive name, try `{reason}-issue-119463.rs` tidy error: file `ui/privacy/issue-113860-1.rs` must begin with a descriptive name, try `{reason}-issue-113860.rs` tidy error: file `ui/privacy/issue-113860.rs` must begin with a descriptive name, try `{reason}-issue-113860.rs` tidy error: file `ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.rs` must begin with a descriptive name, try `{reason}-issue-114151.rs` tidy error: file `ui/did_you_mean/issue-114112.rs` must begin with a descriptive name, try `{reason}-issue-114112.rs` tidy error: file `ui/did_you_mean/issue-105225.rs` must begin with a descriptive name, try `{reason}-issue-105225.rs` tidy error: file `ui/did_you_mean/issue-105225-named-args.rs` must begin with a descriptive name, try `{reason}-issue-105225.rs` ``` You get the idea. There are some tests which merely would require reordering of the name according to the rule. I could modify the diagnostic further to identify those, but doing such would make it prone to bad suggestions. I have opted to trust contributors to recognize the diagnostic is robotic, as the pattern we are linting on is easier to match if we do not speculate on what parts of the name are meaningful: sometimes a word is a reason, but sometimes it is a mere "tag", such as with a pair like: - issue-314159265-blue.rs - issue-314159265-red.rs Starting them with `red-` and `blue-` means they do not sort together, despite being related, and the color names are still not very descriptive. Recognizing a good name is an open-ended task, though this pair might be: - colored-circle-gen-blue.rs - colored-circle-gen-red.rs Deciding exactly *how* to solve this is not the business of tidy, only recognizing a what. r? `@compiler-errors`
Helps with #113345 by preventing any future tests with non-descriptive names from being added.
This PR only checks modified ui test files because there are far too many existing problematic tests to be fixed at once:
3063/15424 (~19.86%)
*.rs
ui test files match^issue[-_ ]?\d+$
.Another 1349 files, totaling ~28.60% of all ui test files, contain that pattern in addition to some other text, where they should probably omit it in favor of a comment.
note: between the creation of this PR and 2023-07-25 (14 days), 10 more tests were added that failed this check.
r? @workingjubilee