Skip to content

Commit aea7484

Browse files
committed
Make all tests reliable by giving each test its own target directory and env vars
1 parent 2937ea5 commit aea7484

File tree

49 files changed

+934
-630
lines changed

Some content is hidden

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

49 files changed

+934
-630
lines changed

tests/compile-test.rs

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,18 @@ fn run_ui_toml() {
110110
"$$DIR",
111111
);
112112

113-
ui_test::run_tests(config).unwrap();
113+
ui_test::run_tests_generic(
114+
config,
115+
|path| path.ends_with(".rs"),
116+
|config, path| {
117+
let mut config = config.clone();
118+
config
119+
.envs
120+
.push(("CLIPPY_CONF_DIR".into(), path.parent().unwrap().into()));
121+
Some(config)
122+
},
123+
)
124+
.unwrap();
114125
}
115126

116127
fn run_ui_cargo() {
@@ -119,15 +130,7 @@ fn run_ui_cargo() {
119130
}
120131

121132
let mut config = base_config("ui-cargo");
122-
config.args = vec![
123-
"clippy".into(),
124-
"--color".into(),
125-
"never".into(),
126-
"--quiet".into(),
127-
"--target-dir".into(),
128-
"target/ui_test_cargo".into(),
129-
"--manifest-path".into(),
130-
];
133+
config.args = vec!["clippy".into(), "--color".into(), "never".into(), "--quiet".into()];
131134
// We need to do this while we still have a rustc in the `program` field.
132135
config.fill_host_and_target();
133136
config.program.set_file_name(if cfg!(windows) {
@@ -150,7 +153,20 @@ fn run_ui_cargo() {
150153
.to_string(),
151154
"$$DIR",
152155
);
153-
ui_test::run_tests_generic(config, |path| path.ends_with("Cargo.toml")).unwrap();
156+
ui_test::run_tests_generic(
157+
config,
158+
|path| path.ends_with("Cargo.toml"),
159+
|config, path| {
160+
let mut config = config.clone();
161+
config.args.extend([
162+
"--target-dir".into(),
163+
format!("target/ui_test_cargo/{}", path.parent().unwrap().display()).into(),
164+
"--manifest-path".into(),
165+
]);
166+
Some(config)
167+
},
168+
)
169+
.unwrap();
154170
}
155171

156172
fn main() {

tests/ui-cargo/feature_name/pass/Cargo.stderr

Lines changed: 0 additions & 50 deletions
This file was deleted.

tests/ui-cargo/wildcard_dependencies/pass/Cargo.stderr

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.fixed

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ fn main() {
77
let local_opt: Option<i32> = Some(3);
88

99
println!("val='{local_i32}'");
10-
println!("Hello x is {:.*}", local_i32, local_f64);
11-
println!("Hello {} is {:.*}", local_i32, 5, local_f64);
12-
println!("Hello {} is {2:.*}", local_i32, 5, local_f64);
13-
println!("{}, {}", local_i32, local_opt.unwrap());
10+
println!("Hello x is {local_f64:.local_i32$}");
11+
println!("Hello {local_i32} is {local_f64:.*}", 5);
12+
println!("Hello {local_i32} is {local_f64:.*}", 5);
13+
println!("{local_i32}, {}", local_opt.unwrap());
1414
}

tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,53 @@ LL - println!("Hello {} is {:.*}", "x", local_i32, local_f64);
2828
LL + println!("Hello x is {:.*}", local_i32, local_f64);
2929
|
3030

31-
warning: 2 warnings emitted
31+
warning: variables can be used directly in the `format!` string
32+
--> $DIR/uninlined_format_args.rs:10:5
33+
|
34+
LL | println!("Hello {} is {:.*}", "x", local_i32, local_f64);
35+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
36+
|
37+
help: change this to
38+
|
39+
LL - println!("Hello {} is {:.*}", "x", local_i32, local_f64);
40+
LL + println!("Hello {} is {local_f64:.local_i32$}", "x");
41+
|
42+
43+
warning: variables can be used directly in the `format!` string
44+
--> $DIR/uninlined_format_args.rs:11:5
45+
|
46+
LL | println!("Hello {} is {:.*}", local_i32, 5, local_f64);
47+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
48+
|
49+
help: change this to
50+
|
51+
LL - println!("Hello {} is {:.*}", local_i32, 5, local_f64);
52+
LL + println!("Hello {local_i32} is {local_f64:.*}", 5);
53+
|
54+
55+
warning: variables can be used directly in the `format!` string
56+
--> $DIR/uninlined_format_args.rs:12:5
57+
|
58+
LL | println!("Hello {} is {2:.*}", local_i32, 5, local_f64);
59+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
60+
|
61+
help: change this to
62+
|
63+
LL - println!("Hello {} is {2:.*}", local_i32, 5, local_f64);
64+
LL + println!("Hello {local_i32} is {local_f64:.*}", 5);
65+
|
66+
67+
warning: variables can be used directly in the `format!` string
68+
--> $DIR/uninlined_format_args.rs:13:5
69+
|
70+
LL | println!("{}, {}", local_i32, local_opt.unwrap());
71+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
72+
|
73+
help: change this to
74+
|
75+
LL - println!("{}, {}", local_i32, local_opt.unwrap());
76+
LL + println!("{local_i32}, {}", local_opt.unwrap());
77+
|
78+
79+
warning: 6 warnings emitted
3280

Lines changed: 4 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,15 @@
11
warning: arithmetic operation that can potentially result in unexpected side-effects
2-
--> $DIR/arithmetic_side_effects_allowed.rs:62:13
2+
--> $DIR/arithmetic_side_effects_allowed.rs:68:13
33
|
4-
LL | let _ = OutOfNames + OutOfNames;
5-
| ^^^^^^^^^^^^^^^^^^^^^^^
4+
LL | let _ = Baz + Baz;
5+
| ^^^^^^^^^
66
|
77
note: the lint level is defined here
88
--> $DIR/arithmetic_side_effects_allowed.rs:1:9
99
|
1010
LL | #![warn(clippy::arithmetic_side_effects)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

13-
warning: arithmetic operation that can potentially result in unexpected side-effects
14-
--> $DIR/arithmetic_side_effects_allowed.rs:64:13
15-
|
16-
LL | let _ = Foo + Foo;
17-
| ^^^^^^^^^
18-
19-
warning: arithmetic operation that can potentially result in unexpected side-effects
20-
--> $DIR/arithmetic_side_effects_allowed.rs:66:13
21-
|
22-
LL | let _ = Bar + Bar;
23-
| ^^^^^^^^^
24-
25-
warning: arithmetic operation that can potentially result in unexpected side-effects
26-
--> $DIR/arithmetic_side_effects_allowed.rs:68:13
27-
|
28-
LL | let _ = Baz + Baz;
29-
| ^^^^^^^^^
30-
31-
warning: arithmetic operation that can potentially result in unexpected side-effects
32-
--> $DIR/arithmetic_side_effects_allowed.rs:73:13
33-
|
34-
LL | let _ = 1i32 + OutOfNames;
35-
| ^^^^^^^^^^^^^^^^^
36-
37-
warning: arithmetic operation that can potentially result in unexpected side-effects
38-
--> $DIR/arithmetic_side_effects_allowed.rs:75:13
39-
|
40-
LL | let _ = 1i32 + Foo;
41-
| ^^^^^^^^^^
42-
43-
warning: arithmetic operation that can potentially result in unexpected side-effects
44-
--> $DIR/arithmetic_side_effects_allowed.rs:77:13
45-
|
46-
LL | let _ = 1i32 + Bar;
47-
| ^^^^^^^^^^
48-
4913
warning: arithmetic operation that can potentially result in unexpected side-effects
5014
--> $DIR/arithmetic_side_effects_allowed.rs:79:13
5115
|
@@ -58,36 +22,12 @@ warning: arithmetic operation that can potentially result in unexpected side-eff
5822
LL | let _ = 1i64 + Foo;
5923
| ^^^^^^^^^^
6024

61-
warning: arithmetic operation that can potentially result in unexpected side-effects
62-
--> $DIR/arithmetic_side_effects_allowed.rs:84:13
63-
|
64-
LL | let _ = 1i64 + Bar;
65-
| ^^^^^^^^^^
66-
6725
warning: arithmetic operation that can potentially result in unexpected side-effects
6826
--> $DIR/arithmetic_side_effects_allowed.rs:86:13
6927
|
7028
LL | let _ = 1i64 + Baz;
7129
| ^^^^^^^^^^
7230

73-
warning: arithmetic operation that can potentially result in unexpected side-effects
74-
--> $DIR/arithmetic_side_effects_allowed.rs:91:13
75-
|
76-
LL | let _ = OutOfNames + 1i32;
77-
| ^^^^^^^^^^^^^^^^^
78-
79-
warning: arithmetic operation that can potentially result in unexpected side-effects
80-
--> $DIR/arithmetic_side_effects_allowed.rs:93:13
81-
|
82-
LL | let _ = Foo + 1i32;
83-
| ^^^^^^^^^^
84-
85-
warning: arithmetic operation that can potentially result in unexpected side-effects
86-
--> $DIR/arithmetic_side_effects_allowed.rs:95:13
87-
|
88-
LL | let _ = Bar + 1i32;
89-
| ^^^^^^^^^^
90-
9131
warning: arithmetic operation that can potentially result in unexpected side-effects
9232
--> $DIR/arithmetic_side_effects_allowed.rs:97:13
9333
|
@@ -100,30 +40,12 @@ warning: arithmetic operation that can potentially result in unexpected side-eff
10040
LL | let _ = Foo + 1i64;
10141
| ^^^^^^^^^^
10242

103-
warning: arithmetic operation that can potentially result in unexpected side-effects
104-
--> $DIR/arithmetic_side_effects_allowed.rs:102:13
105-
|
106-
LL | let _ = Bar + 1i64;
107-
| ^^^^^^^^^^
108-
10943
warning: arithmetic operation that can potentially result in unexpected side-effects
11044
--> $DIR/arithmetic_side_effects_allowed.rs:104:13
11145
|
11246
LL | let _ = Baz + 1i64;
11347
| ^^^^^^^^^^
11448

115-
warning: arithmetic operation that can potentially result in unexpected side-effects
116-
--> $DIR/arithmetic_side_effects_allowed.rs:109:13
117-
|
118-
LL | let _ = -OutOfNames;
119-
| ^^^^^^^^^^^
120-
121-
warning: arithmetic operation that can potentially result in unexpected side-effects
122-
--> $DIR/arithmetic_side_effects_allowed.rs:111:13
123-
|
124-
LL | let _ = -Foo;
125-
| ^^^^
126-
12749
warning: arithmetic operation that can potentially result in unexpected side-effects
12850
--> $DIR/arithmetic_side_effects_allowed.rs:113:13
12951
|
@@ -136,5 +58,5 @@ warning: arithmetic operation that can potentially result in unexpected side-eff
13658
LL | let _ = -Baz;
13759
| ^^^^
13860

139-
warning: 22 warnings emitted
61+
warning: 9 warnings emitted
14062

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
warning: large array defined as const
2+
--> $DIR/array_size_threshold.rs:4:1
3+
|
4+
LL | const ABOVE: [u8; 11] = [0; 11];
5+
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
| |
7+
| help: make this a static item: `static`
8+
|
9+
note: the lint level is defined here
10+
--> $DIR/array_size_threshold.rs:2:9
11+
|
12+
LL | #![warn(clippy::large_const_arrays, clippy::large_stack_arrays)]
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
15+
warning: allocating a local array larger than 10 bytes
16+
--> $DIR/array_size_threshold.rs:4:25
17+
|
18+
LL | const ABOVE: [u8; 11] = [0; 11];
19+
| ^^^^^^^
20+
|
21+
= help: consider allocating on the heap with `vec![0; 11].into_boxed_slice()`
22+
note: the lint level is defined here
23+
--> $DIR/array_size_threshold.rs:2:37
24+
|
25+
LL | #![warn(clippy::large_const_arrays, clippy::large_stack_arrays)]
26+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
27+
28+
warning: allocating a local array larger than 10 bytes
29+
--> $DIR/array_size_threshold.rs:8:17
30+
|
31+
LL | let above = [0u8; 11];
32+
| ^^^^^^^^^
33+
|
34+
= help: consider allocating on the heap with `vec![0u8; 11].into_boxed_slice()`
35+
36+
warning: 3 warnings emitted
37+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
warning: `std::string::String` may not be held across an `await` point per `clippy.toml`
2+
--> $DIR/await_holding_invalid_type.rs:5:9
3+
|
4+
LL | let _x = String::from("hello");
5+
| ^^
6+
|
7+
= note: strings are bad (from clippy.toml)
8+
note: the lint level is defined here
9+
--> $DIR/await_holding_invalid_type.rs:1:9
10+
|
11+
LL | #![warn(clippy::await_holding_invalid_type)]
12+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13+
14+
warning: `std::net::Ipv4Addr` may not be held across an `await` point per `clippy.toml`
15+
--> $DIR/await_holding_invalid_type.rs:10:9
16+
|
17+
LL | let _x = Ipv4Addr::new(127, 0, 0, 1);
18+
| ^^
19+
20+
warning: `std::string::String` may not be held across an `await` point per `clippy.toml`
21+
--> $DIR/await_holding_invalid_type.rs:31:13
22+
|
23+
LL | let _x = String::from("hi!");
24+
| ^^
25+
|
26+
= note: strings are bad (from clippy.toml)
27+
28+
warning: 3 warnings emitted
29+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
//@error-pattern: expected an equals, found an identifier at line 1 column 4
2+
13
fn main() {}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
error: error reading Clippy's configuration file `/home/ubuntu/crates/clippy/$DIR/clippy.toml`: expected an equals, found an identifier at line 1 column 4
2+
3+
error: aborting due to previous error
4+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
//@error-pattern: invalid type: integer `42`, expected a sequence for key `disallowed-names`
2+
13
fn main() {}

0 commit comments

Comments
 (0)