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