Skip to content

Commit 63c9b11

Browse files
committed
auto merge of #8003 : crnobog/rust/case-insensitive-error-prefix, r=cmr
Paths are case insensitive on windows and rustc and compiletest may disagree on casing. Fixes test compile-fail/circular_modules_main on win32
2 parents 8413d47 + 6f4e2b2 commit 63c9b11

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/compiletest/runtest.rs

+26-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use util::logv;
2222

2323
use std::io;
2424
use std::os;
25+
use std::str;
2526
use std::uint;
2627
use std::vec;
2728

@@ -355,6 +356,30 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
355356
fmt!("%s:%u:", testfile.to_str(), ee.line)
356357
}).collect::<~[~str]>();
357358

359+
fn to_lower( s : &str ) -> ~str {
360+
let i = s.iter();
361+
let c : ~[char] = i.transform( |c| {
362+
if c.is_ascii() {
363+
c.to_ascii().to_lower().to_char()
364+
} else {
365+
c
366+
}
367+
} ).collect();
368+
str::from_chars( c )
369+
}
370+
371+
#[cfg(target_os = "win32")]
372+
fn prefix_matches( line : &str, prefix : &str ) -> bool {
373+
to_lower(line).starts_with( to_lower(prefix) )
374+
}
375+
376+
#[cfg(target_os = "linux")]
377+
#[cfg(target_os = "macos")]
378+
#[cfg(target_os = "freebsd")]
379+
fn prefix_matches( line : &str, prefix : &str ) -> bool {
380+
line.starts_with( prefix )
381+
}
382+
358383
// Scan and extract our error/warning messages,
359384
// which look like:
360385
// filename:line1:col1: line2:col2: *error:* msg
@@ -367,7 +392,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
367392
if !found_flags[i] {
368393
debug!("prefix=%s ee.kind=%s ee.msg=%s line=%s",
369394
prefixes[i], ee.kind, ee.msg, line);
370-
if (line.starts_with(prefixes[i]) &&
395+
if (prefix_matches(line, prefixes[i]) &&
371396
line.contains(ee.kind) &&
372397
line.contains(ee.msg)) {
373398
found_flags[i] = true;

0 commit comments

Comments
 (0)