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: Printing process output panics if the output contains unknown JSON-like text #126373

Closed
Zalathar opened this issue Jun 13, 2024 · 1 comment · Fixed by #129049
Closed
Labels
A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Zalathar
Copy link
Contributor

When a process unexpectedly fails/succeeds, compiletest will often print a full dump of its stdout and stderr for diagnostic purposes.

When this happens, ProcRes::print_info calls into extract_rendered, which has special handling for lines starting with {. It tries to parse the line as JSON in one of a few known compiler-specific formats, in order to replace it with a more human-friendly message.

If the line doesn't match any of those formats (or isn't valid JSON), the extractor code will panic, instead of just printing the line as-is. This is awkward in cases where we actually wanted to print the line as-is anyway, because now the error messages are less helpful.

@rustbot label +A-compiletest

@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. A-compiletest Area: The compiletest test runner labels Jun 13, 2024
@Zalathar
Copy link
Contributor Author

The obvious solution (just make it not panic) is complicated by the fact that extract_rendered is called in multiple places, so it's harder to know whether the error is load-bearing in one of those cases.

@jieyouxu jieyouxu added A-testsuite Area: The testsuite used to check the correctness of rustc T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jun 13, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Aug 13, 2024
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 rust-lang#126373.
@bors bors closed this as completed in 65054ed Aug 14, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Aug 14, 2024
Rollup merge of rust-lang#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 rust-lang#126373.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
3 participants