10
10
11
11
#[crate_type = "bin"];
12
12
13
- #[allow(vecs_implicitly_copyable)];
14
13
#[allow(non_camel_case_types)];
15
- #[allow(deprecated_pattern)];
16
14
17
15
extern mod std(vers = "0.7-pre");
18
16
@@ -43,8 +41,8 @@ pub mod errors;
43
41
pub fn main() {
44
42
let args = os::args();
45
43
let config = parse_config(args);
46
- log_config(config);
47
- run_tests(config);
44
+ log_config(& config);
45
+ run_tests(& config);
48
46
}
49
47
50
48
pub fn parse_config(args: ~[~str]) -> config {
@@ -89,30 +87,31 @@ pub fn parse_config(args: ~[~str]) -> config {
89
87
run_ignored: getopts::opt_present(matches, ~"ignored"),
90
88
filter:
91
89
if vec::len(matches.free) > 0u {
92
- option::Some(matches.free[0])
90
+ option::Some(copy matches.free[0])
93
91
} else { option::None },
94
92
logfile: getopts::opt_maybe_str(matches, ~"logfile").map(|s| Path(*s)),
95
93
runtool: getopts::opt_maybe_str(matches, ~"runtool"),
96
94
rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"),
97
95
jit: getopts::opt_present(matches, ~"jit"),
98
96
newrt: getopts::opt_present(matches, ~"newrt"),
99
- target: opt_str(getopts::opt_maybe_str(matches, ~"target")),
100
- adb_path: opt_str(getopts::opt_maybe_str(matches, ~"adb-path")),
101
- adb_test_dir: opt_str(getopts::opt_maybe_str(matches, ~"adb-test-dir")),
97
+ target: opt_str2(getopts::opt_maybe_str(matches, ~"target")).to_str(),
98
+ adb_path: opt_str2(getopts::opt_maybe_str(matches, ~"adb-path")).to_str(),
99
+ adb_test_dir:
100
+ opt_str2(getopts::opt_maybe_str(matches, ~"adb-test-dir")).to_str(),
102
101
adb_device_status:
103
- if (opt_str (getopts::opt_maybe_str(matches, ~"target")) ==
102
+ if (opt_str2 (getopts::opt_maybe_str(matches, ~"target")) ==
104
103
~"arm-linux-androideabi") {
105
- if (opt_str (getopts::opt_maybe_str(matches, ~"adb-test-dir")) !=
104
+ if (opt_str2 (getopts::opt_maybe_str(matches, ~"adb-test-dir")) !=
106
105
~"(none)" &&
107
- opt_str (getopts::opt_maybe_str(matches, ~"adb-test-dir")) !=
106
+ opt_str2 (getopts::opt_maybe_str(matches, ~"adb-test-dir")) !=
108
107
~"") { true }
109
108
else { false }
110
109
} else { false },
111
110
verbose: getopts::opt_present(matches, ~"verbose")
112
111
}
113
112
}
114
113
115
- pub fn log_config(config: config) {
114
+ pub fn log_config(config: & config) {
116
115
let c = config;
117
116
logv(c, fmt!("configuration:"));
118
117
logv(c, fmt!("compile_lib_path: %s", config.compile_lib_path));
@@ -123,9 +122,9 @@ pub fn log_config(config: config) {
123
122
logv(c, fmt!("stage_id: %s", config.stage_id));
124
123
logv(c, fmt!("mode: %s", mode_str(config.mode)));
125
124
logv(c, fmt!("run_ignored: %b", config.run_ignored));
126
- logv(c, fmt!("filter: %s", opt_str(config.filter)));
127
- logv(c, fmt!("runtool: %s", opt_str(config.runtool)));
128
- logv(c, fmt!("rustcflags: %s", opt_str(config.rustcflags)));
125
+ logv(c, fmt!("filter: %s", opt_str(& config.filter)));
126
+ logv(c, fmt!("runtool: %s", opt_str(& config.runtool)));
127
+ logv(c, fmt!("rustcflags: %s", opt_str(& config.rustcflags)));
129
128
logv(c, fmt!("jit: %b", config.jit));
130
129
logv(c, fmt!("newrt: %b", config.newrt));
131
130
logv(c, fmt!("target: %s", config.target));
@@ -136,8 +135,18 @@ pub fn log_config(config: config) {
136
135
logv(c, fmt!("\n"));
137
136
}
138
137
139
- pub fn opt_str(maybestr: Option<~str>) -> ~str {
140
- match maybestr { option::Some(s) => s, option::None => ~"(none)" }
138
+ pub fn opt_str<'a>(maybestr: &'a Option<~str>) -> &'a str {
139
+ match *maybestr {
140
+ option::None => "(none)",
141
+ option::Some(ref s) => {
142
+ let s: &'a str = *s;
143
+ s
144
+ }
145
+ }
146
+ }
147
+
148
+ pub fn opt_str2(maybestr: Option<~str>) -> ~str {
149
+ match maybestr { None => ~"(none)", Some(s) => { s } }
141
150
}
142
151
143
152
pub fn str_opt(maybestr: ~str) -> Option<~str> {
@@ -165,16 +174,16 @@ pub fn mode_str(mode: mode) -> ~str {
165
174
}
166
175
}
167
176
168
- pub fn run_tests(config: config) {
177
+ pub fn run_tests(config: & config) {
169
178
let opts = test_opts(config);
170
179
let tests = make_tests(config);
171
180
let res = test::run_tests_console(&opts, tests);
172
181
if !res { fail!("Some tests failed"); }
173
182
}
174
183
175
- pub fn test_opts(config: config) -> test::TestOpts {
184
+ pub fn test_opts(config: & config) -> test::TestOpts {
176
185
test::TestOpts {
177
- filter: config.filter,
186
+ filter: copy config.filter,
178
187
run_ignored: config.run_ignored,
179
188
logfile: copy config.logfile,
180
189
run_tests: true,
@@ -184,7 +193,7 @@ pub fn test_opts(config: config) -> test::TestOpts {
184
193
}
185
194
}
186
195
187
- pub fn make_tests(config: config) -> ~[test::TestDescAndFn] {
196
+ pub fn make_tests(config: & config) -> ~[test::TestDescAndFn] {
188
197
debug!("making tests from %s",
189
198
config.src_base.to_str());
190
199
let mut tests = ~[];
@@ -198,7 +207,7 @@ pub fn make_tests(config: config) -> ~[test::TestDescAndFn] {
198
207
tests
199
208
}
200
209
201
- pub fn is_test(config: config, testfile: &Path) -> bool {
210
+ pub fn is_test(config: & config, testfile: &Path) -> bool {
202
211
// Pretty-printer does not work with .rc files yet
203
212
let valid_extensions =
204
213
match config.mode {
@@ -221,7 +230,7 @@ pub fn is_test(config: config, testfile: &Path) -> bool {
221
230
return valid;
222
231
}
223
232
224
- pub fn make_test(config: config, testfile: &Path) -> test::TestDescAndFn {
233
+ pub fn make_test(config: & config, testfile: &Path) -> test::TestDescAndFn {
225
234
test::TestDescAndFn {
226
235
desc: test::TestDesc {
227
236
name: make_test_name(config, testfile),
@@ -232,13 +241,15 @@ pub fn make_test(config: config, testfile: &Path) -> test::TestDescAndFn {
232
241
}
233
242
}
234
243
235
- pub fn make_test_name(config: config, testfile: &Path) -> test::TestName {
244
+ pub fn make_test_name(config: & config, testfile: &Path) -> test::TestName {
236
245
test::DynTestName(fmt!("[%s] %s",
237
246
mode_str(config.mode),
238
247
testfile.to_str()))
239
248
}
240
249
241
- pub fn make_test_closure(config: config, testfile: &Path) -> test::TestFn {
242
- let testfile = testfile.to_str();
243
- test::DynTestFn(|| runtest::run(config, testfile))
250
+ pub fn make_test_closure(config: &config, testfile: &Path) -> test::TestFn {
251
+ use core::cell::Cell;
252
+ let config = Cell(copy *config);
253
+ let testfile = Cell(testfile.to_str());
254
+ test::DynTestFn(|| { runtest::run(config.take(), testfile.take()) })
244
255
}
0 commit comments