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" ) ,
@@ -79,7 +79,6 @@ pub fn parse_config(args: Vec<~str> ) -> Config {
79
79
optflag( "" , "jit" , "run tests under the JIT" ) ,
80
80
optopt( "" , "target" , "the target to build for" , "TARGET" ) ,
81
81
optopt( "" , "host" , "the host to build for" , "HOST" ) ,
82
- optopt( "" , "android-cross-path" , "Android NDK standalone path" , "PATH" ) ,
83
82
optopt( "" , "adb-path" , "path to the android debugger" , "PATH" ) ,
84
83
optopt( "" , "adb-test-dir" , "path to tests for the android debugger" , "PATH" ) ,
85
84
optopt( "" , "lldb-python-dir" , "directory containing LLDB's python module" , "PATH" ) ,
@@ -113,7 +112,7 @@ pub fn parse_config(args: Vec<~str> ) -> Config {
113
112
Path :: new ( m. opt_str ( nm) . unwrap ( ) )
114
113
}
115
114
116
- Config {
115
+ config {
117
116
compile_lib_path : matches. opt_str ( "compile-lib-path" ) . unwrap ( ) ,
118
117
run_lib_path : matches. opt_str ( "run-lib-path" ) . unwrap ( ) ,
119
118
rustc_path : opt_path ( matches, "rustc-path" ) ,
@@ -123,7 +122,7 @@ pub fn parse_config(args: Vec<~str> ) -> Config {
123
122
build_base : opt_path ( matches, "build-base" ) ,
124
123
aux_base : opt_path ( matches, "aux-base" ) ,
125
124
stage_id : matches. opt_str ( "stage-id" ) . unwrap ( ) ,
126
- mode : FromStr :: from_str ( matches. opt_str ( "mode" ) . unwrap ( ) ) . expect ( "invalid mode" ) ,
125
+ mode : str_mode ( matches. opt_str ( "mode" ) . unwrap ( ) ) ,
127
126
run_ignored : matches. opt_present ( "ignored" ) ,
128
127
filter :
129
128
if !matches. free . is_empty ( ) {
@@ -143,7 +142,6 @@ pub fn parse_config(args: Vec<~str> ) -> Config {
143
142
jit : matches. opt_present ( "jit" ) ,
144
143
target : opt_str2 ( matches. opt_str ( "target" ) ) . to_str ( ) ,
145
144
host : opt_str2 ( matches. opt_str ( "host" ) ) . to_str ( ) ,
146
- android_cross_path : opt_path ( matches, "android-cross-path" ) ,
147
145
adb_path : opt_str2 ( matches. opt_str ( "adb-path" ) ) . to_str ( ) ,
148
146
adb_test_dir :
149
147
opt_str2 ( matches. opt_str ( "adb-test-dir" ) ) . to_str ( ) ,
@@ -157,7 +155,7 @@ pub fn parse_config(args: Vec<~str> ) -> Config {
157
155
}
158
156
}
159
157
160
- pub fn log_config ( config : & Config ) {
158
+ pub fn log_config ( config : & config ) {
161
159
let c = config;
162
160
logv ( c, format ! ( "configuration:" ) ) ;
163
161
logv ( c, format ! ( "compile_lib_path: {}" , config. compile_lib_path) ) ;
@@ -166,7 +164,7 @@ pub fn log_config(config: &Config) {
166
164
logv ( c, format ! ( "src_base: {}" , config. src_base. display( ) ) ) ;
167
165
logv ( c, format ! ( "build_base: {}" , config. build_base. display( ) ) ) ;
168
166
logv ( c, format ! ( "stage_id: {}" , config. stage_id) ) ;
169
- logv ( c, format ! ( "mode: {}" , config. mode) ) ;
167
+ logv ( c, format ! ( "mode: {}" , mode_str ( config. mode) ) ) ;
170
168
logv ( c, format ! ( "run_ignored: {}" , config. run_ignored) ) ;
171
169
logv ( c, format ! ( "filter: {}" , opt_str( & config. filter) ) ) ;
172
170
logv ( c, format ! ( "runtool: {}" , opt_str( & config. runtool) ) ) ;
@@ -175,7 +173,6 @@ pub fn log_config(config: &Config) {
175
173
logv ( c, format ! ( "jit: {}" , config. jit) ) ;
176
174
logv ( c, format ! ( "target: {}" , config. target) ) ;
177
175
logv ( c, format ! ( "host: {}" , config. host) ) ;
178
- logv ( c, format ! ( "android-cross-path: {}" , config. android_cross_path. display( ) ) ) ;
179
176
logv ( c, format ! ( "adb_path: {}" , config. adb_path) ) ;
180
177
logv ( c, format ! ( "adb_test_dir: {}" , config. adb_test_dir) ) ;
181
178
logv ( c, format ! ( "adb_device_status: {}" , config. adb_device_status) ) ;
@@ -201,10 +198,35 @@ pub fn opt_str2(maybestr: Option<~str>) -> ~str {
201
198
match maybestr { None => "(none)" . to_owned ( ) , Some ( s) => { s } }
202
199
}
203
200
204
- 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 ) {
205
227
if config. target == "arm-linux-androideabi" . to_owned ( ) {
206
- match config. mode {
207
- DebugInfoGdb => {
228
+ match config. mode {
229
+ mode_debug_info_gdb => {
208
230
println ! ( "arm-linux-androideabi debug-info \
209
231
test uses tcp 5039 port. please reserve it") ;
210
232
}
@@ -233,7 +255,7 @@ pub fn run_tests(config: &Config) {
233
255
}
234
256
}
235
257
236
- pub fn test_opts ( config : & Config ) -> test:: TestOpts {
258
+ pub fn test_opts ( config : & config ) -> test:: TestOpts {
237
259
test:: TestOpts {
238
260
filter : config. filter . clone ( ) ,
239
261
run_ignored : config. run_ignored ,
@@ -248,7 +270,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
248
270
}
249
271
}
250
272
251
- pub fn make_tests ( config : & Config ) -> Vec < test:: TestDescAndFn > {
273
+ pub fn make_tests ( config : & config ) -> Vec < test:: TestDescAndFn > {
252
274
debug ! ( "making tests from {}" ,
253
275
config. src_base. display( ) ) ;
254
276
let mut tests = Vec :: new ( ) ;
@@ -259,7 +281,7 @@ pub fn make_tests(config: &Config) -> Vec<test::TestDescAndFn> {
259
281
if is_test ( config, & file) {
260
282
let t = make_test ( config, & file, || {
261
283
match config. mode {
262
- Codegen => make_metrics_test_closure ( config, & file) ,
284
+ mode_codegen => make_metrics_test_closure ( config, & file) ,
263
285
_ => make_test_closure ( config, & file)
264
286
}
265
287
} ) ;
@@ -269,11 +291,11 @@ pub fn make_tests(config: &Config) -> Vec<test::TestDescAndFn> {
269
291
tests
270
292
}
271
293
272
- pub fn is_test ( config : & Config , testfile : & Path ) -> bool {
294
+ pub fn is_test ( config : & config , testfile : & Path ) -> bool {
273
295
// Pretty-printer does not work with .rc files yet
274
296
let valid_extensions =
275
297
match config. mode {
276
- Pretty => vec ! ( ".rs" . to_owned( ) ) ,
298
+ mode_pretty => vec ! ( ".rs" . to_owned( ) ) ,
277
299
_ => vec ! ( ".rc" . to_owned( ) , ".rs" . to_owned( ) )
278
300
} ;
279
301
let invalid_prefixes = vec ! ( "." . to_owned( ) , "#" . to_owned( ) , "~" . to_owned( ) ) ;
@@ -292,7 +314,7 @@ pub fn is_test(config: &Config, testfile: &Path) -> bool {
292
314
return valid;
293
315
}
294
316
295
- pub fn make_test ( config : & Config , testfile : & Path , f: || -> test:: TestFn )
317
+ pub fn make_test ( config : & config , testfile : & Path , f: || -> test:: TestFn )
296
318
-> test:: TestDescAndFn {
297
319
test:: TestDescAndFn {
298
320
desc : test:: TestDesc {
@@ -304,7 +326,7 @@ pub fn make_test(config: &Config, testfile: &Path, f: || -> test::TestFn)
304
326
}
305
327
}
306
328
307
- pub fn make_test_name ( config : & Config , testfile : & Path ) -> test:: TestName {
329
+ pub fn make_test_name ( config : & config , testfile : & Path ) -> test:: TestName {
308
330
309
331
// Try to elide redundant long paths
310
332
fn shorten ( path : & Path ) -> ~str {
@@ -314,17 +336,19 @@ pub fn make_test_name(config: &Config, testfile: &Path) -> test::TestName {
314
336
format ! ( "{}/{}" , dir. unwrap_or( "" ) , filename. unwrap_or( "" ) )
315
337
}
316
338
317
- test:: DynTestName ( format ! ( "[{}] {}" , config. mode, shorten( testfile) ) )
339
+ test:: DynTestName ( format ! ( "[{}] {}" ,
340
+ mode_str( config. mode) ,
341
+ shorten( testfile) ) )
318
342
}
319
343
320
- pub fn make_test_closure ( config : & Config , testfile : & Path ) -> test:: TestFn {
344
+ pub fn make_test_closure ( config : & config , testfile : & Path ) -> test:: TestFn {
321
345
let config = ( * config) . clone ( ) ;
322
346
// FIXME (#9639): This needs to handle non-utf8 paths
323
347
let testfile = testfile. as_str ( ) . unwrap ( ) . to_owned ( ) ;
324
348
test:: DynTestFn ( proc ( ) { runtest:: run ( config, testfile) } )
325
349
}
326
350
327
- 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 {
328
352
let config = ( * config) . clone ( ) ;
329
353
// FIXME (#9639): This needs to handle non-utf8 paths
330
354
let testfile = testfile. as_str ( ) . unwrap ( ) . to_owned ( ) ;
0 commit comments