@@ -94,7 +94,7 @@ pub fn run(input: &str, matches: &getopts::Matches) -> int {
94
94
0
95
95
}
96
96
97
- fn runtest ( test : & str , cratename : & str , libs : HashSet < Path > ) {
97
+ fn runtest ( test : & str , cratename : & str , libs : HashSet < Path > , should_fail : bool ) {
98
98
let test = maketest ( test, cratename) ;
99
99
let parsesess = parse:: new_parse_sess ( ) ;
100
100
let input = driver:: StrInput ( test) ;
@@ -130,9 +130,10 @@ fn runtest(test: &str, cratename: &str, libs: HashSet<Path>) {
130
130
match out {
131
131
Err ( e) => fail ! ( "couldn't run the test: {}" , e) ,
132
132
Ok ( out) => {
133
- if !out. status . success ( ) {
134
- fail ! ( "test executable failed:\n {}" ,
135
- str :: from_utf8( out. error) ) ;
133
+ if should_fail && out. status . success ( ) {
134
+ fail ! ( "test executable succeeded when it should have failed" ) ;
135
+ } else if !should_fail && !out. status . success ( ) {
136
+ fail ! ( "test executable failed:\n {}" , str :: from_utf8( out. error) ) ;
136
137
}
137
138
}
138
139
}
@@ -169,7 +170,7 @@ pub struct Collector {
169
170
}
170
171
171
172
impl Collector {
172
- pub fn add_test ( & mut self , test : & str , ignore : bool , should_fail : bool ) {
173
+ pub fn add_test ( & mut self , test : & str , should_fail : bool ) {
173
174
let test = test. to_owned ( ) ;
174
175
let name = format ! ( "{}_{}" , self . names. connect( "::" ) , self . cnt) ;
175
176
self . cnt += 1 ;
@@ -180,11 +181,11 @@ impl Collector {
180
181
self . tests . push ( test:: TestDescAndFn {
181
182
desc : test:: TestDesc {
182
183
name : test:: DynTestName ( name) ,
183
- ignore : ignore ,
184
- should_fail : should_fail ,
184
+ ignore : false ,
185
+ should_fail : false , // compiler failures are test failures
185
186
} ,
186
187
testfn : test:: DynTestFn ( proc ( ) {
187
- runtest ( test, cratename, libs) ;
188
+ runtest ( test, cratename, libs, should_fail ) ;
188
189
} ) ,
189
190
} ) ;
190
191
}
0 commit comments