1414// we use our own (green) start below; do not link in libnative; issue #13247.
1515#![ no_start]
1616
17- #![ allow( non_camel_case_types) ]
1817#![ deny( warnings) ]
1918
2019extern crate test;
@@ -27,9 +26,10 @@ extern crate rustuv;
2726use std:: os;
2827use std:: io;
2928use std:: io:: fs;
29+ use std:: from_str:: FromStr ;
3030use getopts:: { optopt, optflag, reqopt} ;
31- use common:: { config , mode_run_pass , mode_run_fail , mode_compile_fail , mode_pretty ,
32- mode_debug_info_gdb , mode_debug_info_lldb , mode_codegen , mode } ;
31+ use common:: Config ;
32+ use common :: { Pretty , DebugInfoGdb , Codegen } ;
3333use util:: logv;
3434
3535pub mod procsrv;
@@ -51,7 +51,7 @@ pub fn main() {
5151 run_tests ( & config) ;
5252}
5353
54- pub fn parse_config ( args : Vec < ~str > ) -> config {
54+ pub fn parse_config ( args : Vec < ~str > ) -> Config {
5555
5656 let groups : Vec < getopts:: OptGroup > =
5757 vec ! ( reqopt( "" , "compile-lib-path" , "path to host shared libraries" , "PATH" ) ,
@@ -112,7 +112,7 @@ pub fn parse_config(args: Vec<~str> ) -> config {
112112 Path :: new ( m. opt_str ( nm) . unwrap ( ) )
113113 }
114114
115- config {
115+ Config {
116116 compile_lib_path : matches. opt_str ( "compile-lib-path" ) . unwrap ( ) ,
117117 run_lib_path : matches. opt_str ( "run-lib-path" ) . unwrap ( ) ,
118118 rustc_path : opt_path ( matches, "rustc-path" ) ,
@@ -122,7 +122,7 @@ pub fn parse_config(args: Vec<~str> ) -> config {
122122 build_base : opt_path ( matches, "build-base" ) ,
123123 aux_base : opt_path ( matches, "aux-base" ) ,
124124 stage_id : matches. opt_str ( "stage-id" ) . unwrap ( ) ,
125- mode : str_mode ( matches. opt_str ( "mode" ) . unwrap ( ) ) ,
125+ mode : FromStr :: from_str ( matches. opt_str ( "mode" ) . unwrap ( ) ) . expect ( "invalid mode" ) ,
126126 run_ignored : matches. opt_present ( "ignored" ) ,
127127 filter :
128128 if !matches. free . is_empty ( ) {
@@ -155,7 +155,7 @@ pub fn parse_config(args: Vec<~str> ) -> config {
155155 }
156156}
157157
158- pub fn log_config ( config : & config ) {
158+ pub fn log_config ( config : & Config ) {
159159 let c = config;
160160 logv ( c, format ! ( "configuration:" ) ) ;
161161 logv ( c, format ! ( "compile_lib_path: {}" , config. compile_lib_path) ) ;
@@ -164,7 +164,7 @@ pub fn log_config(config: &config) {
164164 logv ( c, format ! ( "src_base: {}" , config. src_base. display( ) ) ) ;
165165 logv ( c, format ! ( "build_base: {}" , config. build_base. display( ) ) ) ;
166166 logv ( c, format ! ( "stage_id: {}" , config. stage_id) ) ;
167- logv ( c, format ! ( "mode: {}" , mode_str ( config. mode) ) ) ;
167+ logv ( c, format ! ( "mode: {}" , config. mode) ) ;
168168 logv ( c, format ! ( "run_ignored: {}" , config. run_ignored) ) ;
169169 logv ( c, format ! ( "filter: {}" , opt_str( & config. filter) ) ) ;
170170 logv ( c, format ! ( "runtool: {}" , opt_str( & config. runtool) ) ) ;
@@ -198,35 +198,10 @@ pub fn opt_str2(maybestr: Option<~str>) -> ~str {
198198 match maybestr { None => "(none)" . to_owned ( ) , Some ( s) => { s } }
199199}
200200
201- pub fn str_mode ( s : ~str ) -> mode {
202- match s. as_slice ( ) {
203- "compile-fail" => mode_compile_fail,
204- "run-fail" => mode_run_fail,
205- "run-pass" => mode_run_pass,
206- "pretty" => mode_pretty,
207- "debuginfo-gdb" => mode_debug_info_gdb,
208- "debuginfo-lldb" => mode_debug_info_lldb,
209- "codegen" => mode_codegen,
210- s => fail ! ( "invalid mode: " + s)
211- }
212- }
213-
214- pub fn mode_str ( mode : mode ) -> ~str {
215- match mode {
216- mode_compile_fail => "compile-fail" . to_owned ( ) ,
217- mode_run_fail => "run-fail" . to_owned ( ) ,
218- mode_run_pass => "run-pass" . to_owned ( ) ,
219- mode_pretty => "pretty" . to_owned ( ) ,
220- mode_debug_info_gdb => "debuginfo-gdb" . to_owned ( ) ,
221- mode_debug_info_lldb => "debuginfo-lldb" . to_owned ( ) ,
222- mode_codegen => "codegen" . to_owned ( ) ,
223- }
224- }
225-
226- pub fn run_tests ( config : & config ) {
201+ pub fn run_tests ( config : & Config ) {
227202 if config. target == "arm-linux-androideabi" . to_owned ( ) {
228- match config. mode {
229- mode_debug_info_gdb => {
203+ match config. mode {
204+ DebugInfoGdb => {
230205 println ! ( "arm-linux-androideabi debug-info \
231206 test uses tcp 5039 port. please reserve it") ;
232207 }
@@ -255,7 +230,7 @@ pub fn run_tests(config: &config) {
255230 }
256231}
257232
258- pub fn test_opts ( config : & config ) -> test:: TestOpts {
233+ pub fn test_opts ( config : & Config ) -> test:: TestOpts {
259234 test:: TestOpts {
260235 filter : config. filter . clone ( ) ,
261236 run_ignored : config. run_ignored ,
@@ -270,7 +245,7 @@ pub fn test_opts(config: &config) -> test::TestOpts {
270245 }
271246}
272247
273- pub fn make_tests ( config : & config ) -> Vec < test:: TestDescAndFn > {
248+ pub fn make_tests ( config : & Config ) -> Vec < test:: TestDescAndFn > {
274249 debug ! ( "making tests from {}" ,
275250 config. src_base. display( ) ) ;
276251 let mut tests = Vec :: new ( ) ;
@@ -281,7 +256,7 @@ pub fn make_tests(config: &config) -> Vec<test::TestDescAndFn> {
281256 if is_test ( config, & file) {
282257 let t = make_test ( config, & file, || {
283258 match config. mode {
284- mode_codegen => make_metrics_test_closure ( config, & file) ,
259+ Codegen => make_metrics_test_closure ( config, & file) ,
285260 _ => make_test_closure ( config, & file)
286261 }
287262 } ) ;
@@ -291,11 +266,11 @@ pub fn make_tests(config: &config) -> Vec<test::TestDescAndFn> {
291266 tests
292267}
293268
294- pub fn is_test ( config : & config , testfile : & Path ) -> bool {
269+ pub fn is_test ( config : & Config , testfile : & Path ) -> bool {
295270 // Pretty-printer does not work with .rc files yet
296271 let valid_extensions =
297272 match config. mode {
298- mode_pretty => vec ! ( ".rs" . to_owned( ) ) ,
273+ Pretty => vec ! ( ".rs" . to_owned( ) ) ,
299274 _ => vec ! ( ".rc" . to_owned( ) , ".rs" . to_owned( ) )
300275 } ;
301276 let invalid_prefixes = vec ! ( "." . to_owned( ) , "#" . to_owned( ) , "~" . to_owned( ) ) ;
@@ -314,7 +289,7 @@ pub fn is_test(config: &config, testfile: &Path) -> bool {
314289 return valid;
315290}
316291
317- pub fn make_test ( config : & config , testfile : & Path , f: || -> test:: TestFn )
292+ pub fn make_test ( config : & Config , testfile : & Path , f: || -> test:: TestFn )
318293 -> test:: TestDescAndFn {
319294 test:: TestDescAndFn {
320295 desc : test:: TestDesc {
@@ -326,7 +301,7 @@ pub fn make_test(config: &config, testfile: &Path, f: || -> test::TestFn)
326301 }
327302}
328303
329- pub fn make_test_name ( config : & config , testfile : & Path ) -> test:: TestName {
304+ pub fn make_test_name ( config : & Config , testfile : & Path ) -> test:: TestName {
330305
331306 // Try to elide redundant long paths
332307 fn shorten ( path : & Path ) -> ~str {
@@ -336,19 +311,17 @@ pub fn make_test_name(config: &config, testfile: &Path) -> test::TestName {
336311 format ! ( "{}/{}" , dir. unwrap_or( "" ) , filename. unwrap_or( "" ) )
337312 }
338313
339- test:: DynTestName ( format ! ( "[{}] {}" ,
340- mode_str( config. mode) ,
341- shorten( testfile) ) )
314+ test:: DynTestName ( format ! ( "[{}] {}" , config. mode, shorten( testfile) ) )
342315}
343316
344- pub fn make_test_closure ( config : & config , testfile : & Path ) -> test:: TestFn {
317+ pub fn make_test_closure ( config : & Config , testfile : & Path ) -> test:: TestFn {
345318 let config = ( * config) . clone ( ) ;
346319 // FIXME (#9639): This needs to handle non-utf8 paths
347320 let testfile = testfile. as_str ( ) . unwrap ( ) . to_owned ( ) ;
348321 test:: DynTestFn ( proc ( ) { runtest:: run ( config, testfile) } )
349322}
350323
351- pub fn make_metrics_test_closure ( config : & config , testfile : & Path ) -> test:: TestFn {
324+ pub fn make_metrics_test_closure ( config : & Config , testfile : & Path ) -> test:: TestFn {
352325 let config = ( * config) . clone ( ) ;
353326 // FIXME (#9639): This needs to handle non-utf8 paths
354327 let testfile = testfile. as_str ( ) . unwrap ( ) . to_owned ( ) ;
0 commit comments