Skip to content

Commit fea6402

Browse files
authored
Rollup merge of rust-lang#61755 - Centril:compiletest-force-check, r=petrochenkov
Add `--pass $mode` to compiletest through `./x.py` Adds a flag `--pass $mode` to compiletest, which is exposed through `./x.py`. When `--pass $mode` is passed, `{check,build,compile,run}-pass` tests will be forced to run under the given `$mode` unless the directive `// ignore-pass` exists in the test file. The modes are explained in rust-lang#61778: - `check` has the same effect as `cargo check` - `build` or `compile` have the same effect as `cargo build` - `run` has the same effect as `cargo run` On my machine, `./x.py -i test src/test/run-pass --stage 1 --pass check` takes 38 seconds whereas it takes 2 min 7 seconds without `--pass check`. cc rust-lang#61712 r? @petrochenkov
2 parents 8b165dd + 93077f3 commit fea6402

20 files changed

+194
-88
lines changed

src/bootstrap/builder/tests.rs

+2
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,7 @@ fn test_with_no_doc_stage0() {
598598
bless: false,
599599
compare_mode: None,
600600
rustfix_coverage: false,
601+
pass: None,
601602
};
602603

603604
let build = Build::new(config);
@@ -640,6 +641,7 @@ fn test_exclude() {
640641
bless: false,
641642
compare_mode: None,
642643
rustfix_coverage: false,
644+
pass: None,
643645
};
644646

645647
let build = Build::new(config);

src/bootstrap/flags.rs

+17
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ pub enum Subcommand {
5858
/// Whether to automatically update stderr/stdout files
5959
bless: bool,
6060
compare_mode: Option<String>,
61+
pass: Option<String>,
6162
test_args: Vec<String>,
6263
rustc_args: Vec<String>,
6364
fail_fast: bool,
@@ -199,6 +200,12 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`"
199200
"mode describing what file the actual ui output will be compared to",
200201
"COMPARE MODE",
201202
);
203+
opts.optopt(
204+
"",
205+
"pass",
206+
"force {check,build,run}-pass tests to this mode.",
207+
"check | build | run"
208+
);
202209
opts.optflag(
203210
"",
204211
"rustfix-coverage",
@@ -401,6 +408,7 @@ Arguments:
401408
paths,
402409
bless: matches.opt_present("bless"),
403410
compare_mode: matches.opt_str("compare-mode"),
411+
pass: matches.opt_str("pass"),
404412
test_args: matches.opt_strs("test-args"),
405413
rustc_args: matches.opt_strs("rustc-args"),
406414
fail_fast: !matches.opt_present("no-fail-fast"),
@@ -524,6 +532,15 @@ impl Subcommand {
524532
_ => None,
525533
}
526534
}
535+
536+
pub fn pass(&self) -> Option<&str> {
537+
match *self {
538+
Subcommand::Test {
539+
ref pass, ..
540+
} => pass.as_ref().map(|s| &s[..]),
541+
_ => None,
542+
}
543+
}
527544
}
528545

529546
fn split(s: &[String]) -> Vec<String> {

src/bootstrap/test.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,11 @@ impl Step for Compiletest {
10651065
}
10661066
});
10671067

1068+
if let Some(ref pass) = builder.config.cmd.pass() {
1069+
cmd.arg("--pass");
1070+
cmd.arg(pass);
1071+
}
1072+
10681073
if let Some(ref nodejs) = builder.config.nodejs {
10691074
cmd.arg("--nodejs").arg(nodejs);
10701075
}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1-
#![warn(const_err)]
2-
3-
// compile-pass
41
// compile-flags: -O
2+
3+
#![deny(const_err)]
4+
55
fn main() {
66
println!("{}", 0u32 - 1);
77
let _x = 0u32 - 1;
8-
//~^ WARN const_err
8+
//~^ ERROR this expression will panic at runtime [const_err]
99
println!("{}", 1/(1-1));
10-
//~^ WARN const_err
10+
//~^ ERROR this expression will panic at runtime [const_err]
11+
//~| ERROR attempt to divide by zero [const_err]
12+
//~| ERROR reaching this expression at runtime will panic or abort [const_err]
1113
let _x = 1/(1-1);
12-
//~^ WARN const_err
13-
//~| WARN const_err
14+
//~^ ERROR const_err
15+
//~| ERROR const_err
1416
println!("{}", 1/(false as u32));
15-
//~^ WARN const_err
17+
//~^ ERROR this expression will panic at runtime [const_err]
18+
//~| ERROR attempt to divide by zero [const_err]
19+
//~| ERROR reaching this expression at runtime will panic or abort [const_err]
1620
let _x = 1/(false as u32);
17-
//~^ WARN const_err
18-
//~| WARN const_err
21+
//~^ ERROR const_err
22+
//~| ERROR const_err
1923
}
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,74 @@
1-
warning: this expression will panic at runtime
1+
error: this expression will panic at runtime
22
--> $DIR/promoted_errors.rs:7:14
33
|
44
LL | let _x = 0u32 - 1;
55
| ^^^^^^^^ attempt to subtract with overflow
66
|
77
note: lint level defined here
8-
--> $DIR/promoted_errors.rs:1:9
8+
--> $DIR/promoted_errors.rs:3:9
99
|
10-
LL | #![warn(const_err)]
10+
LL | #![deny(const_err)]
1111
| ^^^^^^^^^
1212

13-
warning: attempt to divide by zero
13+
error: attempt to divide by zero
1414
--> $DIR/promoted_errors.rs:9:20
1515
|
1616
LL | println!("{}", 1/(1-1));
1717
| ^^^^^^^
1818

19-
warning: this expression will panic at runtime
19+
error: this expression will panic at runtime
2020
--> $DIR/promoted_errors.rs:9:20
2121
|
2222
LL | println!("{}", 1/(1-1));
2323
| ^^^^^^^ attempt to divide by zero
2424

25-
warning: attempt to divide by zero
26-
--> $DIR/promoted_errors.rs:11:14
25+
error: attempt to divide by zero
26+
--> $DIR/promoted_errors.rs:13:14
2727
|
2828
LL | let _x = 1/(1-1);
2929
| ^^^^^^^
3030

31-
warning: this expression will panic at runtime
32-
--> $DIR/promoted_errors.rs:11:14
31+
error: this expression will panic at runtime
32+
--> $DIR/promoted_errors.rs:13:14
3333
|
3434
LL | let _x = 1/(1-1);
3535
| ^^^^^^^ attempt to divide by zero
3636

37-
warning: attempt to divide by zero
38-
--> $DIR/promoted_errors.rs:14:20
37+
error: attempt to divide by zero
38+
--> $DIR/promoted_errors.rs:16:20
3939
|
4040
LL | println!("{}", 1/(false as u32));
4141
| ^^^^^^^^^^^^^^^^
4242

43-
warning: this expression will panic at runtime
44-
--> $DIR/promoted_errors.rs:14:20
43+
error: this expression will panic at runtime
44+
--> $DIR/promoted_errors.rs:16:20
4545
|
4646
LL | println!("{}", 1/(false as u32));
4747
| ^^^^^^^^^^^^^^^^ attempt to divide by zero
4848

49-
warning: attempt to divide by zero
50-
--> $DIR/promoted_errors.rs:16:14
49+
error: attempt to divide by zero
50+
--> $DIR/promoted_errors.rs:20:14
5151
|
5252
LL | let _x = 1/(false as u32);
5353
| ^^^^^^^^^^^^^^^^
5454

55-
warning: this expression will panic at runtime
56-
--> $DIR/promoted_errors.rs:16:14
55+
error: this expression will panic at runtime
56+
--> $DIR/promoted_errors.rs:20:14
5757
|
5858
LL | let _x = 1/(false as u32);
5959
| ^^^^^^^^^^^^^^^^ attempt to divide by zero
6060

61-
warning: reaching this expression at runtime will panic or abort
62-
--> $DIR/promoted_errors.rs:14:20
61+
error: reaching this expression at runtime will panic or abort
62+
--> $DIR/promoted_errors.rs:16:20
6363
|
6464
LL | println!("{}", 1/(false as u32));
6565
| ^^^^^^^^^^^^^^^^ attempt to divide by zero
6666

67-
warning: reaching this expression at runtime will panic or abort
67+
error: reaching this expression at runtime will panic or abort
6868
--> $DIR/promoted_errors.rs:9:20
6969
|
7070
LL | println!("{}", 1/(1-1));
7171
| ^^^^^^^ attempt to divide by zero
7272

73+
error: aborting due to 11 previous errors
74+

src/test/ui/emit-artifact-notifications.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// compile-flags:--emit=metadata --error-format=json -Z emit-artifact-notifications
22
// compile-pass
3+
// ignore-pass
4+
// ^-- needed because `--pass check` does not emit the output needed.
35

46
// A very basic test for the emission of artifact notifications in JSON output.
57

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
// compile-flags: -O
2-
#![warn(overflowing_literals)]
3-
#![warn(const_err)]
4-
// compile-pass
52

6-
#[allow(unused_variables)]
3+
#![deny(overflowing_literals)]
4+
#![deny(const_err)]
75

86
fn main() {
9-
let x2: i8 = --128; //~ warn: literal out of range for i8
7+
let x2: i8 = --128; //~ ERROR literal out of range for `i8`
108

11-
let x = -3.40282357e+38_f32; //~ warn: literal out of range for f32
12-
let x = 3.40282357e+38_f32; //~ warn: literal out of range for f32
13-
let x = -1.7976931348623159e+308_f64; //~ warn: literal out of range for f64
14-
let x = 1.7976931348623159e+308_f64; //~ warn: literal out of range for f64
9+
let x = -3.40282357e+38_f32; //~ ERROR literal out of range for `f32`
10+
let x = 3.40282357e+38_f32; //~ ERROR literal out of range for `f32`
11+
let x = -1.7976931348623159e+308_f64; //~ ERROR literal out of range for `f64`
12+
let x = 1.7976931348623159e+308_f64; //~ ERROR literal out of range for `f64`
1513
}
+13-23
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,38 @@
1-
warning: literal out of range for `i8`
2-
--> $DIR/lint-type-overflow2.rs:9:20
1+
error: literal out of range for `i8`
2+
--> $DIR/lint-type-overflow2.rs:7:20
33
|
44
LL | let x2: i8 = --128;
55
| ^^^
66
|
77
note: lint level defined here
8-
--> $DIR/lint-type-overflow2.rs:2:9
8+
--> $DIR/lint-type-overflow2.rs:3:9
99
|
10-
LL | #![warn(overflowing_literals)]
10+
LL | #![deny(overflowing_literals)]
1111
| ^^^^^^^^^^^^^^^^^^^^
1212

13-
warning: literal out of range for `f32`
14-
--> $DIR/lint-type-overflow2.rs:11:14
13+
error: literal out of range for `f32`
14+
--> $DIR/lint-type-overflow2.rs:9:14
1515
|
1616
LL | let x = -3.40282357e+38_f32;
1717
| ^^^^^^^^^^^^^^^^^^
1818

19-
warning: literal out of range for `f32`
20-
--> $DIR/lint-type-overflow2.rs:12:14
19+
error: literal out of range for `f32`
20+
--> $DIR/lint-type-overflow2.rs:10:14
2121
|
2222
LL | let x = 3.40282357e+38_f32;
2323
| ^^^^^^^^^^^^^^^^^^
2424

25-
warning: literal out of range for `f64`
26-
--> $DIR/lint-type-overflow2.rs:13:14
25+
error: literal out of range for `f64`
26+
--> $DIR/lint-type-overflow2.rs:11:14
2727
|
2828
LL | let x = -1.7976931348623159e+308_f64;
2929
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
3030

31-
warning: literal out of range for `f64`
32-
--> $DIR/lint-type-overflow2.rs:14:14
31+
error: literal out of range for `f64`
32+
--> $DIR/lint-type-overflow2.rs:12:14
3333
|
3434
LL | let x = 1.7976931348623159e+308_f64;
3535
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
3636

37-
warning: this expression will panic at runtime
38-
--> $DIR/lint-type-overflow2.rs:9:18
39-
|
40-
LL | let x2: i8 = --128;
41-
| ^^^^^ attempt to negate with overflow
42-
|
43-
note: lint level defined here
44-
--> $DIR/lint-type-overflow2.rs:3:9
45-
|
46-
LL | #![warn(const_err)]
47-
| ^^^^^^^^^
37+
error: aborting due to 5 previous errors
4838

src/test/ui/print_type_sizes/generics.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// compile-flags: -Z print-type-sizes
22
// compile-pass
3+
// ignore-pass
4+
// ^-- needed because `--pass check` does not emit the output needed.
5+
// FIXME: consider using an attribute instead of side-effects.
36

47
// This file illustrates how generics are handled: types have to be
58
// monomorphized, in the MIR of the original function in which they

src/test/ui/print_type_sizes/niche-filling.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// compile-flags: -Z print-type-sizes
22
// compile-pass
3+
// ignore-pass
4+
// ^-- needed because `--pass check` does not emit the output needed.
5+
// FIXME: consider using an attribute instead of side-effects.
36

47
// This file illustrates how niche-filling enums are handled,
58
// modelled after cases like `Option<&u32>`, `Option<bool>` and such.

src/test/ui/print_type_sizes/no_duplicates.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// compile-flags: -Z print-type-sizes
22
// compile-pass
3+
// ignore-pass
4+
// ^-- needed because `--pass check` does not emit the output needed.
5+
// FIXME: consider using an attribute instead of side-effects.
36

47
// This file illustrates that when the same type occurs repeatedly
58
// (even if multiple functions), it is only printed once in the

src/test/ui/print_type_sizes/packed.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// compile-flags: -Z print-type-sizes
22
// compile-pass
3+
// ignore-pass
4+
// ^-- needed because `--pass check` does not emit the output needed.
5+
// FIXME: consider using an attribute instead of side-effects.
36

47
// This file illustrates how packing is handled; it should cause
58
// the elimination of padding that would normally be introduced

src/test/ui/print_type_sizes/repr-align.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// compile-flags: -Z print-type-sizes
22
// compile-pass
3+
// ignore-pass
4+
// ^-- needed because `--pass check` does not emit the output needed.
5+
// FIXME: consider using an attribute instead of side-effects.
36

47
// This file illustrates how padding is handled: alignment
58
// requirements can lead to the introduction of padding, either before

src/test/ui/print_type_sizes/uninhabited.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// compile-flags: -Z print-type-sizes
22
// compile-pass
3+
// ignore-pass
4+
// ^-- needed because `--pass check` does not emit the output needed.
5+
// FIXME: consider using an attribute instead of side-effects.
36

47
#![feature(never_type)]
58
#![feature(start)]

src/test/ui/proc-macro/auxiliary/generate-mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// run-pass
22
// force-host
33
// no-prefer-dynamic
4+
// ignore-pass
45

56
#![crate_type = "proc-macro"]
67

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
// compile-pass
22
// compile-flags: -Zsave-analysis -Zemit-artifact-notifications
33
// compile-flags: --crate-type rlib --error-format=json
4+
// ignore-pass
5+
// ^-- needed because otherwise, the .stderr file changes with --pass check
6+
47
pub fn foo() {}

0 commit comments

Comments
 (0)