Skip to content

Commit 8a86027

Browse files
committed
test: Blanket use of hint-mostly-unused
1 parent 706cae0 commit 8a86027

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
use crate::prelude::*;
2+
use cargo_test_support::project;
3+
use cargo_test_support::str;
4+
5+
#[cargo_test(nightly, reason = "-Zhint-mostly-unused is unstable")]
6+
fn named_profile_blanket() {
7+
let p = project()
8+
.file(
9+
"Cargo.toml",
10+
r#"
11+
[package]
12+
name = "foo"
13+
version = "0.0.1"
14+
edition = "2015"
15+
16+
[profile.dev]
17+
hint-mostly-unused = true
18+
"#,
19+
)
20+
.file("src/main.rs", "fn main() {}")
21+
.build();
22+
p.cargo("check -Zprofile-hint-mostly-unused -v")
23+
.masquerade_as_nightly_cargo(&["profile-hint-mostly-unused", "cargo-lints"])
24+
.with_stderr_data(str![[r#"
25+
[CHECKING] foo v0.0.1 ([ROOT]/foo)
26+
[RUNNING] `rustc --crate-name foo [..]`
27+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
28+
29+
"#]])
30+
.run();
31+
}
32+
33+
#[cargo_test(nightly, reason = "-Zhint-mostly-unused is unstable")]
34+
fn profile_package_wildcard() {
35+
let p = project()
36+
.file(
37+
"Cargo.toml",
38+
r#"
39+
[package]
40+
name = "foo"
41+
version = "0.0.1"
42+
edition = "2015"
43+
44+
[profile.dev.package."*"]
45+
hint-mostly-unused = true
46+
"#,
47+
)
48+
.file("src/main.rs", "fn main() {}")
49+
.build();
50+
p.cargo("check -Zprofile-hint-mostly-unused -v")
51+
.masquerade_as_nightly_cargo(&["profile-hint-mostly-unused", "cargo-lints"])
52+
.with_stderr_data(str![[r#"
53+
[CHECKING] foo v0.0.1 ([ROOT]/foo)
54+
[RUNNING] `rustc --crate-name foo [..]`
55+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
56+
57+
"#]])
58+
.run();
59+
}
60+
61+
#[cargo_test(nightly, reason = "-Zhint-mostly-unused is unstable")]
62+
fn profile_build_override() {
63+
let p = project()
64+
.file(
65+
"Cargo.toml",
66+
r#"
67+
[package]
68+
name = "foo"
69+
version = "0.0.1"
70+
edition = "2015"
71+
72+
[profile.dev.build-override]
73+
hint-mostly-unused = true
74+
"#,
75+
)
76+
.file("src/main.rs", "fn main() {}")
77+
.build();
78+
p.cargo("check -Zprofile-hint-mostly-unused -v")
79+
.masquerade_as_nightly_cargo(&["profile-hint-mostly-unused", "cargo-lints"])
80+
.with_stderr_data(str![[r#"
81+
[CHECKING] foo v0.0.1 ([ROOT]/foo)
82+
[RUNNING] `rustc --crate-name foo [..]`
83+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
84+
85+
"#]])
86+
.run();
87+
}
88+
89+
#[cargo_test(nightly, reason = "-Zhint-mostly-unused is unstable")]
90+
fn workspace_profile_package_wildcard() {
91+
let p = project()
92+
.file(
93+
"Cargo.toml",
94+
r#"
95+
[workspace]
96+
members = ["foo"]
97+
98+
[profile.dev.package."*"]
99+
hint-mostly-unused = true
100+
"#,
101+
)
102+
.file(
103+
"foo/Cargo.toml",
104+
r#"
105+
[package]
106+
name = "foo"
107+
version = "0.0.1"
108+
edition = "2015"
109+
authors = []
110+
"#,
111+
)
112+
.file("foo/src/lib.rs", "")
113+
.build();
114+
115+
p.cargo("check -Zprofile-hint-mostly-unused -v")
116+
.masquerade_as_nightly_cargo(&["profile-hint-mostly-unused", "cargo-lints"])
117+
.with_stderr_data(str![[r#"
118+
[CHECKING] foo v0.0.1 ([ROOT]/foo/foo)
119+
[RUNNING] `rustc --crate-name foo [..]`
120+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
121+
122+
"#]])
123+
.run();
124+
}

tests/testsuite/lints/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use cargo_test_support::project;
33
use cargo_test_support::registry::Package;
44
use cargo_test_support::str;
55

6+
mod blanket_hint_mostly_unused;
67
mod error;
78
mod inherited;
89
mod unknown_lints;

0 commit comments

Comments
 (0)