diff options
| author | bors <bors@rust-lang.org> | 2024-03-05 13:02:42 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-03-05 13:02:42 +0000 |
| commit | c7beecf3e3cef7a8226a99aec4e4f6bfc114ba8e (patch) | |
| tree | 0c735045917e5f6f2432d5c81337e1431a65fad2 /src/tools | |
| parent | bdde2a80aef587cdbb8eb2d6e295d5c1d05830d9 (diff) | |
| parent | 247a080b9852e3ab176cca63f5695c8a6b2202cd (diff) | |
| download | rust-c7beecf3e3cef7a8226a99aec4e4f6bfc114ba8e.tar.gz rust-c7beecf3e3cef7a8226a99aec4e4f6bfc114ba8e.zip | |
Auto merge of #121992 - jieyouxu:fix-tidy-unpaired-revision, r=onur-ozkan
tidy: split dots in filename not the entire path when checking for stray stdout/stderr files 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 - [ ] Adjust rustc-dev-guide to document assert on test name not containing dots. https://github.com/rust-lang/rustc-dev-guide/pull/1927 Fixes #121986.
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/tidy/src/tests_revision_unpaired_stdout_stderr.rs | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/tools/tidy/src/tests_revision_unpaired_stdout_stderr.rs b/src/tools/tidy/src/tests_revision_unpaired_stdout_stderr.rs index 394f95e9144..a0773c85bef 100644 --- a/src/tools/tidy/src/tests_revision_unpaired_stdout_stderr.rs +++ b/src/tools/tidy/src/tests_revision_unpaired_stdout_stderr.rs @@ -84,10 +84,16 @@ 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 { + let Some(test_name) = test.file_stem().map(OsStr::to_str).flatten() else { continue; }; + assert!( + !test_name.contains('.'), + "test name cannot contain dots '.': `{}`", + test.display() + ); + test_info.insert(test_name.to_string(), (test, expected_revisions)); } @@ -98,14 +104,20 @@ pub fn check(tests_path: impl AsRef<Path>, bad: &mut bool) { for sibling in files_under_inspection.iter().filter(|f| { f.extension().map(OsStr::to_str).flatten().is_some_and(|ext| EXTENSIONS.contains(&ext)) }) { - let filename_components = sibling.to_str().unwrap().split('.').collect::<Vec<_>>(); - let file_prefix = filename_components[0]; + let Some(filename) = sibling.file_name().map(OsStr::to_str).flatten() else { + continue; + }; + + let filename_components = filename.split('.').collect::<Vec<_>>(); + let [file_prefix, ..] = &filename_components[..] else { + continue; + }; - let Some((test_path, expected_revisions)) = test_info.get(file_prefix) else { + let Some((test_path, expected_revisions)) = test_info.get(*file_prefix) else { continue; }; - match filename_components[..] { + match &filename_components[..] { // Cannot have a revision component, skip. [] | [_] => return, [_, _] if !expected_revisions.is_empty() => { @@ -120,9 +132,9 @@ pub fn check(tests_path: impl AsRef<Path>, bad: &mut bool) { [_, _] => return, [_, found_revision, .., extension] => { if !IGNORES.contains(&found_revision) - && !expected_revisions.contains(found_revision) + && !expected_revisions.contains(*found_revision) // This is from `//@ stderr-per-bitwidth` - && !(extension == "stderr" && ["32bit", "64bit"].contains(&found_revision)) + && !(*extension == "stderr" && ["32bit", "64bit"].contains(&found_revision)) { // Found some unexpected revision-esque component that is not a known // compare-mode or expected revision. |
