From 78e269ee0b8050bf91ed35b08b93b922c334d21f Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Fri, 17 Nov 2017 08:55:22 +0100 Subject: Include rendered diagnostic in json --- src/tools/compiletest/src/runtest.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/tools/compiletest') diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index b5a8a15b1a8..b74867aba2d 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2400,15 +2400,21 @@ 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 { + normalized = normalized.replace("\\n", "\n"); // verbatim newline in json strings + } + + 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 -- cgit 1.4.1-3-g733a5