about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/tools/tidy/src/tests_revision_unpaired_stdout_stderr.rs26
-rw-r--r--tests/rustdoc/invalid$crate$name.rs (renamed from tests/rustdoc/invalid.crate.name.rs)0
-rw-r--r--tests/ui/command/need-crate-arg-ignore-tidy$x.rs (renamed from tests/ui/command/need-crate-arg-ignore-tidy.x.rs)0
-rw-r--r--tests/ui/command/need-crate-arg-ignore-tidy$x.stderr (renamed from tests/ui/command/need-crate-arg-ignore-tidy.x.stderr)2
-rw-r--r--tests/ui/meta/dir.with.dots/test.rs7
5 files changed, 27 insertions, 8 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.
diff --git a/tests/rustdoc/invalid.crate.name.rs b/tests/rustdoc/invalid$crate$name.rs
index 189a6c92124..189a6c92124 100644
--- a/tests/rustdoc/invalid.crate.name.rs
+++ b/tests/rustdoc/invalid$crate$name.rs
diff --git a/tests/ui/command/need-crate-arg-ignore-tidy.x.rs b/tests/ui/command/need-crate-arg-ignore-tidy$x.rs
index b1ac4a4ae21..b1ac4a4ae21 100644
--- a/tests/ui/command/need-crate-arg-ignore-tidy.x.rs
+++ b/tests/ui/command/need-crate-arg-ignore-tidy$x.rs
diff --git a/tests/ui/command/need-crate-arg-ignore-tidy.x.stderr b/tests/ui/command/need-crate-arg-ignore-tidy$x.stderr
index 89f7210c048..28f6d31b1ce 100644
--- a/tests/ui/command/need-crate-arg-ignore-tidy.x.stderr
+++ b/tests/ui/command/need-crate-arg-ignore-tidy$x.stderr
@@ -1,4 +1,4 @@
-error: invalid character `'.'` in crate name: `need_crate_arg_ignore_tidy.x`
+error: invalid character `'$'` in crate name: `need_crate_arg_ignore_tidy$x`
    |
    = help: you can either pass `--crate-name` on the command line or add `#![crate_name="…"]` to set the crate name
 
diff --git a/tests/ui/meta/dir.with.dots/test.rs b/tests/ui/meta/dir.with.dots/test.rs
new file mode 100644
index 00000000000..4d663e994f5
--- /dev/null
+++ b/tests/ui/meta/dir.with.dots/test.rs
@@ -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() {}