Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiletest: Don't panic on unknown JSON-like output lines #129049

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remark: you are right, this is wrong; it's not libtest, it's not just compiler, it's also rustdoc and maybe even more.


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
Loading