Skip to content

Commit 517ea56

Browse files
committed
tidy check to find misc files in ui tests, and clean up the results
1 parent 2f6bc5d commit 517ea56

12 files changed

+82
-40
lines changed

src/tools/tidy/src/ui_tests.rs

+34-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,38 @@
44
55
use ignore::Walk;
66
use std::collections::HashMap;
7+
use std::ffi::OsStr;
78
use std::fs;
89
use std::path::{Path, PathBuf};
910

1011
const ENTRY_LIMIT: usize = 900;
1112
// FIXME: The following limits should be reduced eventually.
1213
const ISSUES_ENTRY_LIMIT: usize = 1920;
13-
const ROOT_ENTRY_LIMIT: usize = 895;
14+
const ROOT_ENTRY_LIMIT: usize = 896;
15+
16+
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
17+
"rs", // test source files
18+
"stderr", // expected stderr file, corresponds to a rs file
19+
"stdout", // expected stdout file, corresponds to a rs file
20+
"fixed", // expected source file after applying fixes
21+
"md", // test directory descriptions
22+
"ftl", // translation tests
23+
];
24+
25+
const EXTENSION_EXCEPTION_PATHS: &[&str] = &[
26+
"tests/ui/asm/named-asm-labels.s", // loading an external asm file to test named labels lint
27+
"tests/ui/check-cfg/my-awesome-platform.json", // testing custom targets with cfgs
28+
"tests/ui/commandline-argfile-badutf8.args", // passing args via a file
29+
"tests/ui/commandline-argfile.args", // passing args via a file
30+
"tests/ui/crate-loading/auxiliary/libfoo.rlib", // testing loading a manually created rlib
31+
"tests/ui/include-macros/data.bin", // testing including data with the include macros
32+
"tests/ui/include-macros/file.txt", // testing including data with the include macros
33+
"tests/ui/macros/macro-expanded-include/file.txt", // testing including data with the include macros
34+
"tests/ui/macros/not-utf8.bin", // testing including data with the include macros
35+
"tests/ui/macros/syntax-extension-source-utils-files/includeme.fragment", // more include
36+
"tests/ui/unused-crate-deps/test.mk", // why would you use make
37+
"tests/ui/proc-macro/auxiliary/included-file.txt", // more include
38+
];
1439

1540
fn check_entries(tests_path: &Path, bad: &mut bool) {
1641
let mut directories: HashMap<PathBuf, usize> = HashMap::new();
@@ -66,7 +91,14 @@ pub fn check(path: &Path, bad: &mut bool) {
6691
let paths = [ui.as_path(), ui_fulldeps.as_path()];
6792
crate::walk::walk_no_read(&paths, |_, _| false, &mut |entry| {
6893
let file_path = entry.path();
69-
if let Some(ext) = file_path.extension() {
94+
if let Some(ext) = file_path.extension().and_then(OsStr::to_str) {
95+
// files that are neither an expected extension or an exception should not exist
96+
// they're probably typos or not meant to exist
97+
if !(EXPECTED_TEST_FILE_EXTENSIONS.contains(&ext)
98+
|| EXTENSION_EXCEPTION_PATHS.iter().any(|path| file_path.ends_with(path)))
99+
{
100+
tidy_error!(bad, "file {} has unexpected extension {}", file_path.display(), ext);
101+
}
70102
if ext == "stderr" || ext == "stdout" {
71103
// Test output filenames have one of the formats:
72104
// ```
File renamed without changes.

tests/ui/attr-bad-crate-attr.stderr

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: expected item after attributes
2+
--> $DIR/attr-bad-crate-attr.rs:4:1
3+
|
4+
LL | #[attr = "val"] // Unterminated
5+
| ^^^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
1+
// run-pass
2+
13
// Regression test for a problem with the first mod attribute
24
// being applied to every mod
35

46
// pretty-expanded FIXME #23616
57

68
#[cfg(target_os = "linux")]
7-
mod hello;
9+
mod hello {}
810

911
#[cfg(target_os = "macos")]
10-
mod hello;
12+
mod hello {}
1113

1214
#[cfg(target_os = "windows")]
13-
mod hello;
15+
mod hello {}
1416

1517
#[cfg(target_os = "freebsd")]
16-
mod hello;
18+
mod hello {}
1719

1820
#[cfg(target_os = "dragonfly")]
19-
mod hello;
21+
mod hello {}
2022

2123
#[cfg(target_os = "android")]
22-
mod hello;
24+
mod hello {}
2325

24-
pub fn main() { }
26+
fn main() {}

tests/ui/extern/auxiliary/invalid-utf8.txt

-1
This file was deleted.

tests/ui/feature-gates/auxiliary/debugger-visualizer.natvis

-3
This file was deleted.

tests/ui/issues/auxiliary/issue-3136-a.rc

-4
This file was deleted.

tests/ui/issues/auxiliary/issue-3136-a.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
#![crate_type = "lib"]
2+
13
trait x {
24
fn use_x<T>(&self);
35
}
46
struct y(());
57
impl x for y {
68
fn use_x<T>(&self) {
7-
struct foo { //~ ERROR quux
8-
i: ()
9+
struct foo {
10+
//~ ERROR quux
11+
i: (),
912
}
1013
fn new_foo<T>(i: ()) -> foo {
1114
foo { i: i }

tests/ui/issues/issue-3136-b.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// run-pass
2-
// aux-build:issue-3136-a.rc
2+
// aux-build:issue-3136-a.rs
33

44
// pretty-expanded FIXME #23616
55

tests/ui/kindck/kindck-send-unsafe.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
extern crate core;
22

3-
fn assert_send<T:Send>() { }
3+
fn assert_send<T: Send>() {}
4+
5+
fn test70() {
6+
assert_send::<*mut isize>();
7+
//~^ ERROR `*mut isize` cannot be sent between threads safely
8+
}
49

510
fn test71<'a>() {
611
assert_send::<*mut &'a isize>();
712
//~^ ERROR `*mut &'a isize` cannot be sent between threads safely
813
}
914

10-
fn main() {
11-
}
15+
fn main() {}

tests/ui/kindck/kindck-send-unsafe.rs~rust-lang_master

-12
This file was deleted.
+18-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
1-
error[E0277]: `*mut &'a isize` cannot be sent between threads safely
1+
error[E0277]: `*mut isize` cannot be sent between threads safely
22
--> $DIR/kindck-send-unsafe.rs:6:19
33
|
4+
LL | assert_send::<*mut isize>();
5+
| ^^^^^^^^^^ `*mut isize` cannot be sent between threads safely
6+
|
7+
= help: the trait `Send` is not implemented for `*mut isize`
8+
note: required by a bound in `assert_send`
9+
--> $DIR/kindck-send-unsafe.rs:3:19
10+
|
11+
LL | fn assert_send<T: Send>() {}
12+
| ^^^^ required by this bound in `assert_send`
13+
14+
error[E0277]: `*mut &'a isize` cannot be sent between threads safely
15+
--> $DIR/kindck-send-unsafe.rs:11:19
16+
|
417
LL | assert_send::<*mut &'a isize>();
518
| ^^^^^^^^^^^^^^ `*mut &'a isize` cannot be sent between threads safely
619
|
720
= help: the trait `Send` is not implemented for `*mut &'a isize`
821
note: required by a bound in `assert_send`
9-
--> $DIR/kindck-send-unsafe.rs:3:18
22+
--> $DIR/kindck-send-unsafe.rs:3:19
1023
|
11-
LL | fn assert_send<T:Send>() { }
12-
| ^^^^ required by this bound in `assert_send`
24+
LL | fn assert_send<T: Send>() {}
25+
| ^^^^ required by this bound in `assert_send`
1326

14-
error: aborting due to previous error
27+
error: aborting due to 2 previous errors
1528

1629
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)