Skip to content

Commit 1d8905a

Browse files
authored
Rollup merge of rust-lang#59769 - RalfJung:compiletest-normalization, 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.
2 parents 520f58a + 8861232 commit 1d8905a

23 files changed

+73
-7
lines changed

src/librustc_mir/interpret/validity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ impl<'rt, 'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>>
353353
match self.ecx.memory.check_align(ptr, align) {
354354
Ok(_) => {},
355355
Err(err) => {
356-
error!("{:?} is not aligned to {:?}", ptr, align);
356+
info!("{:?} is not aligned to {:?}", ptr, align);
357357
match err.kind {
358358
InterpError::InvalidNullPointerUsage =>
359359
return validation_failure!("NULL reference", self.path),

src/test/run-pass/backtrace-debuginfo.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
// ignore-pretty issue #37195
1111
// ignore-cloudabi spawning processes is not supported
1212
// ignore-emscripten spawning processes is not supported
13+
// normalize-stderr-test ".*\n" -> ""
1314

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

1719
use std::env;
1820

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: invalid `--cfg` argument: `a(b=c)` (expected `key` or `key="value"`)
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: invalid `--cfg` argument: `a{b}` (expected `key` or `key="value"`)
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: invalid `--cfg` argument: `a::b` (argument key must be an identifier)
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: invalid `--cfg` argument: `a(b)` (expected `key` or `key="value"`)
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: invalid `--cfg` argument: `a=10` (argument value must be a string)
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: invalid `--cfg` argument: `""` (expected `key` or `key="value"`)
2+

src/test/ui/duplicate/dupe-symbols-7.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
//
22
// error-pattern: entry symbol `main` defined multiple times
3+
4+
// FIXME https://github.com/rust-lang/rust/issues/59774
5+
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
6+
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
37
#![allow(warnings)]
48

59
#[no_mangle]

src/test/ui/duplicate/dupe-symbols-7.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: entry symbol `main` defined multiple times
2-
--> $DIR/dupe-symbols-7.rs:6:1
2+
--> $DIR/dupe-symbols-7.rs:10:1
33
|
44
LL | fn main(){}
55
| ^^^^^^^^^^^

src/test/ui/huge-array-simple.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// error-pattern: too big for the current architecture
22

33
// normalize-stderr-test "; \d+]" -> "; N]"
4+
5+
// FIXME https://github.com/rust-lang/rust/issues/59774
6+
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
7+
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
48
#![allow(exceeding_bitshifts)]
59

610
#[cfg(target_pointer_width = "64")]

src/test/ui/huge-array.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// error-pattern:; 1518600000
22

3+
// FIXME https://github.com/rust-lang/rust/issues/59774
4+
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
5+
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
6+
37
fn generic<T: Copy>(t: T) {
48
let s: [T; 1518600000] = [t; 1518600000];
59
}

src/test/ui/huge-struct.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// normalize-stderr-test "S1M" -> "SXX"
33
// error-pattern: too big for the current
44

5+
// FIXME https://github.com/rust-lang/rust/issues/59774
6+
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
7+
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
8+
59
struct S32<T> {
610
v0: T,
711
v1: T,

src/test/ui/issues/issue-15919.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// error-pattern: too big for the current architecture
22
// normalize-stderr-test "\[usize; \d+\]" -> "[usize; N]"
33

4+
// FIXME https://github.com/rust-lang/rust/issues/59774
5+
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
6+
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
7+
48
#[cfg(target_pointer_width = "32")]
59
fn main() {
610
let x = [0usize; 0xffff_ffff];

src/test/ui/issues/issue-17913.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// normalize-stderr-test "\[&usize; \d+\]" -> "[&usize; N]"
22
// error-pattern: too big for the current architecture
33

4+
// FIXME https://github.com/rust-lang/rust/issues/59774
5+
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
6+
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
7+
48
#![feature(box_syntax)]
59

610
#[cfg(target_pointer_width = "64")]

src/test/ui/issues/issue-56762.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
// only-x86_64
2+
3+
// FIXME https://github.com/rust-lang/rust/issues/59774
4+
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
5+
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
26
const HUGE_SIZE: usize = !0usize / 8;
37

48

src/test/ui/linkage2.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// FIXME https://github.com/rust-lang/rust/issues/59774
2+
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
3+
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
4+
15
#![feature(linkage)]
26

37
extern {

src/test/ui/linkage2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: must have type `*const T` or `*mut T`
2-
--> $DIR/linkage2.rs:4:32
2+
--> $DIR/linkage2.rs:8:32
33
|
44
LL | #[linkage = "extern_weak"] static foo: i32;
55
| ^^^^^^^^^^^^^^^^

src/test/ui/linkage3.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// FIXME https://github.com/rust-lang/rust/issues/59774
2+
// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
3+
// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
4+
15
#![feature(linkage)]
26

37
extern {

src/test/ui/linkage3.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: invalid linkage specified
2-
--> $DIR/linkage3.rs:4:24
2+
--> $DIR/linkage3.rs:8:24
33
|
44
LL | #[linkage = "foo"] static foo: *const i32;
55
| ^^^^^^^^^^^^^^^^^^^^^^^

src/test/ui/pattern/const-pat-ice.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// failure-status: 101
22
// rustc-env:RUST_BACKTRACE=0
3+
// normalize-stderr-test "note: rustc 1.* running on .*" -> "note: rustc VERSION running on TARGET"
4+
// normalize-stderr-test "note: compiler flags: .*" -> "note: compiler flags: FLAGS"
35

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

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
thread 'rustc' panicked at 'assertion failed: rows.iter().all(|r| r.len() == v.len())', src/librustc_mir/hair/pattern/_match.rs:1069:5
2+
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
3+
4+
error: internal compiler error: unexpected panic
5+
6+
note: the compiler unexpectedly panicked. this is a bug.
7+
8+
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
9+
10+
note: rustc VERSION running on TARGET
11+
12+
note: compiler flags: FLAGS
13+

src/tools/compiletest/src/json.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ pub fn extract_rendered(output: &str, proc_res: &ProcRes) -> String {
7878
}
7979
}
8080
} else {
81-
None
81+
// preserve non-JSON lines, such as ICEs
82+
Some(format!("{}\n", line))
8283
}
8384
})
8485
.collect()

0 commit comments

Comments
 (0)