diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-08-13 21:11:14 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-13 21:11:14 +0200 |
| commit | 65054ed35edeb6293c247020ae2259e8d1f0d984 (patch) | |
| tree | 63d292c2825f3fcf30c6f5244861e1b39e196df7 | |
| parent | d4f5a89f6e9f62f147994b65cacf77e944e2aec6 (diff) | |
| parent | 355f264d32cf449e00adeeaccfb17a1e2f3fdd18 (diff) | |
| download | rust-65054ed35edeb6293c247020ae2259e8d1f0d984.tar.gz rust-65054ed35edeb6293c247020ae2259e8d1f0d984.zip | |
Rollup merge of #129049 - Zalathar:json-like, r=jieyouxu
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.
| -rw-r--r-- | src/tools/compiletest/src/json.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/tools/compiletest/src/json.rs b/src/tools/compiletest/src/json.rs index 76b83f02b14..0da93dcafa2 100644 --- a/src/tools/compiletest/src/json.rs +++ b/src/tools/compiletest/src/json.rs @@ -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; @@ -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 |
