Skip to content

Commit

Permalink
Rollup merge of rust-lang#59769 - RalfJung:compiletest-normalization,…
Browse files Browse the repository at this point in the history
… r=alexcrichton

compiletest normalization: preserve non-JSON lines such as ICEs

Currently, every non-JSON line from stderr gets normalized away when compiletest normalizes the output. In particular, ICEs get normalized to the empty output. That does not seem desirable, so this changes normalization to preserve non-JSON lines instead.

Also see Manishearth/compiletest-rs#169: because of that bug, Miri currently *looks* green in the toolstate, but some tests ICE. That same bug is likely no longer present in latest compiletest because the error code gets checked separately, but it still seems like a good idea to also make sure that ICEs are considered stderr output:
This change found an accidental user-visible `error!` in CTFE validation (fixed), and a non-deterministic panic when there are two `main` symbols (not fixed, no idea where this comes from). Both got missed before because non-JSON output got ignored.
  • Loading branch information
Centril authored Apr 13, 2019
2 parents 6688e02 + 8861232 commit 8443fee
Show file tree
Hide file tree
Showing 23 changed files with 73 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ impl<'rt, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>>
match self.ecx.memory.check_align(ptr, align) {
Ok(_) => {},
Err(err) => {
error!("{:?} is not aligned to {:?}", ptr, align);
info!("{:?} is not aligned to {:?}", ptr, align);
match err.kind {
InterpError::InvalidNullPointerUsage =>
return validation_failure!("NULL reference", self.path),
Expand Down
6 changes: 4 additions & 2 deletions src/test/run-pass/backtrace-debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
// ignore-pretty issue #37195
// ignore-cloudabi spawning processes is not supported
// ignore-emscripten spawning processes is not supported
// normalize-stderr-test ".*\n" -> ""

// note that above `-opt-bisect-limit=0` is used to basically disable
// optimizations
// Note that above `-opt-bisect-limit=0` is used to basically disable
// optimizations. It creates tons of output on stderr, hence we normalize
// that away entirely.

use std::env;

Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/conditional-compilation/cfg-arg-invalid-1.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: invalid `--cfg` argument: `a(b=c)` (expected `key` or `key="value"`)

2 changes: 2 additions & 0 deletions src/test/ui/conditional-compilation/cfg-arg-invalid-2.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: invalid `--cfg` argument: `a{b}` (expected `key` or `key="value"`)

2 changes: 2 additions & 0 deletions src/test/ui/conditional-compilation/cfg-arg-invalid-3.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: invalid `--cfg` argument: `a::b` (argument key must be an identifier)

2 changes: 2 additions & 0 deletions src/test/ui/conditional-compilation/cfg-arg-invalid-4.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: invalid `--cfg` argument: `a(b)` (expected `key` or `key="value"`)

2 changes: 2 additions & 0 deletions src/test/ui/conditional-compilation/cfg-arg-invalid-5.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: invalid `--cfg` argument: `a=10` (argument value must be a string)

2 changes: 2 additions & 0 deletions src/test/ui/conditional-compilation/cfg-empty-codemap.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: invalid `--cfg` argument: `""` (expected `key` or `key="value"`)

4 changes: 4 additions & 0 deletions src/test/ui/duplicate/dupe-symbols-7.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
//
// error-pattern: entry symbol `main` defined multiple times

// FIXME https://github.com/rust-lang/rust/issues/59774
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
#![allow(warnings)]

#[no_mangle]
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/duplicate/dupe-symbols-7.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: entry symbol `main` defined multiple times
--> $DIR/dupe-symbols-7.rs:6:1
--> $DIR/dupe-symbols-7.rs:10:1
|
LL | fn main(){}
| ^^^^^^^^^^^
Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/huge-array-simple.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// error-pattern: too big for the current architecture

// normalize-stderr-test "; \d+]" -> "; N]"

// FIXME https://github.com/rust-lang/rust/issues/59774
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
#![allow(exceeding_bitshifts)]

#[cfg(target_pointer_width = "64")]
Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/huge-array.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// error-pattern:; 1518600000

// FIXME https://github.com/rust-lang/rust/issues/59774
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""

fn generic<T: Copy>(t: T) {
let s: [T; 1518600000] = [t; 1518600000];
}
Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/huge-struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// normalize-stderr-test "S1M" -> "SXX"
// error-pattern: too big for the current

// FIXME https://github.com/rust-lang/rust/issues/59774
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""

struct S32<T> {
v0: T,
v1: T,
Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/issues/issue-15919.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// error-pattern: too big for the current architecture
// normalize-stderr-test "\[usize; \d+\]" -> "[usize; N]"

// FIXME https://github.com/rust-lang/rust/issues/59774
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""

#[cfg(target_pointer_width = "32")]
fn main() {
let x = [0usize; 0xffff_ffff];
Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/issues/issue-17913.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// normalize-stderr-test "\[&usize; \d+\]" -> "[&usize; N]"
// error-pattern: too big for the current architecture

// FIXME https://github.com/rust-lang/rust/issues/59774
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""

#![feature(box_syntax)]

#[cfg(target_pointer_width = "64")]
Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/issues/issue-56762.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// only-x86_64

// FIXME https://github.com/rust-lang/rust/issues/59774
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
const HUGE_SIZE: usize = !0usize / 8;


Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/linkage2.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// FIXME https://github.com/rust-lang/rust/issues/59774
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""

#![feature(linkage)]

extern {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/linkage2.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: must have type `*const T` or `*mut T`
--> $DIR/linkage2.rs:4:32
--> $DIR/linkage2.rs:8:32
|
LL | #[linkage = "extern_weak"] static foo: i32;
| ^^^^^^^^^^^^^^^^
Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/linkage3.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// FIXME https://github.com/rust-lang/rust/issues/59774
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""

#![feature(linkage)]

extern {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/linkage3.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: invalid linkage specified
--> $DIR/linkage3.rs:4:24
--> $DIR/linkage3.rs:8:24
|
LL | #[linkage = "foo"] static foo: *const i32;
| ^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/pattern/const-pat-ice.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// failure-status: 101
// rustc-env:RUST_BACKTRACE=0
// normalize-stderr-test "note: rustc 1.* running on .*" -> "note: rustc VERSION running on TARGET"
// normalize-stderr-test "note: compiler flags: .*" -> "note: compiler flags: FLAGS"

// This is a repro test for an ICE in our pattern handling of constants.

Expand Down
13 changes: 13 additions & 0 deletions src/test/ui/pattern/const-pat-ice.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
thread 'rustc' panicked at 'assertion failed: rows.iter().all(|r| r.len() == v.len())', src/librustc_mir/hair/pattern/_match.rs:1069:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc VERSION running on TARGET

note: compiler flags: FLAGS

3 changes: 2 additions & 1 deletion src/tools/compiletest/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ pub fn extract_rendered(output: &str, proc_res: &ProcRes) -> String {
}
}
} else {
None
// preserve non-JSON lines, such as ICEs
Some(format!("{}\n", line))
}
})
.collect()
Expand Down

0 comments on commit 8443fee

Please sign in to comment.