@@ -30,7 +30,6 @@ use treemap::TreeMap;
30
30
31
31
use std:: clone:: Clone ;
32
32
use std:: comm:: { stream, SharedChan , GenericPort , GenericChan } ;
33
- use std:: libc;
34
33
use std:: io;
35
34
use std:: result;
36
35
use std:: task;
@@ -125,8 +124,9 @@ pub type MetricDiff = TreeMap<~str,MetricChange>;
125
124
pub fn test_main ( args : & [ ~str ] , tests : ~[ TestDescAndFn ] ) {
126
125
let opts =
127
126
match parse_opts ( args) {
128
- Ok ( o) => o,
129
- Err ( msg) => fail ! ( msg)
127
+ Some ( Ok ( o) ) => o,
128
+ Some ( Err ( msg) ) => fail ! ( msg) ,
129
+ None => return
130
130
} ;
131
131
if !run_tests_console ( & opts, tests) { fail ! ( "Some tests failed" ) ; }
132
132
}
@@ -189,7 +189,7 @@ fn optgroups() -> ~[getopts::groups::OptGroup] {
189
189
"A.B" ) ]
190
190
}
191
191
192
- fn usage ( binary : & str , helpstr : & str ) -> ! {
192
+ fn usage ( binary : & str , helpstr : & str ) {
193
193
#[ fixed_stack_segment] ; #[ inline( never) ] ;
194
194
195
195
let message = fmt ! ( "Usage: %s [OPTIONS] [FILTER]" , binary) ;
@@ -217,20 +217,19 @@ Test Attributes:
217
217
tests. This may also be written as #[ignore(cfg(...))] to
218
218
ignore the test on certain configurations." ) ;
219
219
}
220
- unsafe { libc:: exit ( 0 ) }
221
220
}
222
221
223
222
// Parses command line arguments into test options
224
- pub fn parse_opts ( args : & [ ~str ] ) -> OptRes {
223
+ pub fn parse_opts ( args : & [ ~str ] ) -> Option < OptRes > {
225
224
let args_ = args. tail ( ) ;
226
225
let matches =
227
226
match groups:: getopts ( args_, optgroups ( ) ) {
228
227
Ok ( m) => m,
229
- Err ( f) => return Err ( f. to_err_msg ( ) )
228
+ Err ( f) => return Some ( Err ( f. to_err_msg ( ) ) )
230
229
} ;
231
230
232
- if matches. opt_present ( "h" ) { usage ( args[ 0 ] , "h" ) ; }
233
- if matches. opt_present ( "help" ) { usage ( args[ 0 ] , "help" ) ; }
231
+ if matches. opt_present ( "h" ) { usage ( args[ 0 ] , "h" ) ; return None ; }
232
+ if matches. opt_present ( "help" ) { usage ( args[ 0 ] , "help" ) ; return None ; }
234
233
235
234
let filter =
236
235
if matches. free . len ( ) > 0 {
@@ -272,7 +271,7 @@ pub fn parse_opts(args: &[~str]) -> OptRes {
272
271
logfile : logfile
273
272
} ;
274
273
275
- Ok ( test_opts)
274
+ Some ( Ok ( test_opts) )
276
275
}
277
276
278
277
pub fn opt_shard ( maybestr : Option < ~str > ) -> Option < ( uint , uint ) > {
@@ -1228,7 +1227,7 @@ mod tests {
1228
1227
fn first_free_arg_should_be_a_filter ( ) {
1229
1228
let args = ~[ ~"progname", ~"filter"] ;
1230
1229
let opts = match parse_opts ( args) {
1231
- Ok ( o) => o,
1230
+ Some ( Ok ( o) ) => o,
1232
1231
_ => fail ! ( "Malformed arg in first_free_arg_should_be_a_filter" )
1233
1232
} ;
1234
1233
assert ! ( "filter" == opts. filter. clone( ) . unwrap( ) ) ;
@@ -1238,7 +1237,7 @@ mod tests {
1238
1237
fn parse_ignored_flag ( ) {
1239
1238
let args = ~[ ~"progname", ~"filter", ~"--ignored"] ;
1240
1239
let opts = match parse_opts ( args) {
1241
- Ok ( o) => o,
1240
+ Some ( Ok ( o) ) => o,
1242
1241
_ => fail ! ( "Malformed arg in parse_ignored_flag" )
1243
1242
} ;
1244
1243
assert ! ( ( opts. run_ignored) ) ;
0 commit comments