Skip to content

Commit 40c3f81

Browse files
committed
---
yaml --- r: 5059 b: refs/heads/master c: 4007006 h: refs/heads/master i: 5057: 4e1428c 5055: 749fb47 v: v3
1 parent 3d2c92b commit 40c3f81

File tree

6 files changed

+249
-214
lines changed

6 files changed

+249
-214
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: eb70267e5e731a5b489aabf0e2214a9c4a264e26
2+
refs/heads/master: 4007006574561280139659a42000321020d589ff

trunk/src/test/compiletest/compiletest.rs

Lines changed: 57 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@ import common::mode;
2323
import util::logv;
2424

2525
fn main(args: [str]) {
26-
26+
let args = istr::from_estrs(args);
2727
let config = parse_config(args);
2828
log_config(config);
2929
run_tests(config);
3030
}
3131

32-
fn parse_config(args: &[str]) -> config {
33-
let args = istr::from_estrs(args);
32+
fn parse_config(args: &[istr]) -> config {
3433
let opts =
3534
[getopts::reqopt(~"compile-lib-path"),
3635
getopts::reqopt(~"run-lib-path"),
@@ -60,7 +59,7 @@ fn parse_config(args: &[str]) -> config {
6059
src_base: getopts::opt_str(match, ~"src-base"),
6160
build_base: getopts::opt_str(match, ~"build-base"),
6261
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")),
6463
run_ignored: getopts::opt_present(match, ~"ignored"),
6564
filter:
6665
if vec::len(match.free) > 0u {
@@ -73,36 +72,49 @@ fn parse_config(args: &[str]) -> config {
7372

7473
fn log_config(config: &config) {
7574
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"]));
91103
}
92104

93-
fn opt_str(maybestr: option::t<istr>) -> str {
105+
fn opt_str(maybestr: option::t<istr>) -> istr {
94106
alt maybestr {
95-
option::some(s) { istr::to_estr(s) }
96-
option::none. { "(none)" }
107+
option::some(s) { s }
108+
option::none. { ~"(none)" }
97109
}
98110
}
99111

100112
fn str_opt(maybestr: &istr) -> option::t<istr> {
101113
if maybestr != ~"(none)" { option::some(maybestr) } else { option::none }
102114
}
103115

104-
fn str_mode(s: str) -> mode {
105-
alt s {
116+
fn str_mode(s: &istr) -> mode {
117+
alt istr::to_estr(s) {
106118
"compile-fail" { mode_compile_fail }
107119
"run-fail" { mode_run_fail }
108120
"run-pass" { mode_run_pass }
@@ -111,12 +123,12 @@ fn str_mode(s: str) -> mode {
111123
}
112124
}
113125

114-
fn mode_str(mode: mode) -> str {
126+
fn mode_str(mode: mode) -> istr {
115127
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" }
120132
}
121133
}
122134
@@ -146,23 +158,22 @@ fn make_tests(cx: &cx) -> tests_and_conv_fn {
146158
let configport = port::<[u8]>();
147159
let tests = [];
148160
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)];
151162
if is_test(cx.config, file) {
152163
tests += [make_test(cx, file, configport)];
153164
}
154165
}
155166
ret {tests: tests, to_task: bind closure_to_task(cx, configport, _)};
156167
}
157168
158-
fn is_test(config: &config, testfile: &str) -> bool {
169+
fn is_test(config: &config, testfile: &istr) -> bool {
159170
// Pretty-printer does not work with .rc files yet
160171
let valid_extensions = alt config.mode {
161172
mode_pretty. { [~".rs"] }
162173
_ { [~".rc", ~".rs"] }
163174
};
164175
let invalid_prefixes = [~".", ~"#", ~"~"];
165-
let name = fs::basename(istr::from_estr(testfile));
176+
let name = fs::basename(testfile);
166177

167178
let valid = false;
168179

@@ -177,15 +188,17 @@ fn is_test(config: &config, testfile: &str) -> bool {
177188
ret valid;
178189
}
179190

180-
fn make_test(cx: &cx, testfile: &str, configport: &port<[u8]>) ->
191+
fn make_test(cx: &cx, testfile: &istr, configport: &port<[u8]>) ->
181192
test::test_desc {
182193
{name: make_test_name(cx.config, testfile),
183194
fn: make_test_closure(testfile, chan(configport)),
184195
ignore: header::is_test_ignored(cx.config, testfile)}
185196
}
186197

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)]
189202
}
190203

191204
/*
@@ -207,13 +220,13 @@ up. Then we'll spawn that data into another task and return the task.
207220
Really convoluted. Need to think up of a better definition for tests.
208221
*/
209222

210-
fn make_test_closure(testfile: &str, configchan: chan<[u8]>) ->
223+
fn make_test_closure(testfile: &istr, configchan: chan<[u8]>) ->
211224
test::test_fn {
212225
bind send_config(testfile, configchan)
213226
}
214227

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));
217230
}
218231

219232
/*
@@ -237,11 +250,11 @@ fn closure_to_task(cx: cx, configport: port<[u8]>, testfn: &fn()) ->
237250
let src_base = cx.config.src_base;
238251
let build_base = cx.config.build_base;
239252
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);
241254
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);
245258
let verbose = cx.config.verbose;
246259
let chan = cx.procsrv.chan;
247260

@@ -277,7 +290,7 @@ fn run_test_task(compile_lib_path: -istr, run_lib_path: -istr,
277290
src_base: src_base,
278291
build_base: build_base,
279292
stage_id: stage_id,
280-
mode: str_mode(istr::to_estr(mode)),
293+
mode: str_mode(mode),
281294
run_ignored: run_ignored,
282295
filter: str_opt(opt_filter),
283296
runtool: str_opt(opt_runtool),

trunk/src/test/compiletest/header.rs

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@ export is_test_ignored;
1212

1313
type test_props = {
1414
// Lines that should be expected, in order, on standard out
15-
error_patterns: [str],
15+
error_patterns: [istr],
1616
// Extra flags to pass to the compiler
17-
compile_flags: option::t<str>,
17+
compile_flags: option::t<istr>,
1818
// If present, the name of a file that this test should match when
1919
// pretty-printed
20-
pp_exact: option::t<str>,
20+
pp_exact: option::t<istr>,
2121
// FIXME: no-valgrind is a temporary directive until all of run-fail
2222
// is valgrind-clean
2323
no_valgrind: bool
2424
};
2525

2626
// Load any test directives embedded in the file
27-
fn load_props(testfile: &str) -> test_props {
27+
fn load_props(testfile: &istr) -> test_props {
2828
let error_patterns = [];
2929
let compile_flags = option::none;
3030
let pp_exact = option::none;
3131
let no_valgrind = false;
32-
for each ln: str in iter_header(testfile) {
32+
for each ln: istr in iter_header(testfile) {
3333
alt parse_error_pattern(ln) {
3434
option::some(ep) { error_patterns += [ep]; }
3535
option::none. { }
@@ -44,7 +44,7 @@ fn load_props(testfile: &str) -> test_props {
4444
}
4545

4646
if no_valgrind == false {
47-
no_valgrind = parse_name_directive(ln, "no-valgrind");
47+
no_valgrind = parse_name_directive(ln, ~"no-valgrind");
4848
}
4949
}
5050
ret {
@@ -55,70 +55,72 @@ fn load_props(testfile: &str) -> test_props {
5555
};
5656
}
5757

58-
fn is_test_ignored(config: &config, testfile: &str) -> bool {
58+
fn is_test_ignored(config: &config, testfile: &istr) -> bool {
5959
let found = false;
60-
for each ln: str in iter_header(testfile) {
60+
for each ln: istr in iter_header(testfile) {
6161
// FIXME: Can't return or break from iterator
6262
found = found
63-
|| parse_name_directive(ln, "xfail-"
64-
+ istr::to_estr(config.stage_id));
63+
|| parse_name_directive(ln, ~"xfail-"
64+
+ config.stage_id);
6565
if (config.mode == common::mode_pretty) {
6666
found = found
67-
|| parse_name_directive(ln, "xfail-pretty");
67+
|| parse_name_directive(ln, ~"xfail-pretty");
6868
}
6969
}
7070
ret found;
7171
}
7272

73-
iter iter_header(testfile: &str) -> str {
74-
let rdr = io::file_reader(istr::from_estr(testfile));
73+
iter iter_header(testfile: &istr) -> istr {
74+
let rdr = io::file_reader(testfile);
7575
while !rdr.eof() {
76-
let ln = istr::to_estr(rdr.read_line());
76+
let ln = rdr.read_line();
7777

7878
// Assume that any directives will be found before the first
7979
// module or function. This doesn't seem to be an optimization
8080
// with a warm page cache. Maybe with a cold one.
81-
if str::starts_with(ln, "fn") || str::starts_with(ln, "mod") {
81+
if istr::starts_with(ln, ~"fn")
82+
|| istr::starts_with(ln, ~"mod") {
8283
break;
8384
} else { put ln; }
8485
}
8586
}
8687

87-
fn parse_error_pattern(line: &str) -> option::t<str> {
88-
parse_name_value_directive(line, "error-pattern")
88+
fn parse_error_pattern(line: &istr) -> option::t<istr> {
89+
parse_name_value_directive(line, ~"error-pattern")
8990
}
9091

91-
fn parse_compile_flags(line: &str) -> option::t<str> {
92-
parse_name_value_directive(line, "compile-flags")
92+
fn parse_compile_flags(line: &istr) -> option::t<istr> {
93+
parse_name_value_directive(line, ~"compile-flags")
9394
}
9495

95-
fn parse_pp_exact(line: &str, testfile: &str) -> option::t<str> {
96-
alt parse_name_value_directive(line, "pp-exact") {
96+
fn parse_pp_exact(line: &istr, testfile: &istr) -> option::t<istr> {
97+
alt parse_name_value_directive(line, ~"pp-exact") {
9798
option::some(s) { option::some(s) }
9899
option::none. {
99-
if parse_name_directive(line, "pp-exact") {
100-
option::some(istr::to_estr(
101-
fs::basename(istr::from_estr(testfile))))
100+
if parse_name_directive(line, ~"pp-exact") {
101+
option::some(fs::basename(testfile))
102102
} else {
103103
option::none
104104
}
105105
}
106106
}
107107
}
108108

109-
fn parse_name_directive(line: &str, directive: &str) -> bool {
110-
str::find(line, directive) >= 0
109+
fn parse_name_directive(line: &istr, directive: &istr) -> bool {
110+
istr::find(line, directive) >= 0
111111
}
112112

113-
fn parse_name_value_directive(line: &str,
114-
directive: &str) -> option::t<str> {
115-
let keycolon = directive + ":";
116-
if str::find(line, keycolon) >= 0 {
117-
let colon = str::find(line, keycolon) as uint;
113+
fn parse_name_value_directive(line: &istr,
114+
directive: &istr) -> option::t<istr> {
115+
let keycolon = directive + ~":";
116+
if istr::find(line, keycolon) >= 0 {
117+
let colon = istr::find(line, keycolon) as uint;
118118
let value =
119-
str::slice(line, colon + str::byte_len(keycolon),
120-
str::byte_len(line));
121-
log #fmt("%s: %s", directive, value);
119+
istr::slice(line, colon + istr::byte_len(keycolon),
120+
istr::byte_len(line));
121+
log #fmt("%s: %s",
122+
istr::to_estr(directive),
123+
istr::to_estr(value));
122124
option::some(value)
123125
} else { option::none }
124126
}

0 commit comments

Comments
 (0)