-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 to error on new Makefile
s in tests/run-make
#122898
Conversation
rustbot has assigned @albertlarsan68. Use |
f5dbd19
to
1761d9e
Compare
src/tools/tidy/src/run_make_tests.rs
Outdated
let allowed_makefiles = include!("expected_run_make_makefiles.txt"); | ||
let is_sorted = allowed_makefiles.windows(2).all(|w| w[0] < w[1]); |
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.
i think you messed up something here, you arent actually parsing the file
can you just reuse the code from the issues test stuff?
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.
oh, include!
does rust syntax, please leave a comment about that lol
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.
Added a comment explaining why include!
is used.
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.
How often will this check be useful (finding newly created Makefiles)? I think it's so rare. How about creating a shell script (which can be used in mingw-check-tidy
pipeline) that handles this? Making additions on tidy for this check seems like an overkill to me.
There's already 3 instances where people weren't aware of the new infrastructure and tried to introduce new Makefiles, e.g. #122757, #122663, #122840, so it does happen.
That sounds reasonable, though I'm not very keen on writing shell scripts :3 If this seems unnecessary, it's fine if I just occasionally remind people who introduce new Makefiles to use |
I thought the same and that's why I suggest creating shell script instead of bloating tidy. |
Now that I think about it, it's probably not even worth the shell script, because we're planning to migrate away from Makefiles anyway, and if I add a shell script it invariably is going to require some allowlist for the Makefiles, which then means anyone who's porting the run-make tests have additional friction needing to adjust that. Given that, I'm going to close this PR, thanks for the advice! EDIT: the tidy version (this version) supports --bless so the person porting run-make tests do not need to manually edit the allowlist if a Makefile is removed. |
I'm actually going to re-open this because a new Makefile slipped through in #118644.
The logic for handling entries in the allowlist for run-make tests is not exactly trivial to write or maintain in a shellscript (this includes checking for sorted entries, moved/removed entries, walking the run-make tests directory, blessing). Furthermore, I would think that it's nicer for people working on PRs to see the "don't add a new Makefile" tidy error locally so it can be caught early, without having to rely on PR CI to then immediately fail anyway. For the people working on actually porting a run-make test, they should only need to |
This comment has been minimized.
This comment has been minimized.
(Failing as intended, it's the new Makefile that slipped through) |
7c03576
to
f10cf7b
Compare
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.
A few comments
src/tools/tidy/src/main.rs
Outdated
@@ -103,6 +103,7 @@ fn main() { | |||
check!(tests_revision_unpaired_stdout_stderr, &tests_path); | |||
check!(debug_artifacts, &tests_path); | |||
check!(ui_tests, &root_path, bless); | |||
check!(run_make_tests, &root_path, bless); |
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.
Why not use tests_path here, instead of creating it later from the root path?
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.
(This was previously changed to check!(run_make_tests, &tests_path, &src_path, bless);
)
@@ -0,0 +1,344 @@ | |||
/* |
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.
I'm not fond of this being a rust file, but marked as .txt
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.
I could just change this to a simple line-separated plain text file and not rust. FWIW, this is also what the ui test tidy check does.
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.
Changed the allowlist txt file to be actually a plain-text file.
69eb315
to
5089717
Compare
I agree that this check is useful, but I'm not sure if it's worth adding this complexity on tidy. I still think we can handle this using shell scripting script to perform the check in CI.
I can make a P.o.C PR in couple days if you don't want to do that. |
(That'd be great, it's moreso that I don't know how to write this in shell script lol) Although, if it's not written in tidy, would people porting run-make tests need to manually edit some allowlist file (i.e. no |
I want to point out that we have a check in tidy that the tests aren't added to src/test, even though it isn't really needed anymore. I prefer the rust version over a shell version, just because it is more portable, and that we have most of the infrastructure needed to run this kind of test. |
We can also justifiably remove the tidy check when we drive out our foe (Makefiles). |
Manually editing. It should be easy to remove a couple of lines (we will check if those lines exist on the filesystem anyway).
|
src/tools/tidy/src/run_make_tests.rs
Outdated
tidy_error!( | ||
bad, | ||
"Makefile `{}` no longer exists and should be removed from the exclusions in \ | ||
`src/tools/tidy/src/allowed_run_make_makefiles.txt`", | ||
p.display() | ||
); |
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.
Maybe also point to --bless here?
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.
Updated the message to point to --bless
tidy_error!( | ||
bad, | ||
"found run-make Makefile not permitted in \ | ||
`src/tools/tidy/src/allowed_run_make_makefiles.txt`, please write new run-make \ | ||
tests with `rmake.rs` instead: {}", | ||
entry.path().display() | ||
); |
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.
Am I right that this error is not fixed by running with --bless?
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.
Yes, that is the intention: that new Makefiles not in the allowlist will error, even if you pass --bless.
The check will become lighter over time, and we can remove it once the run-make with Makefiles infrastructure is removed. |
@onur-ozkan I am not sure I see the point between tidy and another shell script here. Anything that people should be running every time they commit or push a PR is gonna be in that hot path, and this won't catch anything if it doesn't run in that hot path, script or no, but it will require many more hours for the back-and-forth of "this should be fixed" "oh" re: a new Makefile appearing in a PR. |
Left a FIXME to remind removing this check once Makefiles are no longer accepted. |
The catch is rare (only when writing tests in a Makefile) and one CI failure should be enough for anyone to understand "you shouldn't write tests in Makefiles". A simple script can easily perform this check and can be removed right away without changing the codebase once we are done with the Makefiles. I don't want to talk about this indefinitely; it could be just my personal preference. Since most people here prefer the current approach, you can ignore my comments. |
I have no strong opinions on this, as I can understand that if tidy is slow it will be very annoying. I personally don't know how to write a shell script version of this, but if someone writes a shell script version of this instead that'll work too. |
As we will have to remove the makefile-handling code, we can at the same time remove the tidy part. r=me when CI green |
(You will need to r+ since I don't have r+) |
Thanks for the PR! The r=me is also a signal to other r+ people that they can approve the PR in my name, not only to the author of the PR. |
☀️ Test successful - checks-actions |
Finished benchmarking commit (d0e8cbb): comparison URL. Overall result: ❌✅ regressions and improvements - 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: 668.256s -> 669.796s (0.23%) |
We would like to strongly encourage new
run-make
tests to be written in Rust and not add any newMakefile
-basedrun-make
tests.