@@ -23,14 +23,13 @@ import common::mode;
23
23
import util:: logv;
24
24
25
25
fn main ( args : [ str ] ) {
26
-
26
+ let args = istr :: from_estrs ( args ) ;
27
27
let config = parse_config ( args) ;
28
28
log_config ( config) ;
29
29
run_tests ( config) ;
30
30
}
31
31
32
- fn parse_config( args : & [ str ] ) -> config {
33
- let args = istr:: from_estrs ( args) ;
32
+ fn parse_config( args : & [ istr ] ) -> config {
34
33
let opts =
35
34
[ getopts:: reqopt ( ~"compile-lib-path") ,
36
35
getopts:: reqopt ( ~"run-lib-path") ,
@@ -60,7 +59,7 @@ fn parse_config(args: &[str]) -> config {
60
59
src_base: getopts:: opt_str( match , ~"src-base") ,
61
60
build_base: getopts:: opt_str( match , ~"build-base") ,
62
61
stage_id: getopts:: opt_str( match , ~"stage-id") ,
63
- mode: str_mode( istr :: to_estr ( getopts:: opt_str( match , ~"mode") ) ) ,
62
+ mode: str_mode( getopts:: opt_str( match , ~"mode") ) ,
64
63
run_ignored: getopts:: opt_present( match , ~"ignored") ,
65
64
filter:
66
65
if vec:: len( match . free) > 0 u {
@@ -73,36 +72,49 @@ fn parse_config(args: &[str]) -> config {
73
72
74
73
fn log_config ( config: & config) {
75
74
let c = config;
76
- logv( c, #fmt[ "configuration:" ] ) ;
77
- logv( c, #fmt[ "compile_lib_path: %s" ,
78
- istr:: to_estr( config. compile_lib_path) ] ) ;
79
- logv( c, #fmt[ "run_lib_path: %s" , istr:: to_estr( config. run_lib_path) ] ) ;
80
- logv( c, #fmt[ "rustc_path: %s" , istr:: to_estr( config. rustc_path) ] ) ;
81
- logv( c, #fmt[ "src_base: %s" , istr:: to_estr( config. src_base) ] ) ;
82
- logv( c, #fmt[ "build_base: %s" , istr:: to_estr( config. build_base) ] ) ;
83
- logv( c, #fmt[ "stage_id: %s" , istr:: to_estr( config. stage_id) ] ) ;
84
- logv( c, #fmt[ "mode: %s" , mode_str( config. mode) ] ) ;
85
- logv( c, #fmt[ "run_ignored: %b" , config. run_ignored] ) ;
86
- logv( c, #fmt[ "filter: %s" , opt_str( config. filter) ] ) ;
87
- logv( c, #fmt[ "runtool: %s" , opt_str( config. runtool) ] ) ;
88
- logv( c, #fmt[ "rustcflags: %s" , opt_str( config. rustcflags) ] ) ;
89
- logv( c, #fmt[ "verbose: %b" , config. verbose] ) ;
90
- logv( c, #fmt[ "\n " ] ) ;
75
+ logv( c, istr:: from_estr(
76
+ #fmt[ "configuration:" ] ) ) ;
77
+ logv( c, istr:: from_estr(
78
+ #fmt[ "compile_lib_path: %s" ,
79
+ istr:: to_estr( config. compile_lib_path) ] ) ) ;
80
+ logv( c, istr:: from_estr(
81
+ #fmt[ "run_lib_path: %s" , istr:: to_estr( config. run_lib_path) ] ) ) ;
82
+ logv( c, istr:: from_estr(
83
+ #fmt[ "rustc_path: %s" , istr:: to_estr( config. rustc_path) ] ) ) ;
84
+ logv( c, istr:: from_estr(
85
+ #fmt[ "src_base: %s" , istr:: to_estr( config. src_base) ] ) ) ;
86
+ logv( c, istr:: from_estr(
87
+ #fmt[ "build_base: %s" , istr:: to_estr( config. build_base) ] ) ) ;
88
+ logv( c, istr:: from_estr(
89
+ #fmt[ "stage_id: %s" , istr:: to_estr( config. stage_id) ] ) ) ;
90
+ logv( c, istr:: from_estr(
91
+ #fmt[ "mode: %s" , istr:: to_estr( mode_str( config. mode) ) ] ) ) ;
92
+ logv( c, istr:: from_estr(
93
+ #fmt[ "run_ignored: %b" , config. run_ignored] ) ) ;
94
+ logv( c, istr:: from_estr(
95
+ #fmt[ "filter: %s" , istr:: to_estr( opt_str( config. filter) ) ] ) ) ;
96
+ logv( c, istr:: from_estr(
97
+ #fmt[ "runtool: %s" , istr:: to_estr( opt_str( config. runtool) ) ] ) ) ;
98
+ logv( c, istr:: from_estr(
99
+ #fmt[ "rustcflags: %s" , istr:: to_estr( opt_str( config. rustcflags) ) ] ) ) ;
100
+ logv( c, istr:: from_estr(
101
+ #fmt[ "verbose: %b" , config. verbose] ) ) ;
102
+ logv( c, istr:: from_estr( #fmt[ "\n " ] ) ) ;
91
103
}
92
104
93
- fn opt_str( maybestr: option:: t < istr > ) -> str {
105
+ fn opt_str( maybestr: option:: t < istr > ) -> istr {
94
106
alt maybestr {
95
- option : : some( s) { istr :: to_estr ( s ) }
96
- option:: none . { "(none)" }
107
+ option : : some( s) { s }
108
+ option:: none . { ~ "( none) " }
97
109
}
98
110
}
99
111
100
112
fn str_opt( maybestr: & istr) -> option:: t < istr > {
101
113
if maybestr != ~"( none) " { option:: some( maybestr) } else { option:: none }
102
114
}
103
115
104
- fn str_mode ( s : str ) -> mode {
105
- alt s {
116
+ fn str_mode( s: & istr ) -> mode {
117
+ alt istr :: to_estr ( s ) {
106
118
"compile-fail" { mode_compile_fail }
107
119
"run-fail" { mode_run_fail }
108
120
"run-pass" { mode_run_pass }
@@ -111,12 +123,12 @@ fn str_mode(s: str) -> mode {
111
123
}
112
124
}
113
125
114
- fn mode_str( mode: mode) -> str {
126
+ fn mode_str( mode: mode) -> istr {
115
127
alt mode {
116
- mode_compile_fail. { "compile-fail" }
117
- mode_run_fail. { "run-fail" }
118
- mode_run_pass. { "run-pass" }
119
- mode_pretty. { "pretty" }
128
+ mode_compile_fail. { ~ "compile-fail" }
129
+ mode_run_fail. { ~ " run-fail" }
130
+ mode_run_pass. { ~ " run-pass" }
131
+ mode_pretty. { ~ " pretty" }
120
132
}
121
133
}
122
134
@@ -146,23 +158,22 @@ fn make_tests(cx: &cx) -> tests_and_conv_fn {
146
158
let configport = port::<[u8]>();
147
159
let tests = [];
148
160
for file: istr in fs::list_dir(cx.config.src_base) {
149
- let file = istr:: to_estr( file) ;
150
- log #fmt[ "inspecting file %s" , file] ;
161
+ log #fmt[" inspecting file %s", istr::to_estr(file)];
151
162
if is_test(cx.config, file) {
152
163
tests += [make_test(cx, file, configport)];
153
164
}
154
165
}
155
166
ret {tests: tests, to_task: bind closure_to_task(cx, configport, _)};
156
167
}
157
168
158
- fn is_test( config: & config, testfile: & str ) -> bool {
169
+ fn is_test(config: &config, testfile: &istr ) -> bool {
159
170
// Pretty-printer does not work with .rc files yet
160
171
let valid_extensions = alt config.mode {
161
172
mode_pretty. { [~" . rs"] }
162
173
_ { [~" . rc", ~" . rs"] }
163
174
};
164
175
let invalid_prefixes = [~" . ", ~" #", ~" ~"] ;
165
- let name = fs:: basename( istr :: from_estr ( testfile) ) ;
176
+ let name = fs:: basename( testfile) ;
166
177
167
178
let valid = false ;
168
179
@@ -177,15 +188,17 @@ fn is_test(config: &config, testfile: &str) -> bool {
177
188
ret valid;
178
189
}
179
190
180
- fn make_test( cx: & cx, testfile: & str , configport: & port < [ u8 ] > ) ->
191
+ fn make_test( cx: & cx, testfile: & istr , configport: & port<[ u8 ] >) ->
181
192
test:: test_desc {
182
193
{ name: make_test_name( cx. config, testfile) ,
183
194
fn : make_test_closure( testfile, chan( configport) ) ,
184
195
ignore: header:: is_test_ignored( cx. config, testfile) }
185
196
}
186
197
187
- fn make_test_name( config: & config, testfile: & str) -> str {
188
- #fmt[ "[%s] %s" , mode_str( config. mode) , testfile]
198
+ fn make_test_name( config: & config, testfile: & istr) -> str {
199
+ #fmt[ "[%s] %s" ,
200
+ istr:: to_estr( mode_str( config. mode) ) ,
201
+ istr:: to_estr( testfile) ]
189
202
}
190
203
191
204
/*
@@ -207,13 +220,13 @@ up. Then we'll spawn that data into another task and return the task.
207
220
Really convoluted. Need to think up of a better definition for tests.
208
221
*/
209
222
210
- fn make_test_closure( testfile: & str , configchan: chan < [ u8 ] > ) ->
223
+ fn make_test_closure( testfile: & istr , configchan: chan<[ u8 ] >) ->
211
224
test:: test_fn {
212
225
bind send_config( testfile, configchan)
213
226
}
214
227
215
- fn send_config( testfile: str , configchan: chan < [ u8 ] > ) {
216
- send( configchan, str :: bytes( testfile) ) ;
228
+ fn send_config( testfile: istr , configchan: chan<[ u8 ] >) {
229
+ send( configchan, istr :: bytes( testfile) ) ;
217
230
}
218
231
219
232
/*
@@ -237,11 +250,11 @@ fn closure_to_task(cx: cx, configport: port<[u8]>, testfn: &fn()) ->
237
250
let src_base = cx. config. src_base;
238
251
let build_base = cx. config. build_base;
239
252
let stage_id = cx. config. stage_id;
240
- let mode = istr :: from_estr ( mode_str( cx. config. mode) ) ;
253
+ let mode = mode_str( cx. config. mode) ;
241
254
let run_ignored = cx. config. run_ignored;
242
- let filter = istr :: from_estr ( opt_str( cx. config. filter) ) ;
243
- let runtool = istr :: from_estr ( opt_str( cx. config. runtool) ) ;
244
- let rustcflags = istr :: from_estr ( opt_str( cx. config. rustcflags) ) ;
255
+ let filter = opt_str( cx. config. filter) ;
256
+ let runtool = opt_str( cx. config. runtool) ;
257
+ let rustcflags = opt_str( cx. config. rustcflags) ;
245
258
let verbose = cx. config. verbose;
246
259
let chan = cx. procsrv. chan;
247
260
@@ -277,7 +290,7 @@ fn run_test_task(compile_lib_path: -istr, run_lib_path: -istr,
277
290
src_base: src_base,
278
291
build_base: build_base,
279
292
stage_id: stage_id,
280
- mode: str_mode( istr :: to_estr ( mode) ) ,
293
+ mode: str_mode( mode) ,
281
294
run_ignored: run_ignored,
282
295
filter: str_opt( opt_filter) ,
283
296
runtool: str_opt( opt_runtool) ,
0 commit comments