compiletest: Capture panic messages via a custom panic hook#146068
compiletest: Capture panic messages via a custom panic hook#146068bors merged 1 commit intorust-lang:masterfrom
Conversation
|
Some changes occurred in src/tools/compiletest cc @jieyouxu |
|
I've done some amount of manual testing in all three In all cases, the output was as close as I could get it, though there are some minor discrepancies that shouldn't matter. (For example, the technique I use to simulate short backtraces retains the stack frame numbers from the original trace.) |
Output diff for
|
| while let Some(line) = lines.next() { | ||
| if mem::replace(&mut skip_next_at, false) && line.trim_start().starts_with("at ") { | ||
| continue; |
There was a problem hiding this comment.
Remark: this feels a bit hacky, but it seems reasonable as a workaround.
There was a problem hiding this comment.
Yeah, unfortunately I don't think there's a better alternative on stable.
In the long run, replacing compiletest's panic-based error handling with result-based error handling should eventually make it possible to get rid of the panic hook, since leaking internal errors to the console isn't such a big deal.
|
@bors r+ rollup |
Rollup of 5 pull requests Successful merges: - #145468 (dedup recip, powi, to_degrees, and to_radians float tests) - #145643 (coverage: Build an "expansion tree" and use it to unexpand raw spans) - #145754 (fix(lexer): Don't require frontmatters to be escaped with indented fences) - #146060 (fixup nix dev shell again) - #146068 (compiletest: Capture panic messages via a custom panic hook) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of #146068 - Zalathar:panic-hook, r=jieyouxu compiletest: Capture panic messages via a custom panic hook Currently, output-capture of panic messages relies on special cooperation between `#![feature(internal_output_capture)]` and the default panic hook. That's a problem if we want to perform our own output capture, because the default panic hook won't know about our custom output-capture mechanism. We can work around that by installing a custom panic hook that prints equivalent panic messages to a buffer instead. The custom hook is always installed, but delegates to the default panic hook unless a panic-capture buffer has been installed on the current thread. A panic-capture buffer is only installed on compiletest test threads (by the executor), and only if output-capture is enabled. --- Right now this PR doesn't provide any particular concrete benefits. But it will be essential as part of further efforts to replace compiletest's use of `#![feature(internal_output_capture)]` with our own output-capture mechanism. r? jieyouxu
Rollup of 5 pull requests Successful merges: - rust-lang#145468 (dedup recip, powi, to_degrees, and to_radians float tests) - rust-lang#145643 (coverage: Build an "expansion tree" and use it to unexpand raw spans) - rust-lang#145754 (fix(lexer): Don't require frontmatters to be escaped with indented fences) - rust-lang#146060 (fixup nix dev shell again) - rust-lang#146068 (compiletest: Capture panic messages via a custom panic hook) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 5 pull requests Successful merges: - rust-lang/rust#145468 (dedup recip, powi, to_degrees, and to_radians float tests) - rust-lang/rust#145643 (coverage: Build an "expansion tree" and use it to unexpand raw spans) - rust-lang/rust#145754 (fix(lexer): Don't require frontmatters to be escaped with indented fences) - rust-lang/rust#146060 (fixup nix dev shell again) - rust-lang/rust#146068 (compiletest: Capture panic messages via a custom panic hook) r? `@ghost` `@rustbot` modify labels: rollup
Currently, output-capture of panic messages relies on special cooperation between
#![feature(internal_output_capture)]and the default panic hook. That's a problem if we want to perform our own output capture, because the default panic hook won't know about our custom output-capture mechanism.We can work around that by installing a custom panic hook that prints equivalent panic messages to a buffer instead.
The custom hook is always installed, but delegates to the default panic hook unless a panic-capture buffer has been installed on the current thread. A panic-capture buffer is only installed on compiletest test threads (by the executor), and only if output-capture is enabled.
Right now this PR doesn't provide any particular concrete benefits. But it will be essential as part of further efforts to replace compiletest's use of
#![feature(internal_output_capture)]with our own output-capture mechanism.r? jieyouxu