Skip to content

Commit 4895a40

Browse files
committed
Auto merge of rust-lang#10705 - Alexendoo:old-test-headers, r=flip1995
Add a test that checks for old style test headers Follow up to rust-lang#10669, we're pretty used to them so they're easy to slip through changelog: none
2 parents ae880e4 + b406766 commit 4895a40

6 files changed

+38
-12
lines changed

tests/headers.rs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use regex::Regex;
2+
use std::fs;
3+
use walkdir::WalkDir;
4+
5+
#[test]
6+
fn old_test_headers() {
7+
let old_headers = Regex::new(
8+
r"^//( ?\[\w+\])? ?((check|build|run|ignore|aux|only|needs|rustc|unset|no|normalize|run|compile)-|edition|incremental|revisions).*",
9+
)
10+
.unwrap();
11+
let mut failed = false;
12+
13+
for entry in WalkDir::new("tests") {
14+
let entry = entry.unwrap();
15+
if !entry.file_type().is_file() {
16+
continue;
17+
}
18+
19+
let file = fs::read_to_string(entry.path()).unwrap();
20+
21+
if let Some(header) = old_headers.find(&file) {
22+
println!("Found header `{}` in {}", header.as_str(), entry.path().display());
23+
24+
failed = true;
25+
}
26+
}
27+
28+
assert!(!failed, "use `//@foo` style test headers instead");
29+
}

tests/ui/crashes/ice-10645.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags: --cap-lints=warn
1+
//@compile-flags: --cap-lints=warn
22
// https://github.com/rust-lang/rust-clippy/issues/10645
33

44
#![warn(clippy::future_not_send)]

tests/ui/crashes/ice-10645.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: future cannot be sent between threads safely
1+
warning: future cannot be sent between threads safely
22
--> $DIR/ice-10645.rs:5:35
33
|
44
LL | pub async fn bar<'a, T: 'a>(_: T) {}
@@ -12,5 +12,5 @@ LL | pub async fn bar<'a, T: 'a>(_: T) {}
1212
= note: `T` doesn't implement `std::marker::Send`
1313
= note: `-D clippy::future-not-send` implied by `-D warnings`
1414

15-
error: aborting due to previous error
15+
warning: 1 warning emitted
1616

tests/ui/crashes/ice-4968.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//@check-pass
2-
31
// Test for https://github.com/rust-lang/rust-clippy/issues/4968
42

53
#![warn(clippy::unsound_collection_transmute)]

tests/ui/expect_tool_lint_rfc_2383.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// check-pass
21
#![feature(lint_reasons)]
32
//! This file tests the `#[expect]` attribute implementation for tool lints. The same
43
//! file is used to test clippy and rustdoc. Any changes to this file should be synced

tests/ui/expect_tool_lint_rfc_2383.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
error: this lint expectation is unfulfilled
2-
--> $DIR/expect_tool_lint_rfc_2383.rs:35:14
2+
--> $DIR/expect_tool_lint_rfc_2383.rs:34:14
33
|
44
LL | #[expect(dead_code)]
55
| ^^^^^^^^^
66
|
77
= note: `-D unfulfilled-lint-expectations` implied by `-D warnings`
88

99
error: this lint expectation is unfulfilled
10-
--> $DIR/expect_tool_lint_rfc_2383.rs:39:18
10+
--> $DIR/expect_tool_lint_rfc_2383.rs:38:18
1111
|
1212
LL | #[expect(illegal_floating_point_literal_pattern)]
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1414

1515
error: this lint expectation is unfulfilled
16-
--> $DIR/expect_tool_lint_rfc_2383.rs:113:14
16+
--> $DIR/expect_tool_lint_rfc_2383.rs:112:14
1717
|
1818
LL | #[expect(clippy::almost_swapped)]
1919
| ^^^^^^^^^^^^^^^^^^^^^^
2020

2121
error: this lint expectation is unfulfilled
22-
--> $DIR/expect_tool_lint_rfc_2383.rs:120:14
22+
--> $DIR/expect_tool_lint_rfc_2383.rs:119:14
2323
|
2424
LL | #[expect(clippy::bytes_nth)]
2525
| ^^^^^^^^^^^^^^^^^
2626

2727
error: this lint expectation is unfulfilled
28-
--> $DIR/expect_tool_lint_rfc_2383.rs:125:14
28+
--> $DIR/expect_tool_lint_rfc_2383.rs:124:14
2929
|
3030
LL | #[expect(clippy::if_same_then_else)]
3131
| ^^^^^^^^^^^^^^^^^^^^^^^^^
3232

3333
error: this lint expectation is unfulfilled
34-
--> $DIR/expect_tool_lint_rfc_2383.rs:130:14
34+
--> $DIR/expect_tool_lint_rfc_2383.rs:129:14
3535
|
3636
LL | #[expect(clippy::overly_complex_bool_expr)]
3737
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)