diff options
| author | Diggory Blake <diggsey@googlemail.com> | 2015-08-24 04:52:38 +0100 |
|---|---|---|
| committer | Diggory Blake <diggsey@googlemail.com> | 2015-08-24 04:53:56 +0100 |
| commit | 19dc4d0a306852a132b8be3614c6cb49658f0c57 (patch) | |
| tree | d001d7c509e43d5ac53deb1630bf0569979a8b34 | |
| parent | 8f1b0aa32552f2e694aa8702ff2cd6d9a0e894f1 (diff) | |
| download | rust-19dc4d0a306852a132b8be3614c6cb49658f0c57.tar.gz rust-19dc4d0a306852a132b8be3614c6cb49658f0c57.zip | |
Fix compile-fail tests on windows
| -rw-r--r-- | src/compiletest/compiletest.rs | 1 | ||||
| -rw-r--r-- | src/compiletest/runtest.rs | 16 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index 36c67639101..b7249cd8d0f 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -19,6 +19,7 @@ #![feature(str_char)] #![feature(test)] #![feature(vec_push_all)] +#![feature(path_components_peek)] #![deny(warnings)] diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 5d9c430beaf..96e903d3544 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -25,7 +25,7 @@ use std::fs::{self, File}; use std::io::BufReader; use std::io::prelude::*; use std::net::TcpStream; -use std::path::{Path, PathBuf}; +use std::path::{Path, PathBuf, Component}; use std::process::{Command, Output, ExitStatus}; pub fn run(config: Config, testfile: &Path) { @@ -952,6 +952,9 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError>, // filename:line1:col1: line2:col2: *warning:* msg // where line1:col1: is the starting point, line2:col2: // is the ending point, and * represents ANSI color codes. + // + // This pattern is ambiguous on windows, because filename may contain + // a colon, so any path prefix must be detected and removed first. for line in proc_res.stderr.lines() { let mut was_expected = false; let mut prev = 0; @@ -1006,7 +1009,16 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError>, } } -fn is_compiler_error_or_warning(line: &str) -> bool { +fn is_compiler_error_or_warning(mut line: &str) -> bool { + // Remove initial prefix which may contain a colon + let mut components = Path::new(line).components(); + if let Some(Component::Prefix(_)) = components.peek() { + components.next(); + } + + // Safe as path was originally constructed from a &str ^ + line = components.as_path().to_str().unwrap(); + let mut i = 0; return scan_until_char(line, ':', &mut i) && |
