@@ -48,12 +48,14 @@ fn start(argc: int, argv: **u8) -> int {
48
48
49
49
pub fn main ( ) {
50
50
let args = os:: args ( ) ;
51
- let config = parse_config ( args. move_iter ( ) . collect ( ) ) ;
51
+ let config = parse_config ( args. move_iter ( )
52
+ . map ( |x| x. to_strbuf ( ) )
53
+ . collect ( ) ) ;
52
54
log_config ( & config) ;
53
55
run_tests ( & config) ;
54
56
}
55
57
56
- pub fn parse_config ( args : Vec < ~ str > ) -> Config {
58
+ pub fn parse_config ( args : Vec < StrBuf > ) -> Config {
57
59
58
60
let groups : Vec < getopts:: OptGroup > =
59
61
vec ! ( reqopt( "" , "compile-lib-path" , "path to host shared libraries" , "PATH" ) ,
@@ -91,15 +93,19 @@ pub fn parse_config(args: Vec<~str> ) -> Config {
91
93
assert ! ( !args. is_empty( ) ) ;
92
94
let argv0 = ( * args. get ( 0 ) ) . clone ( ) ;
93
95
let args_ = args. tail ( ) ;
94
- if * args. get ( 1 ) == "-h" . to_owned ( ) || * args. get ( 1 ) == "--help" . to_owned ( ) {
96
+ if args. get ( 1 ) . as_slice ( ) == "-h" || args. get ( 1 ) . as_slice ( ) == "--help" {
95
97
let message = format ! ( "Usage: {} [OPTIONS] [TESTNAME...]" , argv0) ;
96
98
println ! ( "{}" , getopts:: usage( message, groups. as_slice( ) ) ) ;
97
99
println ! ( "" ) ;
98
100
fail ! ( )
99
101
}
100
102
101
103
let matches =
102
- & match getopts:: getopts ( args_, groups. as_slice ( ) ) {
104
+ & match getopts:: getopts ( args_. iter ( )
105
+ . map ( |x| x. to_owned ( ) )
106
+ . collect :: < Vec < _ > > ( )
107
+ . as_slice ( ) ,
108
+ groups. as_slice ( ) ) {
103
109
Ok ( m) => m,
104
110
Err ( f) => fail ! ( "{}" , f. to_err_msg( ) )
105
111
} ;
@@ -129,15 +135,17 @@ pub fn parse_config(args: Vec<~str> ) -> Config {
129
135
} ;
130
136
131
137
Config {
132
- compile_lib_path : matches. opt_str ( "compile-lib-path" ) . unwrap ( ) ,
133
- run_lib_path : matches. opt_str ( "run-lib-path" ) . unwrap ( ) ,
138
+ compile_lib_path : matches. opt_str ( "compile-lib-path" )
139
+ . unwrap ( )
140
+ . to_strbuf ( ) ,
141
+ run_lib_path : matches. opt_str ( "run-lib-path" ) . unwrap ( ) . to_strbuf ( ) ,
134
142
rustc_path : opt_path ( matches, "rustc-path" ) ,
135
143
clang_path : matches. opt_str ( "clang-path" ) . map ( |s| Path :: new ( s) ) ,
136
144
llvm_bin_path : matches. opt_str ( "llvm-bin-path" ) . map ( |s| Path :: new ( s) ) ,
137
145
src_base : opt_path ( matches, "src-base" ) ,
138
146
build_base : opt_path ( matches, "build-base" ) ,
139
147
aux_base : opt_path ( matches, "aux-base" ) ,
140
- stage_id : matches. opt_str ( "stage-id" ) . unwrap ( ) ,
148
+ stage_id : matches. opt_str ( "stage-id" ) . unwrap ( ) . to_strbuf ( ) ,
141
149
mode : FromStr :: from_str ( matches. opt_str ( "mode" ) . unwrap ( ) ) . expect ( "invalid mode" ) ,
142
150
run_ignored : matches. opt_present ( "ignored" ) ,
143
151
filter : filter,
@@ -147,21 +155,30 @@ pub fn parse_config(args: Vec<~str> ) -> Config {
147
155
matches. opt_str ( "ratchet-metrics" ) . map ( |s| Path :: new ( s) ) ,
148
156
ratchet_noise_percent :
149
157
matches. opt_str ( "ratchet-noise-percent" ) . and_then ( |s| from_str :: < f64 > ( s) ) ,
150
- runtool : matches. opt_str ( "runtool" ) ,
151
- host_rustcflags : matches. opt_str ( "host-rustcflags" ) ,
152
- target_rustcflags : matches. opt_str ( "target-rustcflags" ) ,
158
+ runtool : matches. opt_str ( "runtool" ) . map ( |x| x. to_strbuf ( ) ) ,
159
+ host_rustcflags : matches. opt_str ( "host-rustcflags" )
160
+ . map ( |x| x. to_strbuf ( ) ) ,
161
+ target_rustcflags : matches. opt_str ( "target-rustcflags" )
162
+ . map ( |x| x. to_strbuf ( ) ) ,
153
163
jit : matches. opt_present ( "jit" ) ,
154
- target : opt_str2 ( matches. opt_str ( "target" ) ) . to_str ( ) ,
155
- host : opt_str2 ( matches. opt_str ( "host" ) ) . to_str ( ) ,
164
+ target : opt_str2 ( matches. opt_str ( "target" ) . map ( |x| x . to_strbuf ( ) ) ) ,
165
+ host : opt_str2 ( matches. opt_str ( "host" ) . map ( |x| x . to_strbuf ( ) ) ) ,
156
166
android_cross_path : opt_path ( matches, "android-cross-path" ) ,
157
- adb_path : opt_str2 ( matches. opt_str ( "adb-path" ) ) . to_str ( ) ,
158
- adb_test_dir :
159
- opt_str2 ( matches. opt_str ( "adb-test-dir" ) ) . to_str ( ) ,
167
+ adb_path : opt_str2 ( matches. opt_str ( "adb-path" )
168
+ . map ( |x| x. to_strbuf ( ) ) ) ,
169
+ adb_test_dir : opt_str2 ( matches. opt_str ( "adb-test-dir" )
170
+ . map ( |x| x. to_strbuf ( ) ) ) ,
160
171
adb_device_status :
161
- "arm-linux-androideabi" == opt_str2 ( matches. opt_str ( "target" ) ) &&
162
- "(none)" != opt_str2 ( matches. opt_str ( "adb-test-dir" ) ) &&
163
- !opt_str2 ( matches. opt_str ( "adb-test-dir" ) ) . is_empty ( ) ,
164
- lldb_python_dir : matches. opt_str ( "lldb-python-dir" ) ,
172
+ "arm-linux-androideabi" ==
173
+ opt_str2 ( matches. opt_str ( "target" )
174
+ . map ( |x| x. to_strbuf ( ) ) ) . as_slice ( ) &&
175
+ "(none)" !=
176
+ opt_str2 ( matches. opt_str ( "adb-test-dir" )
177
+ . map ( |x| x. to_strbuf ( ) ) ) . as_slice ( ) &&
178
+ !opt_str2 ( matches. opt_str ( "adb-test-dir" )
179
+ . map ( |x| x. to_strbuf ( ) ) ) . is_empty ( ) ,
180
+ lldb_python_dir : matches. opt_str ( "lldb-python-dir" )
181
+ . map ( |x| x. to_strbuf ( ) ) ,
165
182
test_shard : test:: opt_shard ( matches. opt_str ( "test-shard" )
166
183
. map ( |x| x. to_strbuf ( ) ) ) ,
167
184
verbose : matches. opt_present ( "verbose" )
@@ -170,50 +187,59 @@ pub fn parse_config(args: Vec<~str> ) -> Config {
170
187
171
188
pub fn log_config ( config : & Config ) {
172
189
let c = config;
173
- logv ( c, format ! ( "configuration:" ) ) ;
174
- logv ( c, format ! ( "compile_lib_path: {}" , config. compile_lib_path) ) ;
175
- logv ( c, format ! ( "run_lib_path: {}" , config. run_lib_path) ) ;
176
- logv ( c, format ! ( "rustc_path: {}" , config. rustc_path. display( ) ) ) ;
177
- logv ( c, format ! ( "src_base: {}" , config. src_base. display( ) ) ) ;
178
- logv ( c, format ! ( "build_base: {}" , config. build_base. display( ) ) ) ;
179
- logv ( c, format ! ( "stage_id: {}" , config. stage_id) ) ;
180
- logv ( c, format ! ( "mode: {}" , config. mode) ) ;
181
- logv ( c, format ! ( "run_ignored: {}" , config. run_ignored) ) ;
182
- logv ( c, format ! ( "filter: {}" , opt_str( & config. filter. as_ref( ) . map( |re| re. to_str( ) ) ) ) ) ;
183
- logv ( c, format ! ( "runtool: {}" , opt_str( & config. runtool) ) ) ;
184
- logv ( c, format ! ( "host-rustcflags: {}" , opt_str( & config. host_rustcflags) ) ) ;
185
- logv ( c, format ! ( "target-rustcflags: {}" , opt_str( & config. target_rustcflags) ) ) ;
186
- logv ( c, format ! ( "jit: {}" , config. jit) ) ;
187
- logv ( c, format ! ( "target: {}" , config. target) ) ;
188
- logv ( c, format ! ( "host: {}" , config. host) ) ;
189
- logv ( c, format ! ( "android-cross-path: {}" , config. android_cross_path. display( ) ) ) ;
190
- logv ( c, format ! ( "adb_path: {}" , config. adb_path) ) ;
191
- logv ( c, format ! ( "adb_test_dir: {}" , config. adb_test_dir) ) ;
192
- logv ( c, format ! ( "adb_device_status: {}" , config. adb_device_status) ) ;
190
+ logv ( c, format_strbuf ! ( "configuration:" ) ) ;
191
+ logv ( c, format_strbuf ! ( "compile_lib_path: {}" , config. compile_lib_path) ) ;
192
+ logv ( c, format_strbuf ! ( "run_lib_path: {}" , config. run_lib_path) ) ;
193
+ logv ( c, format_strbuf ! ( "rustc_path: {}" , config. rustc_path. display( ) ) ) ;
194
+ logv ( c, format_strbuf ! ( "src_base: {}" , config. src_base. display( ) ) ) ;
195
+ logv ( c, format_strbuf ! ( "build_base: {}" , config. build_base. display( ) ) ) ;
196
+ logv ( c, format_strbuf ! ( "stage_id: {}" , config. stage_id) ) ;
197
+ logv ( c, format_strbuf ! ( "mode: {}" , config. mode) ) ;
198
+ logv ( c, format_strbuf ! ( "run_ignored: {}" , config. run_ignored) ) ;
199
+ logv ( c, format_strbuf ! ( "filter: {}" ,
200
+ opt_str( & config. filter
201
+ . as_ref( )
202
+ . map( |re| {
203
+ re. to_str( ) . into_strbuf( )
204
+ } ) ) ) ) ;
205
+ logv ( c, format_strbuf ! ( "runtool: {}" , opt_str( & config. runtool) ) ) ;
206
+ logv ( c, format_strbuf ! ( "host-rustcflags: {}" ,
207
+ opt_str( & config. host_rustcflags) ) ) ;
208
+ logv ( c, format_strbuf ! ( "target-rustcflags: {}" ,
209
+ opt_str( & config. target_rustcflags) ) ) ;
210
+ logv ( c, format_strbuf ! ( "jit: {}" , config. jit) ) ;
211
+ logv ( c, format_strbuf ! ( "target: {}" , config. target) ) ;
212
+ logv ( c, format_strbuf ! ( "host: {}" , config. host) ) ;
213
+ logv ( c, format_strbuf ! ( "android-cross-path: {}" ,
214
+ config. android_cross_path. display( ) ) ) ;
215
+ logv ( c, format_strbuf ! ( "adb_path: {}" , config. adb_path) ) ;
216
+ logv ( c, format_strbuf ! ( "adb_test_dir: {}" , config. adb_test_dir) ) ;
217
+ logv ( c, format_strbuf ! ( "adb_device_status: {}" ,
218
+ config. adb_device_status) ) ;
193
219
match config. test_shard {
194
- None => logv ( c, "test_shard: (all)" . to_owned ( ) ) ,
195
- Some ( ( a, b) ) => logv ( c, format ! ( "test_shard: {}.{}" , a, b) )
220
+ None => logv ( c, "test_shard: (all)" . to_strbuf ( ) ) ,
221
+ Some ( ( a, b) ) => logv ( c, format_strbuf ! ( "test_shard: {}.{}" , a, b) )
196
222
}
197
- logv ( c, format ! ( "verbose: {}" , config. verbose) ) ;
198
- logv ( c, format ! ( "\n " ) ) ;
223
+ logv ( c, format_strbuf ! ( "verbose: {}" , config. verbose) ) ;
224
+ logv ( c, format_strbuf ! ( "\n " ) ) ;
199
225
}
200
226
201
- pub fn opt_str < ' a > ( maybestr : & ' a Option < ~ str > ) -> & ' a str {
227
+ pub fn opt_str < ' a > ( maybestr : & ' a Option < StrBuf > ) -> & ' a str {
202
228
match * maybestr {
203
229
None => "(none)" ,
204
- Some ( ref s) => {
205
- let s: & ' a str = * s;
206
- s
207
- }
230
+ Some ( ref s) => s. as_slice ( ) ,
208
231
}
209
232
}
210
233
211
- pub fn opt_str2 ( maybestr : Option < ~str > ) -> ~str {
212
- match maybestr { None => "(none)" . to_owned ( ) , Some ( s) => { s } }
234
+ pub fn opt_str2 ( maybestr : Option < StrBuf > ) -> StrBuf {
235
+ match maybestr {
236
+ None => "(none)" . to_strbuf ( ) ,
237
+ Some ( s) => s,
238
+ }
213
239
}
214
240
215
241
pub fn run_tests ( config : & Config ) {
216
- if config. target == "arm-linux-androideabi" . to_owned ( ) {
242
+ if config. target . as_slice ( ) == "arm-linux-androideabi" {
217
243
match config. mode {
218
244
DebugInfoGdb => {
219
245
println ! ( "arm-linux-androideabi debug-info \
@@ -321,11 +347,11 @@ pub fn make_test(config: &Config, testfile: &Path, f: || -> test::TestFn)
321
347
pub fn make_test_name ( config : & Config , testfile : & Path ) -> test:: TestName {
322
348
323
349
// Try to elide redundant long paths
324
- fn shorten ( path : & Path ) -> ~ str {
350
+ fn shorten ( path : & Path ) -> StrBuf {
325
351
let filename = path. filename_str ( ) ;
326
352
let p = path. dir_path ( ) ;
327
353
let dir = p. filename_str ( ) ;
328
- format ! ( "{}/{}" , dir. unwrap_or( "" ) , filename. unwrap_or( "" ) )
354
+ format_strbuf ! ( "{}/{}" , dir. unwrap_or( "" ) , filename. unwrap_or( "" ) )
329
355
}
330
356
331
357
test:: DynTestName ( format_strbuf ! ( "[{}] {}" ,
@@ -336,14 +362,16 @@ pub fn make_test_name(config: &Config, testfile: &Path) -> test::TestName {
336
362
pub fn make_test_closure ( config : & Config , testfile : & Path ) -> test:: TestFn {
337
363
let config = ( * config) . clone ( ) ;
338
364
// FIXME (#9639): This needs to handle non-utf8 paths
339
- let testfile = testfile. as_str ( ) . unwrap ( ) . to_owned ( ) ;
340
- test:: DynTestFn ( proc ( ) { runtest:: run ( config, testfile) } )
365
+ let testfile = testfile. as_str ( ) . unwrap ( ) . to_strbuf ( ) ;
366
+ test:: DynTestFn ( proc ( ) {
367
+ runtest:: run ( config, testfile)
368
+ } )
341
369
}
342
370
343
371
pub fn make_metrics_test_closure ( config : & Config , testfile : & Path ) -> test:: TestFn {
344
372
let config = ( * config) . clone ( ) ;
345
373
// FIXME (#9639): This needs to handle non-utf8 paths
346
- let testfile = testfile. as_str ( ) . unwrap ( ) . to_owned ( ) ;
374
+ let testfile = testfile. as_str ( ) . unwrap ( ) . to_strbuf ( ) ;
347
375
test:: DynMetricFn ( proc ( mm) {
348
376
runtest:: run_metrics ( config, testfile, mm)
349
377
} )
0 commit comments