Skip to content

Commit 1deefe5

Browse files
author
Nick Hamann
committed
Fix compiletest to not ignore additional errors.
Also fixes tests to pass.
1 parent c7d26a9 commit 1deefe5

10 files changed

+29
-22
lines changed

src/compiletest/runtest.rs

+13-5
Original file line numberDiff line numberDiff line change
@@ -881,20 +881,28 @@ fn check_error_patterns(props: &TestProps,
881881
}
882882
let mut next_err_idx = 0;
883883
let mut next_err_pat = &props.error_patterns[next_err_idx];
884-
let mut done = false;
885-
for line in output_to_check.lines() {
884+
let mut matched_all_patterns = false;
885+
let mut lines = output_to_check.lines();
886+
for line in &mut lines {
886887
if line.contains(next_err_pat) {
887888
debug!("found error pattern {}", next_err_pat);
888889
next_err_idx += 1;
889890
if next_err_idx == props.error_patterns.len() {
890-
debug!("found all error patterns");
891-
done = true;
891+
matched_all_patterns = true;
892892
break;
893893
}
894894
next_err_pat = &props.error_patterns[next_err_idx];
895895
}
896896
}
897-
if done { return; }
897+
898+
if matched_all_patterns {
899+
if lines.next().is_none() {
900+
debug!("found all error patterns");
901+
return;
902+
} else {
903+
fatal_proc_rec("no more error patterns to match against", proc_res);
904+
}
905+
}
898906

899907
let missing_patterns = &props.error_patterns[next_err_idx..];
900908
if missing_patterns.len() == 1 {

src/test/compile-fail/issue-11154.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -11,5 +11,7 @@
1111
// compile-flags: -C lto -C prefer-dynamic
1212

1313
// error-pattern: cannot prefer dynamic linking
14+
// error-pattern: only 'staticlib' and 'bin' outputs are supported with LTO
15+
// error-pattern: aborting due to previous error
1416

1517
fn main() {}
+2-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,12 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// error-pattern:illegal cast
12-
1311
#![feature(libc)]
1412

1513
extern crate libc;
1614

1715
fn main() {
18-
println!("{:?}", 1.0 as *const libc::FILE); // Can't cast float to foreign.
16+
println!("{:?}", 1.0 as *const libc::FILE); //~ ERROR illegal cast; cast through a usize first: `f64` as `*const libc::types::common::c95::FILE`
1917
}
+2-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// error-pattern:can't find crate for `extra`
12-
13-
extern crate fake_crate as extra;
11+
extern crate fake_crate as extra; //~ ERROR can't find crate for `extra`
1412

1513
fn main() { }
+2-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,6 +8,4 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// error-pattern: mismatched types
12-
13-
fn main() { while main { } }
11+
fn main() { while main { } } //~ ERROR mismatched types
+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,6 +8,5 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// error-pattern: mismatched types
12-
fn mk_int() -> usize { let i: isize = 3; return i; }
11+
fn mk_int() -> usize { let i: isize = 3; return i; } //~ ERROR mismatched types
1312
fn main() { }

src/test/run-fail/panic-task-name-none.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
// error-pattern:thread '<unnamed>' panicked at 'test'
12+
// error-pattern:thread '<main>' panicked at 'assertion failed: r.is_ok()'
1213

1314
use std::thread;
1415

src/test/run-fail/panic-task-name-owned.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
// except according to those terms.
1010

1111
// error-pattern:thread 'owned name' panicked at 'test'
12+
// error-pattern:thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: Any'
1213

1314
use std::thread::Builder;
1415

1516
fn main() {
16-
let r: () = Builder::new().name("owned name".to_string()).spawn(move|| {
17+
let _r: () = Builder::new().name("owned name".to_string()).spawn(move|| {
1718
panic!("test");
1819
()
1920
}).unwrap().join().unwrap();

src/test/run-fail/rt-set-exit-status-panic.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
// error-pattern:whatever
12+
// error-pattern:thread '<main>' panicked at 'explicit panic'
1213

1314
#![feature(exit_status, rustc_private)]
1415

src/test/run-fail/rt-set-exit-status-panic2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
// error-pattern:whatever
12+
// error-pattern:thread '<main>' panicked at 'explicit panic'
1213

1314
#![feature(exit_status, rustc_private)]
1415

0 commit comments

Comments
 (0)