Skip to content

Commit fa86083

Browse files
committed
test(build): Expand rustflags/build.warnings comparison
1 parent 15da6d5 commit fa86083

1 file changed

Lines changed: 122 additions & 10 deletions

File tree

tests/testsuite/warning_override.rs

Lines changed: 122 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,43 @@ fn hard_warning_deny() {
262262
)
263263
.file("src/main.rs", "fn main() {}")
264264
.build();
265+
266+
// Baseline behavior
267+
p.cargo("rustc")
268+
.arg("--")
269+
.arg("-ox.rs")
270+
.with_stderr_data(str![[r#"
271+
[WARNING] `package.edition` is unspecified, defaulting to `2015` while the latest is `[..]`
272+
[COMPILING] foo v0.0.1 ([ROOT]/foo)
273+
[WARNING] [..]
274+
275+
[WARNING] [..]
276+
277+
[WARNING] `foo` (bin "foo") generated 2 warnings
278+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
279+
280+
"#]])
281+
.run();
282+
283+
// Compare with `RUSTFLAGS
284+
p.cargo("rustc")
285+
.env("RUSTFLAGS", "-Dwarnings")
286+
.arg("--")
287+
.arg("-ox.rs")
288+
.with_stderr_data(str![[r#"
289+
[WARNING] `package.edition` is unspecified, defaulting to `2015` while the latest is `[..]`
290+
[COMPILING] foo v0.0.1 ([ROOT]/foo)
291+
[WARNING] [..]
292+
293+
[WARNING] [..]
294+
295+
[WARNING] `foo` (bin "foo") generated 2 warnings
296+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
297+
298+
"#]])
299+
.run();
300+
301+
// Behavior under test
265302
p.cargo("rustc")
266303
.masquerade_as_nightly_cargo(&["warnings"])
267304
.arg("-Zwarnings")
@@ -298,6 +335,40 @@ fn hard_warning_allow() {
298335
)
299336
.file("src/main.rs", "fn main() {}")
300337
.build();
338+
339+
// Baseline behavior
340+
p.cargo("rustc")
341+
.arg("--")
342+
.arg("-ox.rs")
343+
.with_stderr_data(str![[r#"
344+
[WARNING] `package.edition` is unspecified, defaulting to `2015` while the latest is `[..]`
345+
[COMPILING] foo v0.0.1 ([ROOT]/foo)
346+
[WARNING] [..]
347+
348+
[WARNING] [..]
349+
350+
[WARNING] `foo` (bin "foo") generated 2 warnings
351+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
352+
353+
"#]])
354+
.with_status(0)
355+
.run();
356+
357+
// Compare with `RUSTFLAGS
358+
p.cargo("rustc")
359+
.env("RUSTFLAGS", "-Awarnings")
360+
.arg("--")
361+
.arg("-ox.rs")
362+
.with_stderr_data(str![[r#"
363+
[WARNING] `package.edition` is unspecified, defaulting to `2015` while the latest is `[..]`
364+
[COMPILING] foo v0.0.1 ([ROOT]/foo)
365+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
366+
367+
"#]])
368+
.with_status(0)
369+
.run();
370+
371+
// Behavior under test
301372
p.cargo("rustc")
302373
.masquerade_as_nightly_cargo(&["warnings"])
303374
.arg("-Zwarnings")
@@ -311,7 +382,6 @@ fn hard_warning_allow() {
311382
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
312383
313384
"#]])
314-
.with_status(0)
315385
.run();
316386
}
317387

@@ -339,8 +409,8 @@ fn cap_lints_deny() {
339409
.file("src/main.rs", "fn main() {}")
340410
.build();
341411

412+
// Baseline behavior
342413
p.cargo("check -vv")
343-
.env("RUSTFLAGS", "-Dwarnings")
344414
.with_stderr_data(str![[r#"
345415
[UPDATING] `dummy-registry` index
346416
[LOCKING] 1 package to latest compatible version
@@ -358,11 +428,9 @@ fn cap_lints_deny() {
358428
"#]])
359429
.run();
360430

431+
// Compare with `RUSTFLAGS
361432
p.cargo("check -vv")
362-
.masquerade_as_nightly_cargo(&["warnings"])
363-
.arg("-Zwarnings")
364-
.arg("--config")
365-
.arg("build.warnings='deny'")
433+
.env("RUSTFLAGS", "-Dwarnings")
366434
.with_stderr_data(str![[r#"
367435
[CHECKING] has_warning v1.0.0
368436
[RUNNING] [..]
@@ -373,6 +441,23 @@ fn cap_lints_deny() {
373441
[RUNNING] [..]
374442
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
375443
444+
"#]])
445+
.run();
446+
447+
// Behavior under test
448+
p.cargo("check -vv")
449+
.masquerade_as_nightly_cargo(&["warnings"])
450+
.arg("-Zwarnings")
451+
.arg("--config")
452+
.arg("build.warnings='deny'")
453+
.with_stderr_data(str![[r#"
454+
[FRESH] has_warning v1.0.0
455+
[WARNING] unused variable: `x`
456+
...
457+
[WARNING] `has_warning` (lib) generated 1 warning
458+
[FRESH] foo v0.0.1 ([ROOT]/foo)
459+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
460+
376461
"#]])
377462
.run();
378463
}
@@ -401,22 +486,49 @@ fn cap_lints_allow() {
401486
.file("src/main.rs", "fn main() {}")
402487
.build();
403488

489+
// Baseline behavior
404490
p.cargo("check -vv")
405-
.masquerade_as_nightly_cargo(&["warnings"])
406-
.arg("-Zwarnings")
407-
.arg("--config")
408-
.arg("build.warnings='allow'")
409491
.with_stderr_data(str![[r#"
410492
[UPDATING] `dummy-registry` index
411493
[LOCKING] 1 package to latest compatible version
412494
[DOWNLOADING] crates ...
413495
[DOWNLOADED] has_warning v1.0.0 (registry `dummy-registry`)
414496
[CHECKING] has_warning v1.0.0
415497
[RUNNING] [..]
498+
[WARNING] unused variable: `x`
499+
...
500+
[WARNING] `has_warning` (lib) generated 1 warning
501+
[CHECKING] foo v0.0.1 ([ROOT]/foo)
502+
[RUNNING] [..]
503+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
504+
505+
"#]])
506+
.run();
507+
508+
// Compare with `RUSTFLAGS
509+
p.cargo("check -vv")
510+
.env("RUSTFLAGS", "-Awarnings")
511+
.with_stderr_data(str![[r#"
512+
[CHECKING] has_warning v1.0.0
513+
[RUNNING] [..]
416514
[CHECKING] foo v0.0.1 ([ROOT]/foo)
417515
[RUNNING] [..]
418516
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
419517
518+
"#]])
519+
.run();
520+
521+
// Behavior under test
522+
p.cargo("check -vv")
523+
.masquerade_as_nightly_cargo(&["warnings"])
524+
.arg("-Zwarnings")
525+
.arg("--config")
526+
.arg("build.warnings='allow'")
527+
.with_stderr_data(str![[r#"
528+
[FRESH] has_warning v1.0.0
529+
[FRESH] foo v0.0.1 ([ROOT]/foo)
530+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
531+
420532
"#]])
421533
.run();
422534
}

0 commit comments

Comments
 (0)