Skip to content

Commit 28ef44a

Browse files
committed
Auto merge of #27974 - Diggsey:issue-27952, r=alexcrichton
Fixes #27952
2 parents e195aa8 + 19dc4d0 commit 28ef44a

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/compiletest/compiletest.rs

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#![feature(str_char)]
2020
#![feature(test)]
2121
#![feature(vec_push_all)]
22+
#![feature(path_components_peek)]
2223

2324
#![deny(warnings)]
2425

src/compiletest/runtest.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use std::fs::{self, File};
2525
use std::io::BufReader;
2626
use std::io::prelude::*;
2727
use std::net::TcpStream;
28-
use std::path::{Path, PathBuf};
28+
use std::path::{Path, PathBuf, Component};
2929
use std::process::{Command, Output, ExitStatus};
3030

3131
pub fn run(config: Config, testfile: &Path) {
@@ -952,6 +952,9 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError>,
952952
// filename:line1:col1: line2:col2: *warning:* msg
953953
// where line1:col1: is the starting point, line2:col2:
954954
// is the ending point, and * represents ANSI color codes.
955+
//
956+
// This pattern is ambiguous on windows, because filename may contain
957+
// a colon, so any path prefix must be detected and removed first.
955958
for line in proc_res.stderr.lines() {
956959
let mut was_expected = false;
957960
let mut prev = 0;
@@ -1006,7 +1009,16 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError>,
10061009
}
10071010
}
10081011

1009-
fn is_compiler_error_or_warning(line: &str) -> bool {
1012+
fn is_compiler_error_or_warning(mut line: &str) -> bool {
1013+
// Remove initial prefix which may contain a colon
1014+
let mut components = Path::new(line).components();
1015+
if let Some(Component::Prefix(_)) = components.peek() {
1016+
components.next();
1017+
}
1018+
1019+
// Safe as path was originally constructed from a &str ^
1020+
line = components.as_path().to_str().unwrap();
1021+
10101022
let mut i = 0;
10111023
return
10121024
scan_until_char(line, ':', &mut i) &&

0 commit comments

Comments
 (0)