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

Conversation

Zalathar
Copy link
Contributor

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.

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.
The JSON messages parsed by this file are from the _compiler_, not from
libtest.
@rustbot
Copy link
Collaborator

rustbot commented Aug 13, 2024

r? @Kobzol

rustbot has assigned @Kobzol.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the A-testsuite Area: The testsuite used to check the correctness of rustc label Aug 13, 2024
@rustbot
Copy link
Collaborator

rustbot commented Aug 13, 2024

Some changes occurred in src/tools/compiletest

cc @jieyouxu

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Aug 13, 2024
Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

The existing code here is extremely hacky and fragile, but not panicking here seems okay to me.

@@ -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.

@jieyouxu
Copy link
Member

Thanks for the fix!

r? jieyouxu
@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 13, 2024

📌 Commit 355f264 has been approved by jieyouxu

It is now in the queue for this repository.

@rustbot rustbot assigned jieyouxu and unassigned Kobzol Aug 13, 2024
@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 13, 2024
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request 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 added a commit to rust-lang-ci/rust that referenced this pull request Aug 13, 2024
…llaumeGomez

Rollup of 7 pull requests

Successful merges:

 - rust-lang#127857 (Allow to customize `// TODO:` comment for deprecated safe autofix)
 - rust-lang#128410 (Migrate `remap-path-prefix-dwarf` `run-make` test to rmake)
 - rust-lang#128828 (`-Znext-solver` caching)
 - rust-lang#128873 (Add windows-targets crate to std's sysroot)
 - rust-lang#129034 (Add `#[must_use]` attribute to `Coroutine` trait)
 - rust-lang#129049 (compiletest: Don't panic on unknown JSON-like output lines)
 - rust-lang#129050 (Emit a warning instead of an error if `--generate-link-to-definition` is used with other output formats than HTML)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 13, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#122884 (Optimize integer `pow` by removing the exit branch)
 - rust-lang#127857 (Allow to customize `// TODO:` comment for deprecated safe autofix)
 - rust-lang#129034 (Add `#[must_use]` attribute to `Coroutine` trait)
 - rust-lang#129049 (compiletest: Don't panic on unknown JSON-like output lines)
 - rust-lang#129050 (Emit a warning instead of an error if `--generate-link-to-definition` is used with other output formats than HTML)
 - rust-lang#129056 (Fix one usage of target triple in bootstrap)
 - rust-lang#129058 (Add mw back to review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 14, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#122884 (Optimize integer `pow` by removing the exit branch)
 - rust-lang#127857 (Allow to customize `// TODO:` comment for deprecated safe autofix)
 - rust-lang#129034 (Add `#[must_use]` attribute to `Coroutine` trait)
 - rust-lang#129049 (compiletest: Don't panic on unknown JSON-like output lines)
 - rust-lang#129050 (Emit a warning instead of an error if `--generate-link-to-definition` is used with other output formats than HTML)
 - rust-lang#129056 (Fix one usage of target triple in bootstrap)
 - rust-lang#129058 (Add mw back to review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 14, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#122884 (Optimize integer `pow` by removing the exit branch)
 - rust-lang#127857 (Allow to customize `// TODO:` comment for deprecated safe autofix)
 - rust-lang#129034 (Add `#[must_use]` attribute to `Coroutine` trait)
 - rust-lang#129049 (compiletest: Don't panic on unknown JSON-like output lines)
 - rust-lang#129050 (Emit a warning instead of an error if `--generate-link-to-definition` is used with other output formats than HTML)
 - rust-lang#129056 (Fix one usage of target triple in bootstrap)
 - rust-lang#129058 (Add mw back to review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 65054ed into rust-lang:master Aug 14, 2024
6 checks passed
@rustbot rustbot added this to the 1.82.0 milestone Aug 14, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request 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.
@Zalathar Zalathar deleted the json-like branch August 14, 2024 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

compiletest: Printing process output panics if the output contains unknown JSON-like text
5 participants