Split dots in filename, not the entire path

This commit is contained in:
许杰友 Jieyou Xu (Joe) 2024-03-04 19:30:53 +00:00
parent 7606c13961
commit b4936133bb
No known key found for this signature in database
GPG key ID: 95DDEBD74A1DC2C0
2 changed files with 23 additions and 8 deletions

View file

@ -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((test_path, expected_revisions)) = test_info.get(file_prefix) else {
let Some(filename) = sibling.file_name().map(OsStr::to_str).flatten() else {
continue;
};
match filename_components[..] {
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 {
continue;
};
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.

View file

@ -0,0 +1,7 @@
// Regression test for <https://github.com/rust-lang/rust/issues/121986>.
// Check that `tests_revision_unpaired_stdout_stderr` don't accidentally get confused by
// paths containing periods.
//@ check-pass
fn main() {}