summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-05-13 21:34:05 +0000
committerbors <bors@rust-lang.org>2023-05-13 21:34:05 +0000
commiteb03a3e3f98019209d63e680eed49bde01bf5f60 (patch)
treea694e1bb6cc2fdd59d6aa130e1310dbf3731e3cd
parent2c41369acc445d04129db40ba998dd7a89fb0d2e (diff)
parent517ea5652a773d51c3cc431e86d5ba2f443c2fd2 (diff)
downloadrust-eb03a3e3f98019209d63e680eed49bde01bf5f60.tar.gz
rust-eb03a3e3f98019209d63e680eed49bde01bf5f60.zip
Auto merge of #111363 - asquared31415:tidy_no_random_ui_tests, r=fee1-dead
Add a tidy check to find unexpected files in UI tests, and clean up the results

While looking at UI tests, I noticed several weird files that were not being tested, some from even pre-1.0. I added a tidy check that fails if any files not known to compiletest or not used in tests (via manual list) are present in the ui tests.

Unfortunately the root entry limit had to be raised by 1 to accommodate the stderr file for one of the tests.

r? `@fee1-dead`
-rw-r--r--src/tools/tidy/src/ui_tests.rs36
-rw-r--r--tests/ui/attr-bad-crate-attr.rs (renamed from tests/ui/attr-bad-crate-attr.rc)0
-rw-r--r--tests/ui/attr-bad-crate-attr.stderr8
-rw-r--r--tests/ui/dupe-first-attr.rs (renamed from tests/ui/dupe-first-attr.rc)16
-rw-r--r--tests/ui/extern/auxiliary/invalid-utf8.txt1
-rw-r--r--tests/ui/feature-gates/auxiliary/debugger-visualizer.natvis3
-rw-r--r--tests/ui/issues/auxiliary/issue-3136-a.rc4
-rw-r--r--tests/ui/issues/auxiliary/issue-3136-a.rs7
-rw-r--r--tests/ui/issues/issue-3136-b.rs2
-rw-r--r--tests/ui/kindck/kindck-send-unsafe.rs10
-rw-r--r--tests/ui/kindck/kindck-send-unsafe.rs~rust-lang_master12
-rw-r--r--tests/ui/kindck/kindck-send-unsafe.stderr23
12 files changed, 82 insertions, 40 deletions
diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs
index 9473eabe442..ee12f4acb10 100644
--- a/src/tools/tidy/src/ui_tests.rs
+++ b/src/tools/tidy/src/ui_tests.rs
@@ -4,13 +4,38 @@
 
 use ignore::Walk;
 use std::collections::HashMap;
+use std::ffi::OsStr;
 use std::fs;
 use std::path::{Path, PathBuf};
 
 const ENTRY_LIMIT: usize = 900;
 // FIXME: The following limits should be reduced eventually.
 const ISSUES_ENTRY_LIMIT: usize = 1920;
-const ROOT_ENTRY_LIMIT: usize = 895;
+const ROOT_ENTRY_LIMIT: usize = 896;
+
+const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
+    "rs",     // test source files
+    "stderr", // expected stderr file, corresponds to a rs file
+    "stdout", // expected stdout file, corresponds to a rs file
+    "fixed",  // expected source file after applying fixes
+    "md",     // test directory descriptions
+    "ftl",    // translation tests
+];
+
+const EXTENSION_EXCEPTION_PATHS: &[&str] = &[
+    "tests/ui/asm/named-asm-labels.s", // loading an external asm file to test named labels lint
+    "tests/ui/check-cfg/my-awesome-platform.json", // testing custom targets with cfgs
+    "tests/ui/commandline-argfile-badutf8.args", // passing args via a file
+    "tests/ui/commandline-argfile.args", // passing args via a file
+    "tests/ui/crate-loading/auxiliary/libfoo.rlib", // testing loading a manually created rlib
+    "tests/ui/include-macros/data.bin", // testing including data with the include macros
+    "tests/ui/include-macros/file.txt", // testing including data with the include macros
+    "tests/ui/macros/macro-expanded-include/file.txt", // testing including data with the include macros
+    "tests/ui/macros/not-utf8.bin", // testing including data with the include macros
+    "tests/ui/macros/syntax-extension-source-utils-files/includeme.fragment", // more include
+    "tests/ui/unused-crate-deps/test.mk", // why would you use make
+    "tests/ui/proc-macro/auxiliary/included-file.txt", // more include
+];
 
 fn check_entries(tests_path: &Path, bad: &mut bool) {
     let mut directories: HashMap<PathBuf, usize> = HashMap::new();
@@ -66,7 +91,14 @@ pub fn check(path: &Path, bad: &mut bool) {
     let paths = [ui.as_path(), ui_fulldeps.as_path()];
     crate::walk::walk_no_read(&paths, |_, _| false, &mut |entry| {
         let file_path = entry.path();
-        if let Some(ext) = file_path.extension() {
+        if let Some(ext) = file_path.extension().and_then(OsStr::to_str) {
+            // files that are neither an expected extension or an exception should not exist
+            // they're probably typos or not meant to exist
+            if !(EXPECTED_TEST_FILE_EXTENSIONS.contains(&ext)
+                || EXTENSION_EXCEPTION_PATHS.iter().any(|path| file_path.ends_with(path)))
+            {
+                tidy_error!(bad, "file {} has unexpected extension {}", file_path.display(), ext);
+            }
             if ext == "stderr" || ext == "stdout" {
                 // Test output filenames have one of the formats:
                 // ```
diff --git a/tests/ui/attr-bad-crate-attr.rc b/tests/ui/attr-bad-crate-attr.rs
index 89ba26dfd6f..89ba26dfd6f 100644
--- a/tests/ui/attr-bad-crate-attr.rc
+++ b/tests/ui/attr-bad-crate-attr.rs
diff --git a/tests/ui/attr-bad-crate-attr.stderr b/tests/ui/attr-bad-crate-attr.stderr
new file mode 100644
index 00000000000..ff420eeea4a
--- /dev/null
+++ b/tests/ui/attr-bad-crate-attr.stderr
@@ -0,0 +1,8 @@
+error: expected item after attributes
+  --> $DIR/attr-bad-crate-attr.rs:4:1
+   |
+LL | #[attr = "val"] // Unterminated
+   | ^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/dupe-first-attr.rc b/tests/ui/dupe-first-attr.rs
index 8b7025b7be7..d950743b41c 100644
--- a/tests/ui/dupe-first-attr.rc
+++ b/tests/ui/dupe-first-attr.rs
@@ -1,24 +1,26 @@
+// run-pass
+
 // Regression test for a problem with the first mod attribute
 // being applied to every mod
 
 // pretty-expanded FIXME #23616
 
 #[cfg(target_os = "linux")]
-mod hello;
+mod hello {}
 
 #[cfg(target_os = "macos")]
-mod hello;
+mod hello {}
 
 #[cfg(target_os = "windows")]
-mod hello;
+mod hello {}
 
 #[cfg(target_os = "freebsd")]
-mod hello;
+mod hello {}
 
 #[cfg(target_os = "dragonfly")]
-mod hello;
+mod hello {}
 
 #[cfg(target_os = "android")]
-mod hello;
+mod hello {}
 
-pub fn main() { }
+fn main() {}
diff --git a/tests/ui/extern/auxiliary/invalid-utf8.txt b/tests/ui/extern/auxiliary/invalid-utf8.txt
deleted file mode 100644
index dc1115b82db..00000000000
--- a/tests/ui/extern/auxiliary/invalid-utf8.txt
+++ /dev/null
@@ -1 +0,0 @@
-Ã(
\ No newline at end of file
diff --git a/tests/ui/feature-gates/auxiliary/debugger-visualizer.natvis b/tests/ui/feature-gates/auxiliary/debugger-visualizer.natvis
deleted file mode 100644
index 6eb47e3d85b..00000000000
--- a/tests/ui/feature-gates/auxiliary/debugger-visualizer.natvis
+++ /dev/null
@@ -1,3 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
-</AutoVisualizer>
diff --git a/tests/ui/issues/auxiliary/issue-3136-a.rc b/tests/ui/issues/auxiliary/issue-3136-a.rc
deleted file mode 100644
index cd5fd314505..00000000000
--- a/tests/ui/issues/auxiliary/issue-3136-a.rc
+++ /dev/null
@@ -1,4 +0,0 @@
-#![crate_type = "lib"]
-
-#[path = "issue-3136-a.rs"]
-pub mod issue_3136_a;
diff --git a/tests/ui/issues/auxiliary/issue-3136-a.rs b/tests/ui/issues/auxiliary/issue-3136-a.rs
index 9bb546ab393..22bb1c8f977 100644
--- a/tests/ui/issues/auxiliary/issue-3136-a.rs
+++ b/tests/ui/issues/auxiliary/issue-3136-a.rs
@@ -1,11 +1,14 @@
+#![crate_type = "lib"]
+
 trait x {
     fn use_x<T>(&self);
 }
 struct y(());
 impl x for y {
     fn use_x<T>(&self) {
-        struct foo { //~ ERROR quux
-            i: ()
+        struct foo {
+            //~ ERROR quux
+            i: (),
         }
         fn new_foo<T>(i: ()) -> foo {
             foo { i: i }
diff --git a/tests/ui/issues/issue-3136-b.rs b/tests/ui/issues/issue-3136-b.rs
index c4ca7236e76..33d97fe7c83 100644
--- a/tests/ui/issues/issue-3136-b.rs
+++ b/tests/ui/issues/issue-3136-b.rs
@@ -1,5 +1,5 @@
 // run-pass
-// aux-build:issue-3136-a.rc
+// aux-build:issue-3136-a.rs
 
 // pretty-expanded FIXME #23616
 
diff --git a/tests/ui/kindck/kindck-send-unsafe.rs b/tests/ui/kindck/kindck-send-unsafe.rs
index 4ef30a71fa3..eb1f2a549b1 100644
--- a/tests/ui/kindck/kindck-send-unsafe.rs
+++ b/tests/ui/kindck/kindck-send-unsafe.rs
@@ -1,11 +1,15 @@
 extern crate core;
 
-fn assert_send<T:Send>() { }
+fn assert_send<T: Send>() {}
+
+fn test70() {
+    assert_send::<*mut isize>();
+    //~^ ERROR `*mut isize` cannot be sent between threads safely
+}
 
 fn test71<'a>() {
     assert_send::<*mut &'a isize>();
     //~^ ERROR `*mut &'a isize` cannot be sent between threads safely
 }
 
-fn main() {
-}
+fn main() {}
diff --git a/tests/ui/kindck/kindck-send-unsafe.rs~rust-lang_master b/tests/ui/kindck/kindck-send-unsafe.rs~rust-lang_master
deleted file mode 100644
index 3f0444ec9c8..00000000000
--- a/tests/ui/kindck/kindck-send-unsafe.rs~rust-lang_master
+++ /dev/null
@@ -1,12 +0,0 @@
-fn assert_send<T:Send>() { }
-
-// unsafe ptrs are ok unless they point at unsendable things
-fn test70() {
-    assert_send::<*mut int>();
-}
-fn test71<'a>() {
-    assert_send::<*mut &'a int>(); //~ ERROR does not fulfill the required lifetime
-}
-
-fn main() {
-}
diff --git a/tests/ui/kindck/kindck-send-unsafe.stderr b/tests/ui/kindck/kindck-send-unsafe.stderr
index ceed0053caa..f1a5054abbc 100644
--- a/tests/ui/kindck/kindck-send-unsafe.stderr
+++ b/tests/ui/kindck/kindck-send-unsafe.stderr
@@ -1,16 +1,29 @@
-error[E0277]: `*mut &'a isize` cannot be sent between threads safely
+error[E0277]: `*mut isize` cannot be sent between threads safely
   --> $DIR/kindck-send-unsafe.rs:6:19
    |
+LL |     assert_send::<*mut isize>();
+   |                   ^^^^^^^^^^ `*mut isize` cannot be sent between threads safely
+   |
+   = help: the trait `Send` is not implemented for `*mut isize`
+note: required by a bound in `assert_send`
+  --> $DIR/kindck-send-unsafe.rs:3:19
+   |
+LL | fn assert_send<T: Send>() {}
+   |                   ^^^^ required by this bound in `assert_send`
+
+error[E0277]: `*mut &'a isize` cannot be sent between threads safely
+  --> $DIR/kindck-send-unsafe.rs:11:19
+   |
 LL |     assert_send::<*mut &'a isize>();
    |                   ^^^^^^^^^^^^^^ `*mut &'a isize` cannot be sent between threads safely
    |
    = help: the trait `Send` is not implemented for `*mut &'a isize`
 note: required by a bound in `assert_send`
-  --> $DIR/kindck-send-unsafe.rs:3:18
+  --> $DIR/kindck-send-unsafe.rs:3:19
    |
-LL | fn assert_send<T:Send>() { }
-   |                  ^^^^ required by this bound in `assert_send`
+LL | fn assert_send<T: Send>() {}
+   |                   ^^^^ required by this bound in `assert_send`
 
-error: aborting due to previous error
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0277`.