diff options
| author | 许杰友 Jieyou Xu (Joe) <jieyouxu@outlook.com> | 2024-03-04 19:30:53 +0000 |
|---|---|---|
| committer | 许杰友 Jieyou Xu (Joe) <jieyouxu@outlook.com> | 2024-03-04 19:30:53 +0000 |
| commit | b4936133bb781676070d5189362823ef058e0041 (patch) | |
| tree | 532f71983ed8d05ddec85a01c8e87a4af5b4fe50 /src | |
| parent | 7606c13961ddc1174b70638e934df0439b7dc515 (diff) | |
| download | rust-b4936133bb781676070d5189362823ef058e0041.tar.gz rust-b4936133bb781676070d5189362823ef058e0041.zip | |
Split dots in filename, not the entire path
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/tidy/src/tests_revision_unpaired_stdout_stderr.rs | 22 |
1 files changed, 15 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..87dbb0026d4 100644 --- a/src/tools/tidy/src/tests_revision_unpaired_stdout_stderr.rs +++ b/src/tools/tidy/src/tests_revision_unpaired_stdout_stderr.rs @@ -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 { + let Some((test_name, _)) = + test.file_name().map(OsStr::to_str).flatten().map(|n| n.split_once('.')).flatten() + else { continue; }; @@ -98,14 +100,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 +128,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. |
