Fix compiletest::header::iter_header to work with new-style for loops

Gets rid of a FIXME -- yay!
This commit is contained in:
Tim Chevalier
2012-05-03 17:41:02 -07:00
parent 82d4fe3967
commit 37f23303e6

View File

@@ -29,7 +29,7 @@ fn load_props(testfile: str) -> test_props {
let mut exec_env = []; let mut exec_env = [];
let mut compile_flags = option::none; let mut compile_flags = option::none;
let mut pp_exact = option::none; let mut pp_exact = option::none;
iter_header(testfile) {|ln| for iter_header(testfile) {|ln|
alt parse_error_pattern(ln) { alt parse_error_pattern(ln) {
option::some(ep) { error_patterns += [ep]; } option::some(ep) { error_patterns += [ep]; }
option::none { } option::none { }
@@ -62,14 +62,11 @@ fn load_props(testfile: str) -> test_props {
fn is_test_ignored(config: config, testfile: str) -> bool { fn is_test_ignored(config: config, testfile: str) -> bool {
let mut found = false; let mut found = false;
iter_header(testfile) {|ln| for iter_header(testfile) {|ln|
// FIXME: Can't return or break from iterator if parse_name_directive(ln, "xfail-test") { ret true; }
// (Fix when Issue #1619 is resolved) if parse_name_directive(ln, xfail_target()) { ret true; }
found = found || parse_name_directive(ln, "xfail-test"); if config.mode == common::mode_pretty &&
found = found || parse_name_directive(ln, xfail_target()); parse_name_directive(ln, "xfail-pretty") { ret true; }
if (config.mode == common::mode_pretty) {
found = found || parse_name_directive(ln, "xfail-pretty");
}
}; };
ret found; ret found;
@@ -78,7 +75,7 @@ fn is_test_ignored(config: config, testfile: str) -> bool {
} }
} }
fn iter_header(testfile: str, it: fn(str)) { fn iter_header(testfile: str, it: fn(str) -> bool) -> bool {
let rdr = result::get(io::file_reader(testfile)); let rdr = result::get(io::file_reader(testfile));
while !rdr.eof() { while !rdr.eof() {
let ln = rdr.read_line(); let ln = rdr.read_line();
@@ -88,9 +85,10 @@ fn iter_header(testfile: str, it: fn(str)) {
// with a warm page cache. Maybe with a cold one. // with a warm page cache. Maybe with a cold one.
if str::starts_with(ln, "fn") if str::starts_with(ln, "fn")
|| str::starts_with(ln, "mod") { || str::starts_with(ln, "mod") {
break; ret false;
} else { it(ln); } } else { if !(it(ln)) { ret false; } }
} }
ret true;
} }
fn parse_error_pattern(line: str) -> option<str> { fn parse_error_pattern(line: str) -> option<str> {