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 ( ) ,
@@ -152,13 +150,12 @@ pub fn parse_config(args: Vec<~str> ) -> Config {
152
150
"(none)" != opt_str2 ( matches. opt_str ( "adb-test-dir" ) ) &&
153
151
!opt_str2 ( matches. opt_str ( "adb-test-dir" ) ) . is_empty ( ) ,
154
152
lldb_python_dir : matches. opt_str ( "lldb-python-dir" ) ,
155
- test_shard : test:: opt_shard ( matches. opt_str ( "test-shard" )
156
- . map ( |x| x. to_strbuf ( ) ) ) ,
153
+ test_shard : test:: opt_shard ( matches. opt_str ( "test-shard" ) ) ,
157
154
verbose : matches. opt_present ( "verbose" )
158
155
}
159
156
}
160
157
161
- pub fn log_config ( config : & Config ) {
158
+ pub fn log_config ( config : & config ) {
162
159
let c = config;
163
160
logv ( c, format ! ( "configuration:" ) ) ;
164
161
logv ( c, format ! ( "compile_lib_path: {}" , config. compile_lib_path) ) ;
@@ -167,7 +164,7 @@ pub fn log_config(config: &Config) {
167
164
logv ( c, format ! ( "src_base: {}" , config. src_base. display( ) ) ) ;
168
165
logv ( c, format ! ( "build_base: {}" , config. build_base. display( ) ) ) ;
169
166
logv ( c, format ! ( "stage_id: {}" , config. stage_id) ) ;
170
- logv ( c, format ! ( "mode: {}" , config. mode) ) ;
167
+ logv ( c, format ! ( "mode: {}" , mode_str ( config. mode) ) ) ;
171
168
logv ( c, format ! ( "run_ignored: {}" , config. run_ignored) ) ;
172
169
logv ( c, format ! ( "filter: {}" , opt_str( & config. filter) ) ) ;
173
170
logv ( c, format ! ( "runtool: {}" , opt_str( & config. runtool) ) ) ;
@@ -176,7 +173,6 @@ pub fn log_config(config: &Config) {
176
173
logv ( c, format ! ( "jit: {}" , config. jit) ) ;
177
174
logv ( c, format ! ( "target: {}" , config. target) ) ;
178
175
logv ( c, format ! ( "host: {}" , config. host) ) ;
179
- logv ( c, format ! ( "android-cross-path: {}" , config. android_cross_path. display( ) ) ) ;
180
176
logv ( c, format ! ( "adb_path: {}" , config. adb_path) ) ;
181
177
logv ( c, format ! ( "adb_test_dir: {}" , config. adb_test_dir) ) ;
182
178
logv ( c, format ! ( "adb_device_status: {}" , config. adb_device_status) ) ;
@@ -202,10 +198,35 @@ pub fn opt_str2(maybestr: Option<~str>) -> ~str {
202
198
match maybestr { None => "(none)" . to_owned ( ) , Some ( s) => { s } }
203
199
}
204
200
205
- 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 ) {
206
227
if config. target == "arm-linux-androideabi" . to_owned ( ) {
207
- match config. mode {
208
- DebugInfoGdb => {
228
+ match config. mode {
229
+ mode_debug_info_gdb => {
209
230
println ! ( "arm-linux-androideabi debug-info \
210
231
test uses tcp 5039 port. please reserve it") ;
211
232
}
@@ -234,12 +255,9 @@ pub fn run_tests(config: &Config) {
234
255
}
235
256
}
236
257
237
- pub fn test_opts ( config : & Config ) -> test:: TestOpts {
258
+ pub fn test_opts ( config : & config ) -> test:: TestOpts {
238
259
test:: TestOpts {
239
- filter : match config. filter {
240
- None => None ,
241
- Some ( ref filter) => Some ( filter. to_strbuf ( ) ) ,
242
- } ,
260
+ filter : config. filter . clone ( ) ,
243
261
run_ignored : config. run_ignored ,
244
262
logfile : config. logfile . clone ( ) ,
245
263
run_tests : true ,
@@ -252,7 +270,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
252
270
}
253
271
}
254
272
255
- pub fn make_tests ( config : & Config ) -> Vec < test:: TestDescAndFn > {
273
+ pub fn make_tests ( config : & config ) -> Vec < test:: TestDescAndFn > {
256
274
debug ! ( "making tests from {}" ,
257
275
config. src_base. display( ) ) ;
258
276
let mut tests = Vec :: new ( ) ;
@@ -263,7 +281,7 @@ pub fn make_tests(config: &Config) -> Vec<test::TestDescAndFn> {
263
281
if is_test ( config, & file) {
264
282
let t = make_test ( config, & file, || {
265
283
match config. mode {
266
- Codegen => make_metrics_test_closure ( config, & file) ,
284
+ mode_codegen => make_metrics_test_closure ( config, & file) ,
267
285
_ => make_test_closure ( config, & file)
268
286
}
269
287
} ) ;
@@ -273,11 +291,11 @@ pub fn make_tests(config: &Config) -> Vec<test::TestDescAndFn> {
273
291
tests
274
292
}
275
293
276
- pub fn is_test ( config : & Config , testfile : & Path ) -> bool {
294
+ pub fn is_test ( config : & config , testfile : & Path ) -> bool {
277
295
// Pretty-printer does not work with .rc files yet
278
296
let valid_extensions =
279
297
match config. mode {
280
- Pretty => vec ! ( ".rs" . to_owned( ) ) ,
298
+ mode_pretty => vec ! ( ".rs" . to_owned( ) ) ,
281
299
_ => vec ! ( ".rc" . to_owned( ) , ".rs" . to_owned( ) )
282
300
} ;
283
301
let invalid_prefixes = vec ! ( "." . to_owned( ) , "#" . to_owned( ) , "~" . to_owned( ) ) ;
@@ -296,7 +314,7 @@ pub fn is_test(config: &Config, testfile: &Path) -> bool {
296
314
return valid;
297
315
}
298
316
299
- pub fn make_test ( config : & Config , testfile : & Path , f: || -> test:: TestFn )
317
+ pub fn make_test ( config : & config , testfile : & Path , f: || -> test:: TestFn )
300
318
-> test:: TestDescAndFn {
301
319
test:: TestDescAndFn {
302
320
desc : test:: TestDesc {
@@ -308,7 +326,7 @@ pub fn make_test(config: &Config, testfile: &Path, f: || -> test::TestFn)
308
326
}
309
327
}
310
328
311
- pub fn make_test_name ( config : & Config , testfile : & Path ) -> test:: TestName {
329
+ pub fn make_test_name ( config : & config , testfile : & Path ) -> test:: TestName {
312
330
313
331
// Try to elide redundant long paths
314
332
fn shorten ( path : & Path ) -> ~str {
@@ -318,19 +336,19 @@ pub fn make_test_name(config: &Config, testfile: &Path) -> test::TestName {
318
336
format ! ( "{}/{}" , dir. unwrap_or( "" ) , filename. unwrap_or( "" ) )
319
337
}
320
338
321
- test:: DynTestName ( format_strbuf ! ( "[{}] {}" ,
322
- config. mode,
323
- shorten( testfile) ) )
339
+ test:: DynTestName ( format ! ( "[{}] {}" ,
340
+ mode_str ( config. mode) ,
341
+ shorten( testfile) ) )
324
342
}
325
343
326
- pub fn make_test_closure ( config : & Config , testfile : & Path ) -> test:: TestFn {
344
+ pub fn make_test_closure ( config : & config , testfile : & Path ) -> test:: TestFn {
327
345
let config = ( * config) . clone ( ) ;
328
346
// FIXME (#9639): This needs to handle non-utf8 paths
329
347
let testfile = testfile. as_str ( ) . unwrap ( ) . to_owned ( ) ;
330
348
test:: DynTestFn ( proc ( ) { runtest:: run ( config, testfile) } )
331
349
}
332
350
333
- 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 {
334
352
let config = ( * config) . clone ( ) ;
335
353
// FIXME (#9639): This needs to handle non-utf8 paths
336
354
let testfile = testfile. as_str ( ) . unwrap ( ) . to_owned ( ) ;
0 commit comments