Skip to content

Commit a8b1782

Browse files
authored
Make UI test annotations mandatory (#11421)
Follow-up of #11249. changelog: make UI tests annotations mandatory
2 parents 379c8f4 + 847bd67 commit a8b1782

File tree

2,368 files changed

+26957
-13615
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,368 files changed

+26957
-13615
lines changed

tests/compile-test.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl TestContext {
139139
}
140140
}
141141

142-
fn base_config(&self, test_dir: &str) -> Config {
142+
fn base_config(&self, test_dir: &str, mandatory_annotations: bool) -> Config {
143143
let target_dir = PathBuf::from(var_os("CARGO_TARGET_DIR").unwrap_or_else(|| "target".into()));
144144
let mut config = Config {
145145
output_conflict_handling: OutputConflictHandling::Error,
@@ -153,7 +153,11 @@ impl TestContext {
153153
};
154154
let defaults = config.comment_defaults.base();
155155
defaults.exit_status = None.into();
156-
defaults.require_annotations = None.into();
156+
if mandatory_annotations {
157+
defaults.require_annotations = Some(Spanned::dummy(true)).into();
158+
} else {
159+
defaults.require_annotations = None.into();
160+
}
157161
defaults.diagnostic_code_prefix = Some(Spanned::dummy("clippy::".into())).into();
158162
defaults.set_custom("rustfix", RustfixMode::Everything);
159163
if let Some(collector) = self.diagnostic_collector.clone() {
@@ -197,7 +201,7 @@ impl TestContext {
197201
}
198202

199203
fn run_ui(cx: &TestContext) {
200-
let mut config = cx.base_config("ui");
204+
let mut config = cx.base_config("ui", true);
201205
config
202206
.program
203207
.envs
@@ -216,7 +220,7 @@ fn run_internal_tests(cx: &TestContext) {
216220
if !RUN_INTERNAL_TESTS {
217221
return;
218222
}
219-
let mut config = cx.base_config("ui-internal");
223+
let mut config = cx.base_config("ui-internal", false);
220224
config.bless_command = Some("cargo uitest --features internal -- -- --bless".into());
221225

222226
ui_test::run_tests_generic(
@@ -229,7 +233,7 @@ fn run_internal_tests(cx: &TestContext) {
229233
}
230234

231235
fn run_ui_toml(cx: &TestContext) {
232-
let mut config = cx.base_config("ui-toml");
236+
let mut config = cx.base_config("ui-toml", true);
233237

234238
config
235239
.comment_defaults
@@ -259,7 +263,7 @@ fn run_ui_cargo(cx: &TestContext) {
259263
return;
260264
}
261265

262-
let mut config = cx.base_config("ui-cargo");
266+
let mut config = cx.base_config("ui-cargo", false);
263267
config.program.input_file_flag = CommandBuilder::cargo().input_file_flag;
264268
config.program.out_dir_flag = CommandBuilder::cargo().out_dir_flag;
265269
config.program.args = vec!["clippy".into(), "--color".into(), "never".into(), "--quiet".into()];

tests/ui-toml/absolute_paths/absolute_paths_2015.default.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: consider bringing this path into scope with the `use` keyword
2-
--> tests/ui-toml/absolute_paths/absolute_paths_2015.rs:15:13
2+
--> tests/ui-toml/absolute_paths/absolute_paths_2015.rs:16:13
33
|
44
LL | let _ = ::m1::m2::X;
55
| ^^^^^^^^^^^
66
|
77
note: the lint level is defined here
8-
--> tests/ui-toml/absolute_paths/absolute_paths_2015.rs:6:9
8+
--> tests/ui-toml/absolute_paths/absolute_paths_2015.rs:7:9
99
|
1010
LL | #![deny(clippy::absolute_paths)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^

tests/ui-toml/absolute_paths/absolute_paths_2015.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@revisions: default allow_crates
22
//@[default]rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/absolute_paths/default
33
//@[allow_crates]rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/absolute_paths/allow_crates
4+
//@[allow_crates]check-pass
45
//@edition:2015
56

67
#![deny(clippy::absolute_paths)]

tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.fixed

+6
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@ fn main() {
77
let local_opt: Option<i32> = Some(3);
88

99
println!("val='{local_i32}'");
10+
//~^ uninlined_format_args
1011
println!("Hello x is {local_f64:.local_i32$}");
12+
//~^ uninlined_format_args
13+
//~| print_literal
1114
println!("Hello {local_i32} is {local_f64:.*}", 5);
15+
//~^ uninlined_format_args
1216
println!("Hello {local_i32} is {local_f64:.*}", 5);
17+
//~^ uninlined_format_args
1318
println!("{local_i32}, {}", local_opt.unwrap());
19+
//~^ uninlined_format_args
1420
}

tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs

+6
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@ fn main() {
77
let local_opt: Option<i32> = Some(3);
88

99
println!("val='{}'", local_i32);
10+
//~^ uninlined_format_args
1011
println!("Hello {} is {:.*}", "x", local_i32, local_f64);
12+
//~^ uninlined_format_args
13+
//~| print_literal
1114
println!("Hello {} is {:.*}", local_i32, 5, local_f64);
15+
//~^ uninlined_format_args
1216
println!("Hello {} is {2:.*}", local_i32, 5, local_f64);
17+
//~^ uninlined_format_args
1318
println!("{}, {}", local_i32, local_opt.unwrap());
19+
//~^ uninlined_format_args
1420
}

tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ LL + println!("val='{local_i32}'");
1313
|
1414

1515
error: variables can be used directly in the `format!` string
16-
--> tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs:10:5
16+
--> tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs:11:5
1717
|
1818
LL | println!("Hello {} is {:.*}", "x", local_i32, local_f64);
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -25,7 +25,7 @@ LL + println!("Hello {} is {local_f64:.local_i32$}", "x");
2525
|
2626

2727
error: literal with an empty format string
28-
--> tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs:10:35
28+
--> tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs:11:35
2929
|
3030
LL | println!("Hello {} is {:.*}", "x", local_i32, local_f64);
3131
| ^^^
@@ -39,7 +39,7 @@ LL + println!("Hello x is {:.*}", local_i32, local_f64);
3939
|
4040

4141
error: variables can be used directly in the `format!` string
42-
--> tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs:11:5
42+
--> tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs:14:5
4343
|
4444
LL | println!("Hello {} is {:.*}", local_i32, 5, local_f64);
4545
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -51,7 +51,7 @@ LL + println!("Hello {local_i32} is {local_f64:.*}", 5);
5151
|
5252

5353
error: variables can be used directly in the `format!` string
54-
--> tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs:12:5
54+
--> tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs:16:5
5555
|
5656
LL | println!("Hello {} is {2:.*}", local_i32, 5, local_f64);
5757
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -63,7 +63,7 @@ LL + println!("Hello {local_i32} is {local_f64:.*}", 5);
6363
|
6464

6565
error: variables can be used directly in the `format!` string
66-
--> tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs:13:5
66+
--> tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs:18:5
6767
|
6868
LL | println!("{}, {}", local_i32, local_opt.unwrap());
6969
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/ui-toml/arbitrary_source_item_ordering/ordering_good.rs

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
//@[bad_conf_1] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/arbitrary_source_item_ordering/bad_conf_1
66
//@[bad_conf_2] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/arbitrary_source_item_ordering/bad_conf_2
77
//@[bad_conf_3] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/arbitrary_source_item_ordering/bad_conf_3
8+
//@[default] check-pass
9+
//@[default_exp] check-pass
10+
//@[bad_conf_1] error-in-other-file:
11+
//@[bad_conf_2] error-in-other-file:
12+
//@[bad_conf_3] error-in-other-file:
813

914
#![allow(dead_code)]
1015
#![warn(clippy::arbitrary_source_item_ordering)]

tests/ui-toml/arbitrary_source_item_ordering/ordering_good_var_1.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@aux-build:../../ui/auxiliary/proc_macros.rs
22
//@revisions: var_1
33
//@[var_1] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/arbitrary_source_item_ordering/var_1
4+
//@check-pass
45

56
#![allow(dead_code)]
67
#![warn(clippy::arbitrary_source_item_ordering)]

0 commit comments

Comments
 (0)