14
14
// we use our own (green) start below; do not link in libnative; issue #13247.
15
15
#![ no_start]
16
16
17
- #![ allow( non_camel_case_types) ]
18
17
#![ deny( warnings) ]
19
18
20
19
extern crate test;
@@ -27,9 +26,10 @@ extern crate rustuv;
27
26
use std:: os;
28
27
use std:: io;
29
28
use std:: io:: fs;
29
+ use std:: from_str:: FromStr ;
30
30
use 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 } ;
33
33
use util:: logv;
34
34
35
35
pub mod procsrv;
@@ -51,7 +51,7 @@ pub fn main() {
51
51
run_tests ( & config) ;
52
52
}
53
53
54
- pub fn parse_config ( args : Vec < ~str > ) -> config {
54
+ pub fn parse_config ( args : Vec < ~str > ) -> Config {
55
55
56
56
let groups : Vec < getopts:: OptGroup > =
57
57
vec ! ( reqopt( "" , "compile-lib-path" , "path to host shared libraries" , "PATH" ) ,
@@ -112,7 +112,7 @@ pub fn parse_config(args: Vec<~str> ) -> config {
112
112
Path :: new ( m. opt_str ( nm) . unwrap ( ) )
113
113
}
114
114
115
- config {
115
+ Config {
116
116
compile_lib_path : matches. opt_str ( "compile-lib-path" ) . unwrap ( ) ,
117
117
run_lib_path : matches. opt_str ( "run-lib-path" ) . unwrap ( ) ,
118
118
rustc_path : opt_path ( matches, "rustc-path" ) ,
@@ -122,7 +122,7 @@ pub fn parse_config(args: Vec<~str> ) -> config {
122
122
build_base : opt_path ( matches, "build-base" ) ,
123
123
aux_base : opt_path ( matches, "aux-base" ) ,
124
124
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" ) ,
126
126
run_ignored : matches. opt_present ( "ignored" ) ,
127
127
filter :
128
128
if !matches. free . is_empty ( ) {
@@ -155,7 +155,7 @@ pub fn parse_config(args: Vec<~str> ) -> config {
155
155
}
156
156
}
157
157
158
- pub fn log_config ( config : & config ) {
158
+ pub fn log_config ( config : & Config ) {
159
159
let c = config;
160
160
logv ( c, format ! ( "configuration:" ) ) ;
161
161
logv ( c, format ! ( "compile_lib_path: {}" , config. compile_lib_path) ) ;
@@ -164,7 +164,7 @@ pub fn log_config(config: &config) {
164
164
logv ( c, format ! ( "src_base: {}" , config. src_base. display( ) ) ) ;
165
165
logv ( c, format ! ( "build_base: {}" , config. build_base. display( ) ) ) ;
166
166
logv ( c, format ! ( "stage_id: {}" , config. stage_id) ) ;
167
- logv ( c, format ! ( "mode: {}" , mode_str ( config. mode) ) ) ;
167
+ logv ( c, format ! ( "mode: {}" , config. mode) ) ;
168
168
logv ( c, format ! ( "run_ignored: {}" , config. run_ignored) ) ;
169
169
logv ( c, format ! ( "filter: {}" , opt_str( & config. filter) ) ) ;
170
170
logv ( c, format ! ( "runtool: {}" , opt_str( & config. runtool) ) ) ;
@@ -198,35 +198,10 @@ pub fn opt_str2(maybestr: Option<~str>) -> ~str {
198
198
match maybestr { None => "(none)" . to_owned ( ) , Some ( s) => { s } }
199
199
}
200
200
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 ) {
227
202
if config. target == "arm-linux-androideabi" . to_owned ( ) {
228
- match config. mode {
229
- mode_debug_info_gdb => {
203
+ match config. mode {
204
+ DebugInfoGdb => {
230
205
println ! ( "arm-linux-androideabi debug-info \
231
206
test uses tcp 5039 port. please reserve it") ;
232
207
}
@@ -255,7 +230,7 @@ pub fn run_tests(config: &config) {
255
230
}
256
231
}
257
232
258
- pub fn test_opts ( config : & config ) -> test:: TestOpts {
233
+ pub fn test_opts ( config : & Config ) -> test:: TestOpts {
259
234
test:: TestOpts {
260
235
filter : config. filter . clone ( ) ,
261
236
run_ignored : config. run_ignored ,
@@ -270,7 +245,7 @@ pub fn test_opts(config: &config) -> test::TestOpts {
270
245
}
271
246
}
272
247
273
- pub fn make_tests ( config : & config ) -> Vec < test:: TestDescAndFn > {
248
+ pub fn make_tests ( config : & Config ) -> Vec < test:: TestDescAndFn > {
274
249
debug ! ( "making tests from {}" ,
275
250
config. src_base. display( ) ) ;
276
251
let mut tests = Vec :: new ( ) ;
@@ -281,7 +256,7 @@ pub fn make_tests(config: &config) -> Vec<test::TestDescAndFn> {
281
256
if is_test ( config, & file) {
282
257
let t = make_test ( config, & file, || {
283
258
match config. mode {
284
- mode_codegen => make_metrics_test_closure ( config, & file) ,
259
+ Codegen => make_metrics_test_closure ( config, & file) ,
285
260
_ => make_test_closure ( config, & file)
286
261
}
287
262
} ) ;
@@ -291,11 +266,11 @@ pub fn make_tests(config: &config) -> Vec<test::TestDescAndFn> {
291
266
tests
292
267
}
293
268
294
- pub fn is_test ( config : & config , testfile : & Path ) -> bool {
269
+ pub fn is_test ( config : & Config , testfile : & Path ) -> bool {
295
270
// Pretty-printer does not work with .rc files yet
296
271
let valid_extensions =
297
272
match config. mode {
298
- mode_pretty => vec ! ( ".rs" . to_owned( ) ) ,
273
+ Pretty => vec ! ( ".rs" . to_owned( ) ) ,
299
274
_ => vec ! ( ".rc" . to_owned( ) , ".rs" . to_owned( ) )
300
275
} ;
301
276
let invalid_prefixes = vec ! ( "." . to_owned( ) , "#" . to_owned( ) , "~" . to_owned( ) ) ;
@@ -314,7 +289,7 @@ pub fn is_test(config: &config, testfile: &Path) -> bool {
314
289
return valid;
315
290
}
316
291
317
- pub fn make_test ( config : & config , testfile : & Path , f: || -> test:: TestFn )
292
+ pub fn make_test ( config : & Config , testfile : & Path , f: || -> test:: TestFn )
318
293
-> test:: TestDescAndFn {
319
294
test:: TestDescAndFn {
320
295
desc : test:: TestDesc {
@@ -326,7 +301,7 @@ pub fn make_test(config: &config, testfile: &Path, f: || -> test::TestFn)
326
301
}
327
302
}
328
303
329
- pub fn make_test_name ( config : & config , testfile : & Path ) -> test:: TestName {
304
+ pub fn make_test_name ( config : & Config , testfile : & Path ) -> test:: TestName {
330
305
331
306
// Try to elide redundant long paths
332
307
fn shorten ( path : & Path ) -> ~str {
@@ -336,19 +311,17 @@ pub fn make_test_name(config: &config, testfile: &Path) -> test::TestName {
336
311
format ! ( "{}/{}" , dir. unwrap_or( "" ) , filename. unwrap_or( "" ) )
337
312
}
338
313
339
- test:: DynTestName ( format ! ( "[{}] {}" ,
340
- mode_str( config. mode) ,
341
- shorten( testfile) ) )
314
+ test:: DynTestName ( format ! ( "[{}] {}" , config. mode, shorten( testfile) ) )
342
315
}
343
316
344
- pub fn make_test_closure ( config : & config , testfile : & Path ) -> test:: TestFn {
317
+ pub fn make_test_closure ( config : & Config , testfile : & Path ) -> test:: TestFn {
345
318
let config = ( * config) . clone ( ) ;
346
319
// FIXME (#9639): This needs to handle non-utf8 paths
347
320
let testfile = testfile. as_str ( ) . unwrap ( ) . to_owned ( ) ;
348
321
test:: DynTestFn ( proc ( ) { runtest:: run ( config, testfile) } )
349
322
}
350
323
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 {
352
325
let config = ( * config) . clone ( ) ;
353
326
// FIXME (#9639): This needs to handle non-utf8 paths
354
327
let testfile = testfile. as_str ( ) . unwrap ( ) . to_owned ( ) ;
0 commit comments