@@ -30,7 +30,6 @@ use treemap::TreeMap;
3030
3131use std:: clone:: Clone ;
3232use std:: comm:: { stream, SharedChan , GenericPort , GenericChan } ;
33- use std:: libc;
3433use std:: io;
3534use std:: result;
3635use std:: task;
@@ -125,8 +124,9 @@ pub type MetricDiff = TreeMap<~str,MetricChange>;
125124pub fn test_main ( args : & [ ~str ] , tests : ~[ TestDescAndFn ] ) {
126125 let opts =
127126 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
130130 } ;
131131 if !run_tests_console ( & opts, tests) { fail ! ( "Some tests failed" ) ; }
132132}
@@ -189,7 +189,7 @@ fn optgroups() -> ~[getopts::groups::OptGroup] {
189189 "A.B" ) ]
190190}
191191
192- fn usage ( binary : & str , helpstr : & str ) -> ! {
192+ fn usage ( binary : & str , helpstr : & str ) {
193193 #[ fixed_stack_segment] ; #[ inline( never) ] ;
194194
195195 let message = fmt ! ( "Usage: %s [OPTIONS] [FILTER]" , binary) ;
@@ -217,20 +217,19 @@ Test Attributes:
217217 tests. This may also be written as #[ignore(cfg(...))] to
218218 ignore the test on certain configurations." ) ;
219219 }
220- unsafe { libc:: exit ( 0 ) }
221220}
222221
223222// Parses command line arguments into test options
224- pub fn parse_opts ( args : & [ ~str ] ) -> OptRes {
223+ pub fn parse_opts ( args : & [ ~str ] ) -> Option < OptRes > {
225224 let args_ = args. tail ( ) ;
226225 let matches =
227226 match groups:: getopts ( args_, optgroups ( ) ) {
228227 Ok ( m) => m,
229- Err ( f) => return Err ( f. to_err_msg ( ) )
228+ Err ( f) => return Some ( Err ( f. to_err_msg ( ) ) )
230229 } ;
231230
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 ; }
234233
235234 let filter =
236235 if matches. free . len ( ) > 0 {
@@ -272,7 +271,7 @@ pub fn parse_opts(args: &[~str]) -> OptRes {
272271 logfile : logfile
273272 } ;
274273
275- Ok ( test_opts)
274+ Some ( Ok ( test_opts) )
276275}
277276
278277pub fn opt_shard ( maybestr : Option < ~str > ) -> Option < ( uint , uint ) > {
@@ -1228,7 +1227,7 @@ mod tests {
12281227 fn first_free_arg_should_be_a_filter ( ) {
12291228 let args = ~[ ~"progname", ~"filter"] ;
12301229 let opts = match parse_opts ( args) {
1231- Ok ( o) => o,
1230+ Some ( Ok ( o) ) => o,
12321231 _ => fail ! ( "Malformed arg in first_free_arg_should_be_a_filter" )
12331232 } ;
12341233 assert ! ( "filter" == opts. filter. clone( ) . unwrap( ) ) ;
@@ -1238,7 +1237,7 @@ mod tests {
12381237 fn parse_ignored_flag ( ) {
12391238 let args = ~[ ~"progname", ~"filter", ~"--ignored"] ;
12401239 let opts = match parse_opts ( args) {
1241- Ok ( o) => o,
1240+ Some ( Ok ( o) ) => o,
12421241 _ => fail ! ( "Malformed arg in parse_ignored_flag" )
12431242 } ;
12441243 assert ! ( ( opts. run_ignored) ) ;
0 commit comments