Skip to content

Add a test that checks for old style test headers #10705

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
Jun 5, 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
29 changes: 29 additions & 0 deletions tests/headers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use regex::Regex;
use std::fs;
use walkdir::WalkDir;

#[test]
fn old_test_headers() {
let old_headers = Regex::new(
r"^//( ?\[\w+\])? ?((check|build|run|ignore|aux|only|needs|rustc|unset|no|normalize|run|compile)-|edition|incremental|revisions).*",
)
.unwrap();
let mut failed = false;

for entry in WalkDir::new("tests") {
let entry = entry.unwrap();
if !entry.file_type().is_file() {
continue;
}

let file = fs::read_to_string(entry.path()).unwrap();

if let Some(header) = old_headers.find(&file) {
println!("Found header `{}` in {}", header.as_str(), entry.path().display());

failed = true;
}
}

assert!(!failed, "use `//@foo` style test headers instead");
}
2 changes: 1 addition & 1 deletion tests/ui/crashes/ice-10645.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// compile-flags: --cap-lints=warn
//@compile-flags: --cap-lints=warn
// https://github.com/rust-lang/rust-clippy/issues/10645

#![warn(clippy::future_not_send)]
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/crashes/ice-10645.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: future cannot be sent between threads safely
warning: future cannot be sent between threads safely
--> $DIR/ice-10645.rs:5:35
|
LL | pub async fn bar<'a, T: 'a>(_: T) {}
Expand All @@ -12,5 +12,5 @@ LL | pub async fn bar<'a, T: 'a>(_: T) {}
= note: `T` doesn't implement `std::marker::Send`
= note: `-D clippy::future-not-send` implied by `-D warnings`

error: aborting due to previous error
warning: 1 warning emitted

2 changes: 0 additions & 2 deletions tests/ui/crashes/ice-4968.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//@check-pass

// Test for https://github.com/rust-lang/rust-clippy/issues/4968

#![warn(clippy::unsound_collection_transmute)]
Expand Down
1 change: 0 additions & 1 deletion tests/ui/expect_tool_lint_rfc_2383.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// check-pass
#![feature(lint_reasons)]
//! This file tests the `#[expect]` attribute implementation for tool lints. The same
//! file is used to test clippy and rustdoc. Any changes to this file should be synced
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/expect_tool_lint_rfc_2383.stderr
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
error: this lint expectation is unfulfilled
--> $DIR/expect_tool_lint_rfc_2383.rs:35:14
--> $DIR/expect_tool_lint_rfc_2383.rs:34:14
|
LL | #[expect(dead_code)]
| ^^^^^^^^^
|
= note: `-D unfulfilled-lint-expectations` implied by `-D warnings`

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

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

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

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

error: this lint expectation is unfulfilled
--> $DIR/expect_tool_lint_rfc_2383.rs:130:14
--> $DIR/expect_tool_lint_rfc_2383.rs:129:14
|
LL | #[expect(clippy::overly_complex_bool_expr)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down