Skip to content

Commit

Permalink
Rollup merge of rust-lang#61755 - Centril:compiletest-force-check, r=…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
Centril authored Jun 28, 2019
2 parents 3dfca34 + 93077f3 commit 49c2a2a
Show file tree
Hide file tree
Showing 20 changed files with 194 additions and 88 deletions.
2 changes: 2 additions & 0 deletions src/bootstrap/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ fn test_with_no_doc_stage0() {
bless: false,
compare_mode: None,
rustfix_coverage: false,
pass: None,
};

let build = Build::new(config);
Expand Down Expand Up @@ -640,6 +641,7 @@ fn test_exclude() {
bless: false,
compare_mode: None,
rustfix_coverage: false,
pass: None,
};

let build = Build::new(config);
Expand Down
17 changes: 17 additions & 0 deletions src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub enum Subcommand {
/// Whether to automatically update stderr/stdout files
bless: bool,
compare_mode: Option<String>,
pass: Option<String>,
test_args: Vec<String>,
rustc_args: Vec<String>,
fail_fast: bool,
Expand Down Expand Up @@ -199,6 +200,12 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`"
"mode describing what file the actual ui output will be compared to",
"COMPARE MODE",
);
opts.optopt(
"",
"pass",
"force {check,build,run}-pass tests to this mode.",
"check | build | run"
);
opts.optflag(
"",
"rustfix-coverage",
Expand Down Expand Up @@ -401,6 +408,7 @@ Arguments:
paths,
bless: matches.opt_present("bless"),
compare_mode: matches.opt_str("compare-mode"),
pass: matches.opt_str("pass"),
test_args: matches.opt_strs("test-args"),
rustc_args: matches.opt_strs("rustc-args"),
fail_fast: !matches.opt_present("no-fail-fast"),
Expand Down Expand Up @@ -524,6 +532,15 @@ impl Subcommand {
_ => None,
}
}

pub fn pass(&self) -> Option<&str> {
match *self {
Subcommand::Test {
ref pass, ..
} => pass.as_ref().map(|s| &s[..]),
_ => None,
}
}
}

fn split(s: &[String]) -> Vec<String> {
Expand Down
5 changes: 5 additions & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,11 @@ impl Step for Compiletest {
}
});

if let Some(ref pass) = builder.config.cmd.pass() {
cmd.arg("--pass");
cmd.arg(pass);
}

if let Some(ref nodejs) = builder.config.nodejs {
cmd.arg("--nodejs").arg(nodejs);
}
Expand Down
24 changes: 14 additions & 10 deletions src/test/ui/consts/const-eval/promoted_errors.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
#![warn(const_err)]

// compile-pass
// compile-flags: -O

#![deny(const_err)]

fn main() {
println!("{}", 0u32 - 1);
let _x = 0u32 - 1;
//~^ WARN const_err
//~^ ERROR this expression will panic at runtime [const_err]
println!("{}", 1/(1-1));
//~^ WARN const_err
//~^ ERROR this expression will panic at runtime [const_err]
//~| ERROR attempt to divide by zero [const_err]
//~| ERROR reaching this expression at runtime will panic or abort [const_err]
let _x = 1/(1-1);
//~^ WARN const_err
//~| WARN const_err
//~^ ERROR const_err
//~| ERROR const_err
println!("{}", 1/(false as u32));
//~^ WARN const_err
//~^ ERROR this expression will panic at runtime [const_err]
//~| ERROR attempt to divide by zero [const_err]
//~| ERROR reaching this expression at runtime will panic or abort [const_err]
let _x = 1/(false as u32);
//~^ WARN const_err
//~| WARN const_err
//~^ ERROR const_err
//~| ERROR const_err
}
42 changes: 22 additions & 20 deletions src/test/ui/consts/const-eval/promoted_errors.stderr
Original file line number Diff line number Diff line change
@@ -1,72 +1,74 @@
warning: this expression will panic at runtime
error: this expression will panic at runtime
--> $DIR/promoted_errors.rs:7:14
|
LL | let _x = 0u32 - 1;
| ^^^^^^^^ attempt to subtract with overflow
|
note: lint level defined here
--> $DIR/promoted_errors.rs:1:9
--> $DIR/promoted_errors.rs:3:9
|
LL | #![warn(const_err)]
LL | #![deny(const_err)]
| ^^^^^^^^^

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

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

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

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

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

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

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

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

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

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

error: aborting due to 11 previous errors

2 changes: 2 additions & 0 deletions src/test/ui/emit-artifact-notifications.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// compile-flags:--emit=metadata --error-format=json -Z emit-artifact-notifications
// compile-pass
// ignore-pass
// ^-- needed because `--pass check` does not emit the output needed.

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

Expand Down
16 changes: 7 additions & 9 deletions src/test/ui/lint/lint-type-overflow2.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
// compile-flags: -O
#![warn(overflowing_literals)]
#![warn(const_err)]
// compile-pass

#[allow(unused_variables)]
#![deny(overflowing_literals)]
#![deny(const_err)]

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

let x = -3.40282357e+38_f32; //~ warn: literal out of range for f32
let x = 3.40282357e+38_f32; //~ warn: literal out of range for f32
let x = -1.7976931348623159e+308_f64; //~ warn: literal out of range for f64
let x = 1.7976931348623159e+308_f64; //~ warn: literal out of range for f64
let x = -3.40282357e+38_f32; //~ ERROR literal out of range for `f32`
let x = 3.40282357e+38_f32; //~ ERROR literal out of range for `f32`
let x = -1.7976931348623159e+308_f64; //~ ERROR literal out of range for `f64`
let x = 1.7976931348623159e+308_f64; //~ ERROR literal out of range for `f64`
}
36 changes: 13 additions & 23 deletions src/test/ui/lint/lint-type-overflow2.stderr
Original file line number Diff line number Diff line change
@@ -1,48 +1,38 @@
warning: literal out of range for `i8`
--> $DIR/lint-type-overflow2.rs:9:20
error: literal out of range for `i8`
--> $DIR/lint-type-overflow2.rs:7:20
|
LL | let x2: i8 = --128;
| ^^^
|
note: lint level defined here
--> $DIR/lint-type-overflow2.rs:2:9
--> $DIR/lint-type-overflow2.rs:3:9
|
LL | #![warn(overflowing_literals)]
LL | #![deny(overflowing_literals)]
| ^^^^^^^^^^^^^^^^^^^^

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

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

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

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

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

3 changes: 3 additions & 0 deletions src/test/ui/print_type_sizes/generics.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// compile-flags: -Z print-type-sizes
// compile-pass
// ignore-pass
// ^-- needed because `--pass check` does not emit the output needed.
// FIXME: consider using an attribute instead of side-effects.

// This file illustrates how generics are handled: types have to be
// monomorphized, in the MIR of the original function in which they
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/print_type_sizes/niche-filling.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// compile-flags: -Z print-type-sizes
// compile-pass
// ignore-pass
// ^-- needed because `--pass check` does not emit the output needed.
// FIXME: consider using an attribute instead of side-effects.

// This file illustrates how niche-filling enums are handled,
// modelled after cases like `Option<&u32>`, `Option<bool>` and such.
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/print_type_sizes/no_duplicates.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// compile-flags: -Z print-type-sizes
// compile-pass
// ignore-pass
// ^-- needed because `--pass check` does not emit the output needed.
// FIXME: consider using an attribute instead of side-effects.

// This file illustrates that when the same type occurs repeatedly
// (even if multiple functions), it is only printed once in the
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/print_type_sizes/packed.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// compile-flags: -Z print-type-sizes
// compile-pass
// ignore-pass
// ^-- needed because `--pass check` does not emit the output needed.
// FIXME: consider using an attribute instead of side-effects.

// This file illustrates how packing is handled; it should cause
// the elimination of padding that would normally be introduced
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/print_type_sizes/repr-align.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// compile-flags: -Z print-type-sizes
// compile-pass
// ignore-pass
// ^-- needed because `--pass check` does not emit the output needed.
// FIXME: consider using an attribute instead of side-effects.

// This file illustrates how padding is handled: alignment
// requirements can lead to the introduction of padding, either before
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/print_type_sizes/uninhabited.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// compile-flags: -Z print-type-sizes
// compile-pass
// ignore-pass
// ^-- needed because `--pass check` does not emit the output needed.
// FIXME: consider using an attribute instead of side-effects.

#![feature(never_type)]
#![feature(start)]
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/proc-macro/auxiliary/generate-mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// run-pass
// force-host
// no-prefer-dynamic
// ignore-pass

#![crate_type = "proc-macro"]

Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/save-analysis/emit-notifications.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// compile-pass
// compile-flags: -Zsave-analysis -Zemit-artifact-notifications
// compile-flags: --crate-type rlib --error-format=json
// ignore-pass
// ^-- needed because otherwise, the .stderr file changes with --pass check

pub fn foo() {}
Loading

0 comments on commit 49c2a2a

Please sign in to comment.