From 057bc7d6506bb0208b5da782602c5cf7692d10c8 Mon Sep 17 00:00:00 2001 From: clippered Date: Sat, 7 Oct 2017 18:50:50 +1100 Subject: Fix #44968 Windows path in UI tests --- src/tools/compiletest/src/runtest.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/tools/compiletest') diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 870e08cc6e5..0ffc8b563bb 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2325,8 +2325,15 @@ actual:\n\ fn normalize_output(&self, output: &str, custom_rules: &[(String, String)]) -> String { let parent_dir = self.testpaths.file.parent().unwrap(); - let parent_dir_str = parent_dir.display().to_string(); + let cflags = self.props.compile_flags.join(" "); + let parent_dir_str = if cflags.contains("--error-format json") { + parent_dir.display().to_string().replace("\\", "\\\\") + } else { + parent_dir.display().to_string() + }; + let mut normalized = output.replace(&parent_dir_str, "$DIR") + .replace("\\\\", "\\") // denormalize for paths on windows .replace("\\", "/") // normalize for paths on windows .replace("\r\n", "\n") // normalize for linebreaks on windows .replace("\t", "\\t"); // makes tabs visible -- cgit 1.4.1-3-g733a5