Skip to content

Add a tidy check to find unexpected files in UI tests, and clean up the results #111363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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:
// ```
Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions tests/ui/attr-bad-crate-attr.stderr
Original file line number Diff line number Diff line change
@@ -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

16 changes: 9 additions & 7 deletions tests/ui/dupe-first-attr.rc → tests/ui/dupe-first-attr.rs
Original file line number Diff line number Diff line change
@@ -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() {}
1 change: 0 additions & 1 deletion tests/ui/extern/auxiliary/invalid-utf8.txt

This file was deleted.

3 changes: 0 additions & 3 deletions tests/ui/feature-gates/auxiliary/debugger-visualizer.natvis

This file was deleted.

4 changes: 0 additions & 4 deletions tests/ui/issues/auxiliary/issue-3136-a.rc

This file was deleted.

7 changes: 5 additions & 2 deletions tests/ui/issues/auxiliary/issue-3136-a.rs
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/issues/issue-3136-b.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// run-pass
// aux-build:issue-3136-a.rc
// aux-build:issue-3136-a.rs

// pretty-expanded FIXME #23616

Expand Down
10 changes: 7 additions & 3 deletions tests/ui/kindck/kindck-send-unsafe.rs
Original file line number Diff line number Diff line change
@@ -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() {}
12 changes: 0 additions & 12 deletions tests/ui/kindck/kindck-send-unsafe.rs~rust-lang_master

This file was deleted.

23 changes: 18 additions & 5 deletions tests/ui/kindck/kindck-send-unsafe.stderr
Original file line number Diff line number Diff line change
@@ -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`.