-
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
tidy: split dots in filename not the entire path when checking for stray stdout/stderr files #121992
Conversation
r? @clubby789 rustbot has assigned @clubby789. Use r? to explicitly pick a reviewer |
@@ -84,7 +84,9 @@ pub fn check(tests_path: impl AsRef<Path>, bad: &mut bool) { | |||
} | |||
}); | |||
|
|||
let Some((test_name, _)) = test.to_str().map(|s| s.split_once('.')).flatten() else { |
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.
You want https://doc.rust-lang.org/stable/std/path/struct.Path.html#method.file_prefix which is sadly unstable
https://doc.rust-lang.org/stable/std/path/struct.Path.html#method.with_extension should work too, and be nicer than... split 😭
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.
Could we not use some unstable features?
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 I actually want file_stem
semantics here, because I want to keep the test name which is everything but the "rs" extension. This split_once
doesn't seem right. E.g. a.b.rs
, the test name is should be a.b
not a
. Revisioned output gets additional .[rev].std{out,err}
after the test name to the best of my knowledge.
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.
Could we not use some unstable features?
Tidy requires stable no?
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 😢
let filename_components = filename.split('.').collect::<Vec<_>>(); | ||
let [file_prefix, ..] = &filename_components[..] else { | ||
continue; | ||
}; |
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 this logic here isn't robust either. If a test name is a.b.rs
, and previously we use file_stem
, the test name becomes a.b
. But now this sibling check produces a
which will silently let a.b.unknown-revision.stdout
go through because there is no entry in test_info
. I'll have to think about this part of the logic a bit.
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 actually not sure if we can properly check here, if we don't assume test name itself to not have any dots.
According to rustc-dev-guide, a test output can take the form
<test_name>[.<revision>][.<compare_mode>].<extension>
- but
<extension>
can be:stderr
,stdout
run.stderr
,run.stdout
64bit.stderr
,32bit.stderr
- but
<test_name>
can also have dots if we don't assume it can't have dots.
Maybe it's just better to just say "we assume a test's name don't contain dots or else this tidy check won't catch stray stdout/stderr files for that test"?
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, I think that's necessary to assume for file names. We can assume that of a file name even if we can't assume that for the full 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.
we assume a test's name don't contain dots or else this tidy check won't catch stray stdout/stderr files for that test
We may need to add an assertion with a message to ensure that it doesn't happen.
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'll add an aasert for if the test name contains dots, and update the dev-guide to describe this behavior.
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.
Probably a good idea. A lot of the test infra assumes that things like e.g. .64bit.stderr
remain coherent.
This is so that we can catch stray test output files, since test names without dots can form predictable patterns we can match on.
This comment has been minimized.
This comment has been minimized.
Is there a way to force tidy to rerun on all test files, regardless of if they are modified or not? |
Did you try |
As in |
Probably doesn't do anything then |
I'll just write an external script to go through all the test files to check if there's any multi-dot test names. |
@bors r+ p=1 (as this fixes a very noisy tidy issue) |
☀️ Test successful - checks-actions |
Finished benchmarking commit (c7beecf): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. 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.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 643.644s -> 644.654s (0.16%) |
As far as I see we already doing this. Could you tell what made you think that tidy doesn't already do that? |
I'm actually not sure, probably because the formatting modified entries messages came first, and then I subconsciously ignored the other messages? (this is moreso me being :ferrisClueless: than anything) |
I committed a path crime by splitting the entire path on
.
, when I meant to split on the filename. This means that any parent folders which contain.
will cause tidy failure. Added a regression test so that doesn't happen again.Follow-up
Fixes #121986.