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) ]
17
18
#![ deny( warnings) ]
18
19
19
20
extern crate test;
@@ -26,10 +27,9 @@ extern crate rustuv;
26
27
use std:: os;
27
28
use std:: io;
28
29
use std:: io:: fs;
29
- use std:: from_str:: FromStr ;
30
30
use getopts:: { optopt, optflag, reqopt} ;
31
- use common:: Config ;
32
- use common :: { Pretty , DebugInfoGdb , Codegen } ;
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 } ;
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 : FromStr :: from_str ( matches. opt_str ( "mode" ) . unwrap ( ) ) . expect ( "invalid mode" ) ,
125
+ mode : str_mode ( matches. opt_str ( "mode" ) . unwrap ( ) ) ,
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: {}" , config. mode) ) ;
167
+ logv ( c, format ! ( "mode: {}" , mode_str ( 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,10 +198,35 @@ 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 run_tests ( config : & Config ) {
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 ) {
202
227
if config. target == "arm-linux-androideabi" . to_owned ( ) {
203
- match config. mode {
204
- DebugInfoGdb => {
228
+ match config. mode {
229
+ mode_debug_info_gdb => {
205
230
println ! ( "arm-linux-androideabi debug-info \
206
231
test uses tcp 5039 port. please reserve it") ;
207
232
}
@@ -230,7 +255,7 @@ pub fn run_tests(config: &Config) {
230
255
}
231
256
}
232
257
233
- pub fn test_opts ( config : & Config ) -> test:: TestOpts {
258
+ pub fn test_opts ( config : & config ) -> test:: TestOpts {
234
259
test:: TestOpts {
235
260
filter : config. filter . clone ( ) ,
236
261
run_ignored : config. run_ignored ,
@@ -245,7 +270,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
245
270
}
246
271
}
247
272
248
- pub fn make_tests ( config : & Config ) -> Vec < test:: TestDescAndFn > {
273
+ pub fn make_tests ( config : & config ) -> Vec < test:: TestDescAndFn > {
249
274
debug ! ( "making tests from {}" ,
250
275
config. src_base. display( ) ) ;
251
276
let mut tests = Vec :: new ( ) ;
@@ -256,7 +281,7 @@ pub fn make_tests(config: &Config) -> Vec<test::TestDescAndFn> {
256
281
if is_test ( config, & file) {
257
282
let t = make_test ( config, & file, || {
258
283
match config. mode {
259
- Codegen => make_metrics_test_closure ( config, & file) ,
284
+ mode_codegen => make_metrics_test_closure ( config, & file) ,
260
285
_ => make_test_closure ( config, & file)
261
286
}
262
287
} ) ;
@@ -266,11 +291,11 @@ pub fn make_tests(config: &Config) -> Vec<test::TestDescAndFn> {
266
291
tests
267
292
}
268
293
269
- pub fn is_test ( config : & Config , testfile : & Path ) -> bool {
294
+ pub fn is_test ( config : & config , testfile : & Path ) -> bool {
270
295
// Pretty-printer does not work with .rc files yet
271
296
let valid_extensions =
272
297
match config. mode {
273
- Pretty => vec ! ( ".rs" . to_owned( ) ) ,
298
+ mode_pretty => vec ! ( ".rs" . to_owned( ) ) ,
274
299
_ => vec ! ( ".rc" . to_owned( ) , ".rs" . to_owned( ) )
275
300
} ;
276
301
let invalid_prefixes = vec ! ( "." . to_owned( ) , "#" . to_owned( ) , "~" . to_owned( ) ) ;
@@ -289,7 +314,7 @@ pub fn is_test(config: &Config, testfile: &Path) -> bool {
289
314
return valid;
290
315
}
291
316
292
- pub fn make_test ( config : & Config , testfile : & Path , f: || -> test:: TestFn )
317
+ pub fn make_test ( config : & config , testfile : & Path , f: || -> test:: TestFn )
293
318
-> test:: TestDescAndFn {
294
319
test:: TestDescAndFn {
295
320
desc : test:: TestDesc {
@@ -301,7 +326,7 @@ pub fn make_test(config: &Config, testfile: &Path, f: || -> test::TestFn)
301
326
}
302
327
}
303
328
304
- pub fn make_test_name ( config : & Config , testfile : & Path ) -> test:: TestName {
329
+ pub fn make_test_name ( config : & config , testfile : & Path ) -> test:: TestName {
305
330
306
331
// Try to elide redundant long paths
307
332
fn shorten ( path : & Path ) -> ~str {
@@ -311,17 +336,19 @@ pub fn make_test_name(config: &Config, testfile: &Path) -> test::TestName {
311
336
format ! ( "{}/{}" , dir. unwrap_or( "" ) , filename. unwrap_or( "" ) )
312
337
}
313
338
314
- test:: DynTestName ( format ! ( "[{}] {}" , config. mode, shorten( testfile) ) )
339
+ test:: DynTestName ( format ! ( "[{}] {}" ,
340
+ mode_str( config. mode) ,
341
+ shorten( testfile) ) )
315
342
}
316
343
317
- pub fn make_test_closure ( config : & Config , testfile : & Path ) -> test:: TestFn {
344
+ pub fn make_test_closure ( config : & config , testfile : & Path ) -> test:: TestFn {
318
345
let config = ( * config) . clone ( ) ;
319
346
// FIXME (#9639): This needs to handle non-utf8 paths
320
347
let testfile = testfile. as_str ( ) . unwrap ( ) . to_owned ( ) ;
321
348
test:: DynTestFn ( proc ( ) { runtest:: run ( config, testfile) } )
322
349
}
323
350
324
- pub fn make_metrics_test_closure ( config : & Config , testfile : & Path ) -> test:: TestFn {
351
+ pub fn make_metrics_test_closure ( config : & config , testfile : & Path ) -> test:: TestFn {
325
352
let config = ( * config) . clone ( ) ;
326
353
// FIXME (#9639): This needs to handle non-utf8 paths
327
354
let testfile = testfile. as_str ( ) . unwrap ( ) . to_owned ( ) ;
0 commit comments