Skip to content

Commit 39d3b93

Browse files
committed
Pretty-print tests only run on .rs files. Issue #789
The pretty-printer can't handle .rc files currently
1 parent 4e8ab8b commit 39d3b93

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/test/compiletest/compiletest.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,33 @@ fn make_tests(cx: &cx) -> tests_and_conv_fn {
125125
let tests = ~[];
126126
for file: str in fs::list_dir(cx.config.src_base) {
127127
log #fmt("inspecting file %s", file);
128-
if is_test(file) { tests += ~[make_test(cx, file, configport)]; }
128+
if is_test(cx.config, file) {
129+
tests += ~[make_test(cx, file, configport)];
130+
}
129131
}
130132
ret {tests: tests, to_task: bind closure_to_task(cx, configport, _)};
131133
}
132134

133-
fn is_test(testfile: &str) -> bool {
135+
fn is_test(config: &config, testfile: &str) -> bool {
136+
// Pretty-printer does not work with .rc files yet
137+
let valid_extensions = alt config.mode {
138+
mode_pretty. { ~[".rs"] }
139+
_ { ~[".rc", ".rs"] }
140+
};
141+
let invalid_prefixes = ~[".", "#", "~"];
134142
let name = fs::basename(testfile);
135-
(str::ends_with(name, ".rs") || str::ends_with(name, ".rc")) &&
136-
!(str::starts_with(name, ".") || str::starts_with(name, "#") ||
137-
str::starts_with(name, "~"))
143+
144+
let valid = false;
145+
146+
for ext in valid_extensions {
147+
if str::ends_with(name, ext) { valid = true }
148+
}
149+
150+
for pre in invalid_prefixes {
151+
if str::starts_with(name, pre) { valid = false }
152+
}
153+
154+
ret valid;
138155
}
139156

140157
fn make_test(cx: &cx, testfile: &str, configport: &port[str]) ->

0 commit comments

Comments
 (0)