]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/compiletest/src/runtest.rs
Auto merge of #45080 - clippered:issue-44986/fix-windows-ui-path, r=estebank
[rust.git] / src / tools / compiletest / src / runtest.rs
index d61077643f1fe435c36b318f6cf097e7e1100d3d..0473c2a5405b02f12b5c5f4e4464c0d7a49df5c2 100644 (file)
@@ -2378,8 +2378,15 @@ fn get_mir_dump_dir(&self) -> PathBuf {
 
     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