-
Notifications
You must be signed in to change notification settings - Fork 13.7k
compiletest: Capture panic messages via a custom panic hook #146068
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
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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this seems reasonable to work towards not relying on internal_output_capture
. I do hope that long term we'd have stable alternatives, but this is fine.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: this feels a bit hacky, but it seems reasonable as a workaround.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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