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