Rollup merge of #46052 - oli-obk:rendered_diagnostics_in_json, r=petrochenkov
Include rendered diagnostic in json r? @petrochenkov
This commit is contained in:
commit
0af67a4df0
5 changed files with 176 additions and 24 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue