about summary refs log tree commit diff
path: root/src/tools/compiletest
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/compiletest')
-rw-r--r--src/tools/compiletest/src/runtest.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 749d1f4c378..1fd48881ba2 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -2424,15 +2424,25 @@ actual:\n\
     fn normalize_output(&self, output: &str, custom_rules: &[(String, String)]) -> String {
         let parent_dir = self.testpaths.file.parent().unwrap();
         let cflags = self.props.compile_flags.join(" ");
-        let parent_dir_str = if cflags.contains("--error-format json")
-                             || cflags.contains("--error-format pretty-json") {
+        let json = cflags.contains("--error-format json") ||
+                   cflags.contains("--error-format pretty-json");
+        let parent_dir_str = if 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
+        let mut normalized = output.replace(&parent_dir_str, "$DIR");
+
+        if json {
+            // escaped newlines in json strings should be readable
+            // in the stderr files. There's no point int being correct,
+            // since only humans process the stderr files.
+            // Thus we just turn escaped newlines back into newlines.
+            normalized = normalized.replace("\\n", "\n");
+        }
+
+        normalized = normalized.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