diff options
| author | Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> | 2017-11-17 08:55:22 +0100 |
|---|---|---|
| committer | Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> | 2017-11-20 09:37:54 +0100 |
| commit | 78e269ee0b8050bf91ed35b08b93b922c334d21f (patch) | |
| tree | 9df61c46d43d1e8a6d84e28446dd1a12949320d7 /src/tools/compiletest | |
| parent | 580298680ca6500c537662f38b4f56dab9c8c9aa (diff) | |
| download | rust-78e269ee0b8050bf91ed35b08b93b922c334d21f.tar.gz rust-78e269ee0b8050bf91ed35b08b93b922c334d21f.zip | |
Include rendered diagnostic in json
Diffstat (limited to 'src/tools/compiletest')
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 14 |
1 files changed, 10 insertions, 4 deletions
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 |
