about summary refs log tree commit diff
path: root/src/tools/compiletest
diff options
context:
space:
mode:
authorclippered <clarke_overkill@yahoo.com>2017-10-07 18:50:50 +1100
committerclippered <clarke_overkill@yahoo.com>2017-10-11 23:25:39 +1100
commit057bc7d6506bb0208b5da782602c5cf7692d10c8 (patch)
tree3d8a1518903998a587c7c4a7c63e391b513c8a10 /src/tools/compiletest
parent264aafe0566e521bbc95bd3f44dae97591c9fd20 (diff)
downloadrust-057bc7d6506bb0208b5da782602c5cf7692d10c8.tar.gz
rust-057bc7d6506bb0208b5da782602c5cf7692d10c8.zip
Fix #44968 Windows path in UI tests
Diffstat (limited to 'src/tools/compiletest')
-rw-r--r--src/tools/compiletest/src/runtest.rs9
1 files changed, 8 insertions, 1 deletions
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