Skip to content

Commit 3c25c49

Browse files
Add a clippy test to minicrater
The test runs crater in `clippy` mode and compares `stable` with `stable+rustflags=-Dclippy::all` so that a regression will appear when clippy would emit a warning on a crate. Also adds a new local crate which compiles succesfully but causes clippy to emit a warning.
1 parent ec1877d commit 3c25c49

File tree

6 files changed

+101
-9
lines changed

6 files changed

+101
-9
lines changed

local-crates/clippy-warn/Cargo.toml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "clippy-warn"
3+
version = "0.1.0"
4+
authors = ["Dylan MacKenzie <[email protected]>"]
5+
edition = "2018"
6+
7+
[dependencies]

local-crates/clippy-warn/src/main.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
// Trigger `clippy::print_with_newline`
3+
print!("Hello, world!\n");
4+
}

tests/minicrater/clippy/config.toml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[server]
2+
bot-acl = [
3+
"pietroalbini",
4+
]
5+
6+
[server.labels]
7+
remove = "^S-"
8+
experiment-queued = "S-waiting-on-crater"
9+
experiment-completed = "S-waiting-on-review"
10+
11+
[demo-crates]
12+
crates = []
13+
github-repos = []
14+
local-crates = ["build-pass", "clippy-warn"]
15+
16+
[sandbox]
17+
memory-limit = "512M"
18+
build-log-max-size = "2M"
19+
build-log-max-lines = 1000
20+
21+
[crates]
22+
23+
[github-repos]
24+
25+
[local-crates]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"crates": [
3+
{
4+
"name": "build-pass (local)",
5+
"res": "test-pass",
6+
"runs": [
7+
{
8+
"log": "stable/local/build-pass",
9+
"res": "test-pass"
10+
},
11+
{
12+
"log": "stable%2Brustflags=-Dclippy::all/local/build-pass",
13+
"res": "test-pass"
14+
}
15+
],
16+
"url": "https://github.com/rust-lang-nursery/crater/tree/master/local-crates/build-pass"
17+
},
18+
{
19+
"name": "clippy-warn (local)",
20+
"res": "regressed",
21+
"runs": [
22+
{
23+
"log": "stable/local/clippy-warn",
24+
"res": "test-pass"
25+
},
26+
{
27+
"log": "stable%2Brustflags=-Dclippy::all/local/clippy-warn",
28+
"res": "build-fail:unknown"
29+
}
30+
],
31+
"url": "https://github.com/rust-lang-nursery/crater/tree/master/local-crates/clippy-warn"
32+
}
33+
]
34+
}

tests/minicrater/driver.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ pub(super) struct MinicraterRun {
2626
pub(super) crate_select: &'static str,
2727
pub(super) multithread: bool,
2828
pub(super) ignore_blacklist: bool,
29+
pub(super) mode: &'static str,
30+
pub(super) toolchains: &'static [&'static str],
31+
}
32+
33+
impl Default for MinicraterRun {
34+
fn default() -> Self {
35+
MinicraterRun {
36+
ex: "default",
37+
crate_select: "demo",
38+
multithread: false,
39+
ignore_blacklist: false,
40+
mode: "build-and-test",
41+
toolchains: &["stable", "beta"],
42+
}
43+
}
2944
}
3045

3146
impl MinicraterRun {
@@ -54,8 +69,10 @@ impl MinicraterRun {
5469
.minicrater_exec();
5570

5671
// Define the experiment
72+
let mode = format!("--mode={}", self.mode);
5773
let crate_select = format!("--crate-select={}", self.crate_select);
58-
let mut define_args = vec!["define-ex", &ex_arg, "stable", "beta", &crate_select];
74+
let mut define_args = vec!["define-ex", &ex_arg, &crate_select, &mode];
75+
define_args.extend(self.toolchains);
5976
if self.ignore_blacklist {
6077
define_args.push("--ignore-blacklist");
6178
}

tests/minicrater/mod.rs

+13-8
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,40 @@ minicrater! {
55
single_thread_small {
66
ex: "small",
77
crate_select: "demo",
8-
multithread: false,
9-
ignore_blacklist: false,
8+
..Default::default()
109
},
1110

1211
single_thread_full {
1312
ex: "full",
1413
crate_select: "local",
15-
multithread: false,
16-
ignore_blacklist: false,
14+
..Default::default()
1715
},
1816

1917
single_thread_blacklist {
2018
ex: "blacklist",
2119
crate_select: "demo",
22-
multithread: false,
23-
ignore_blacklist: false,
20+
..Default::default()
2421
},
2522

2623
single_thread_ignore_blacklist {
2724
ex: "ignore-blacklist",
2825
crate_select: "demo",
29-
multithread: false,
3026
ignore_blacklist: true,
27+
..Default::default()
3128
},
3229

3330
multi_thread_full {
3431
ex: "full",
3532
crate_select: "local",
3633
multithread: true,
37-
ignore_blacklist: false,
34+
..Default::default()
35+
},
36+
37+
clippy_small {
38+
ex: "clippy",
39+
crate_select: "demo",
40+
mode: "clippy",
41+
toolchains: &["stable", "stable+rustflags=-Dclippy::all"],
42+
..Default::default()
3843
},
3944
}

0 commit comments

Comments
 (0)