Skip to content

Commit cabd5eb

Browse files
committed
Auto merge of #14104 - eth3lbert:snapbox-lints, r=weihanglo
test: migrate lints_table and lints/(mod|unknown_lints) to snapbox ### What does this PR try to resolve? Part of #14039. Migrate followings to snapbox: - `tests/testsuite/lints/mod.rs` - `tests/testsuite/lints/unknown_lints.rs` - `tests/testsuite/lints_table.rs`
2 parents fb05646 + 6c4d59c commit cabd5eb

File tree

3 files changed

+162
-191
lines changed

3 files changed

+162
-191
lines changed

tests/testsuite/lints/mod.rs

Lines changed: 51 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
#![allow(deprecated)]
2-
31
use cargo_test_support::project;
42
use cargo_test_support::registry::Package;
3+
use cargo_test_support::str;
54

65
mod error;
76
mod implicit_features;
@@ -34,20 +33,19 @@ im-a-teapot = "warn"
3433

3534
foo.cargo("check -Zcargo-lints")
3635
.masquerade_as_nightly_cargo(&["cargo-lints", "test-dummy-unstable"])
37-
.with_stderr(
38-
"\
39-
warning: unknown lint: `im-a-teapot`
36+
.with_stderr_data(str![[r#"
37+
[WARNING] unknown lint: `im-a-teapot`
4038
--> Cargo.toml:12:1
4139
|
42-
12 | im-a-teapot = \"warn\"
40+
12 | im-a-teapot = "warn"
4341
| ^^^^^^^^^^^
4442
|
45-
= note: `cargo::unknown_lints` is set to `warn` by default
46-
= help: there is a lint with a similar name: `im_a_teapot`
47-
[CHECKING] foo v0.0.1 ([CWD])
48-
[FINISHED] [..]
49-
",
50-
)
43+
= [NOTE] `cargo::unknown_lints` is set to `warn` by default
44+
= [HELP] there is a lint with a similar name: `im_a_teapot`
45+
[CHECKING] foo v0.0.1 ([ROOT]/foo)
46+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
47+
48+
"#]])
5149
.run();
5250
}
5351

@@ -77,17 +75,16 @@ test_dummy_unstable = { level = "forbid", priority = -1 }
7775
p.cargo("check -Zcargo-lints")
7876
.masquerade_as_nightly_cargo(&["cargo-lints", "test-dummy-unstable"])
7977
.with_status(101)
80-
.with_stderr(
81-
"\
82-
error: `im_a_teapot` is specified
78+
.with_stderr_data(str![[r#"
79+
[ERROR] `im_a_teapot` is specified
8380
--> Cargo.toml:9:1
8481
|
8582
9 | im-a-teapot = true
8683
| ^^^^^^^^^^^^^^^^^^
8784
|
88-
= note: `cargo::im_a_teapot` is set to `forbid` in `[lints]`
89-
",
90-
)
85+
= [NOTE] `cargo::im_a_teapot` is set to `forbid` in `[lints]`
86+
87+
"#]])
9188
.run();
9289
}
9390

@@ -120,17 +117,16 @@ workspace = true
120117
p.cargo("check -Zcargo-lints")
121118
.masquerade_as_nightly_cargo(&["cargo-lints", "test-dummy-unstable"])
122119
.with_status(101)
123-
.with_stderr(
124-
"\
125-
error: `im_a_teapot` is specified
120+
.with_stderr_data(str![[r#"
121+
[ERROR] `im_a_teapot` is specified
126122
--> Cargo.toml:13:1
127123
|
128124
13 | im-a-teapot = true
129125
| ^^^^^^^^^^^^^^^^^^
130126
|
131-
= note: `cargo::im_a_teapot` is set to `forbid` in `[lints]`
132-
",
133-
)
127+
= [NOTE] `cargo::im_a_teapot` is set to `forbid` in `[lints]`
128+
129+
"#]])
134130
.run();
135131
}
136132

@@ -165,12 +161,11 @@ im-a-teapot = true
165161

166162
p.cargo("check -Zcargo-lints")
167163
.masquerade_as_nightly_cargo(&["cargo-lints"])
168-
.with_stderr(
169-
"\
170-
[CHECKING] foo v0.0.1 ([CWD]/foo)
171-
[FINISHED] [..]
172-
",
173-
)
164+
.with_stderr_data(str![[r#"
165+
[CHECKING] foo v0.0.1 ([ROOT]/foo/foo)
166+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
167+
168+
"#]])
174169
.run();
175170
}
176171

@@ -216,17 +211,16 @@ implicit_features = "warn"
216211

217212
p.cargo("check -Zcargo-lints")
218213
.masquerade_as_nightly_cargo(&["cargo-lints"])
219-
.with_stderr(
220-
"\
221-
[UPDATING] [..]
214+
.with_stderr_data(str![[r#"
215+
[UPDATING] `dummy-registry` index
222216
[LOCKING] 2 packages to latest compatible versions
223217
[DOWNLOADING] crates ...
224-
[DOWNLOADED] bar v0.1.0 ([..])
218+
[DOWNLOADED] bar v0.1.0 (registry `dummy-registry`)
225219
[CHECKING] bar v0.1.0
226-
[CHECKING] foo v0.1.0 ([CWD])
227-
[FINISHED] [..]
228-
",
229-
)
220+
[CHECKING] foo v0.1.0 ([ROOT]/foo)
221+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
222+
223+
"#]])
230224
.run();
231225
}
232226

@@ -252,18 +246,17 @@ im_a_teapot = "warn"
252246
p.cargo("check -Zcargo-lints")
253247
.masquerade_as_nightly_cargo(&["cargo-lints"])
254248
.with_status(101)
255-
.with_stderr(
256-
"\
257-
error: use of unstable lint `im_a_teapot`
249+
.with_stderr_data(str![[r#"
250+
[ERROR] use of unstable lint `im_a_teapot`
258251
--> Cargo.toml:9:1
259252
|
260-
9 | im_a_teapot = \"warn\"
253+
9 | im_a_teapot = "warn"
261254
| ^^^^^^^^^^^ this is behind `test-dummy-unstable`, which is not enabled
262255
|
263-
= help: consider adding `cargo-features = [\"test-dummy-unstable\"]` to the top of the manifest
264-
error: encountered 1 errors(s) while verifying lints
265-
",
266-
)
256+
= [HELP] consider adding `cargo-features = ["test-dummy-unstable"]` to the top of the manifest
257+
[ERROR] encountered 1 errors(s) while verifying lints
258+
259+
"#]])
267260
.run();
268261
}
269262

@@ -300,36 +293,35 @@ workspace = true
300293
p.cargo("check -Zcargo-lints")
301294
.masquerade_as_nightly_cargo(&["cargo-lints"])
302295
.with_status(101)
303-
.with_stderr(
304-
"\
305-
error: use of unstable lint `im_a_teapot`
296+
.with_stderr_data(str![[r#"
297+
[ERROR] use of unstable lint `im_a_teapot`
306298
--> Cargo.toml:6:1
307299
|
308-
6 | im_a_teapot = { level = \"warn\", priority = 10 }
300+
6 | im_a_teapot = { level = "warn", priority = 10 }
309301
| ^^^^^^^^^^^ this is behind `test-dummy-unstable`, which is not enabled
310302
|
311-
note: `cargo::im_a_teapot` was inherited
303+
[NOTE] `cargo::im_a_teapot` was inherited
312304
--> foo/Cargo.toml:9:1
313305
|
314306
9 | workspace = true
315307
| ----------------
316308
|
317-
= help: consider adding `cargo-features = [\"test-dummy-unstable\"]` to the top of the manifest
318-
error: use of unstable lint `test_dummy_unstable`
309+
= [HELP] consider adding `cargo-features = ["test-dummy-unstable"]` to the top of the manifest
310+
[ERROR] use of unstable lint `test_dummy_unstable`
319311
--> Cargo.toml:7:1
320312
|
321-
7 | test_dummy_unstable = { level = \"forbid\", priority = -1 }
313+
7 | test_dummy_unstable = { level = "forbid", priority = -1 }
322314
| ^^^^^^^^^^^^^^^^^^^ this is behind `test-dummy-unstable`, which is not enabled
323315
|
324-
note: `cargo::test_dummy_unstable` was inherited
316+
[NOTE] `cargo::test_dummy_unstable` was inherited
325317
--> foo/Cargo.toml:9:1
326318
|
327319
9 | workspace = true
328320
| ----------------
329321
|
330-
= help: consider adding `cargo-features = [\"test-dummy-unstable\"]` to the top of the manifest
331-
error: encountered 2 errors(s) while verifying lints
332-
",
333-
)
322+
= [HELP] consider adding `cargo-features = ["test-dummy-unstable"]` to the top of the manifest
323+
[ERROR] encountered 2 errors(s) while verifying lints
324+
325+
"#]])
334326
.run();
335327
}

tests/testsuite/lints/unknown_lints.rs

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#![allow(deprecated)]
2-
31
use cargo_test_support::project;
2+
use cargo_test_support::str;
43

54
#[cargo_test]
65
fn default() {
@@ -23,19 +22,18 @@ this-lint-does-not-exist = "warn"
2322

2423
p.cargo("check -Zcargo-lints")
2524
.masquerade_as_nightly_cargo(&["cargo-lints"])
26-
.with_stderr(
27-
"\
28-
warning: unknown lint: `this-lint-does-not-exist`
25+
.with_stderr_data(str![[r#"
26+
[WARNING] unknown lint: `this-lint-does-not-exist`
2927
--> Cargo.toml:9:1
3028
|
31-
9 | this-lint-does-not-exist = \"warn\"
29+
9 | this-lint-does-not-exist = "warn"
3230
| ^^^^^^^^^^^^^^^^^^^^^^^^
3331
|
34-
= note: `cargo::unknown_lints` is set to `warn` by default
35-
[CHECKING] foo v0.0.1 ([CWD])
36-
[FINISHED] [..]
37-
",
38-
)
32+
= [NOTE] `cargo::unknown_lints` is set to `warn` by default
33+
[CHECKING] foo v0.0.1 ([ROOT]/foo)
34+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
35+
36+
"#]])
3937
.run();
4038
}
4139

@@ -70,24 +68,23 @@ workspace = true
7068

7169
p.cargo("check -Zcargo-lints")
7270
.masquerade_as_nightly_cargo(&["cargo-lints"])
73-
.with_stderr(
74-
"\
75-
warning: unknown lint: `this-lint-does-not-exist`
71+
.with_stderr_data(str![[r#"
72+
[WARNING] unknown lint: `this-lint-does-not-exist`
7673
--> Cargo.toml:6:1
7774
|
78-
6 | this-lint-does-not-exist = \"warn\"
75+
6 | this-lint-does-not-exist = "warn"
7976
| ^^^^^^^^^^^^^^^^^^^^^^^^
8077
|
81-
note: `cargo::this-lint-does-not-exist` was inherited
78+
[NOTE] `cargo::this-lint-does-not-exist` was inherited
8279
--> foo/Cargo.toml:9:1
8380
|
8481
9 | workspace = true
8582
| ----------------
8683
|
87-
= note: `cargo::unknown_lints` is set to `warn` by default
88-
[CHECKING] foo v0.0.1 ([CWD]/foo)
89-
[FINISHED] [..]
90-
",
91-
)
84+
= [NOTE] `cargo::unknown_lints` is set to `warn` by default
85+
[CHECKING] foo v0.0.1 ([ROOT]/foo/foo)
86+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
87+
88+
"#]])
9289
.run();
9390
}

0 commit comments

Comments
 (0)