Skip to content

Commit c1f0c0b

Browse files
committed
refactor: Move off UI tests for individual lints
1 parent e6603b7 commit c1f0c0b

File tree

22 files changed

+387
-773
lines changed

22 files changed

+387
-773
lines changed
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
use cargo_test_support::project;
2+
use cargo_test_support::registry::Package;
3+
4+
#[cargo_test]
5+
fn default() {
6+
Package::new("bar", "0.1.0").publish();
7+
let p = project()
8+
.file(
9+
"Cargo.toml",
10+
r#"
11+
[package]
12+
name = "foo"
13+
version = "0.1.0"
14+
edition = "2021"
15+
16+
[dependencies]
17+
bar = { version = "0.1.0", optional = true }
18+
"#,
19+
)
20+
.file("src/lib.rs", "")
21+
.build();
22+
23+
p.cargo("check -Zcargo-lints")
24+
.masquerade_as_nightly_cargo(&["cargo-lints"])
25+
.with_stderr(
26+
"\
27+
[UPDATING] [..]
28+
[LOCKING] 2 packages to latest compatible versions
29+
[CHECKING] foo v0.1.0 ([CWD])
30+
[FINISHED] [..]
31+
",
32+
)
33+
.run();
34+
}
35+
36+
#[cargo_test]
37+
fn warn() {
38+
Package::new("bar", "0.1.0").publish();
39+
Package::new("baz", "0.1.0").publish();
40+
Package::new("target-dep", "0.1.0").publish();
41+
let p = project()
42+
.file(
43+
"Cargo.toml",
44+
r#"
45+
[package]
46+
name = "foo"
47+
version = "0.1.0"
48+
edition = "2021"
49+
50+
[dependencies]
51+
bar = { version = "0.1.0", optional = true }
52+
53+
[build-dependencies]
54+
baz = { version = "0.1.0", optional = true }
55+
56+
[target.'cfg(target_os = "linux")'.dependencies]
57+
target-dep = { version = "0.1.0", optional = true }
58+
59+
[lints.cargo]
60+
implicit_features = "warn"
61+
"#,
62+
)
63+
.file("src/lib.rs", "")
64+
.build();
65+
66+
p.cargo("check -Zcargo-lints")
67+
.masquerade_as_nightly_cargo(&["cargo-lints"])
68+
.with_stderr(
69+
"\
70+
warning: implicit features for optional dependencies is deprecated and will be unavailable in the 2024 edition
71+
--> Cargo.toml:8:1
72+
|
73+
8 | bar = { version = \"0.1.0\", optional = true }
74+
| ---
75+
|
76+
= note: `cargo::implicit_features` is set to `warn` in `[lints]`
77+
warning: implicit features for optional dependencies is deprecated and will be unavailable in the 2024 edition
78+
--> Cargo.toml:11:1
79+
|
80+
11 | baz = { version = \"0.1.0\", optional = true }
81+
| ---
82+
|
83+
warning: implicit features for optional dependencies is deprecated and will be unavailable in the 2024 edition
84+
--> Cargo.toml:14:1
85+
|
86+
14 | target-dep = { version = \"0.1.0\", optional = true }
87+
| ----------
88+
|
89+
[UPDATING] [..]
90+
[LOCKING] 4 packages to latest compatible versions
91+
[CHECKING] foo v0.1.0 ([CWD])
92+
[FINISHED] [..]
93+
",
94+
)
95+
.run();
96+
}
97+
98+
#[cargo_test(nightly, reason = "edition2024 is not stable")]
99+
fn implicit_features_edition_2024() {
100+
Package::new("bar", "0.1.0").publish();
101+
Package::new("baz", "0.1.0").publish();
102+
let p = project()
103+
.file(
104+
"Cargo.toml",
105+
r#"
106+
cargo-features = ["edition2024"]
107+
[package]
108+
name = "foo"
109+
version = "0.1.0"
110+
edition = "2024"
111+
112+
[dependencies]
113+
bar = { version = "0.1.0", optional = true }
114+
baz = { version = "0.1.0", optional = true }
115+
116+
[features]
117+
baz = ["dep:baz"]
118+
119+
[lints.cargo]
120+
unused_optional_dependency = "allow"
121+
"#,
122+
)
123+
.file("src/lib.rs", "")
124+
.build();
125+
126+
p.cargo("check -Zcargo-lints")
127+
.masquerade_as_nightly_cargo(&["cargo-lints", "edition2024"])
128+
.with_stderr(
129+
"\
130+
[UPDATING] [..]
131+
[LOCKING] 2 packages to latest Rust [..] compatible versions
132+
[CHECKING] foo v0.1.0 ([CWD])
133+
[FINISHED] [..]
134+
",
135+
)
136+
.run();
137+
}

tests/testsuite/lints/implicit_features/edition_2021/mod.rs

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

tests/testsuite/lints/implicit_features/edition_2021/stderr.term.svg

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

tests/testsuite/lints/implicit_features/edition_2021_warn/mod.rs

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

tests/testsuite/lints/implicit_features/edition_2021_warn/stderr.term.svg

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

tests/testsuite/lints/implicit_features/edition_2024/mod.rs

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

0 commit comments

Comments
 (0)