From 19dc4d0a306852a132b8be3614c6cb49658f0c57 Mon Sep 17 00:00:00 2001 From: Diggory Blake Date: Mon, 24 Aug 2015 04:52:38 +0100 Subject: [PATCH] Fix compile-fail tests on windows --- src/compiletest/compiletest.rs | 1 + 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, // 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, } } -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) &&