Skip to content

Commit

Permalink
Rollup merge of #129049 - Zalathar:json-like, r=jieyouxu
Browse files Browse the repository at this point in the history
compiletest: Don't panic on unknown JSON-like output lines

The `json::extract_rendered` function is called for both compiler output and non-compiler output, so it's inappropriate to panic just because a line starting with `{` didn't contain a compiler output message.

It is called from two places: when checking the output of a `ui` test process, and when printing the output of an arbitrary non-passing `ProcRes`. So unfortunately there's currently no easy way to know for sure whether it is seeing compiler output or not. Fortunately, neither call site appears to be relying on this panic; it's just an overzealous internal check.

Fixes #126373.
  • Loading branch information
matthiaskrgr committed Aug 13, 2024
2 parents d4f5a89 + 355f264 commit 65054ed
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/tools/compiletest/src/json.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//! These structs are a subset of the ones found in `rustc_errors::json`.
//! They are only used for deserialization of JSON output provided by libtest.

use std::path::{Path, PathBuf};
use std::str::FromStr;
Expand Down Expand Up @@ -127,11 +126,10 @@ pub fn extract_rendered(output: &str) -> String {
// Ignore the notification.
None
} else {
print!(
"failed to decode compiler output as json: line: {}\noutput: {}",
line, output
);
panic!()
// This function is called for both compiler and non-compiler output,
// so if the line isn't recognized as JSON from the compiler then
// just print it as-is.
Some(format!("{line}\n"))
}
} else {
// preserve non-JSON lines, such as ICEs
Expand Down

0 comments on commit 65054ed

Please sign in to comment.