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

do not print panic message on doctest failures #60549

Merged
merged 1 commit into from
May 29, 2019

Conversation

euclio
Copy link
Contributor

@euclio euclio commented May 4, 2019

This PR cleans up rustdoc test output by silently unwinding on failure instead of using panic!. It also improves the clarity and consistency of the output on test failure, and adds test cases for failure modes that were previously untested.

@euclio
Copy link
Contributor Author

euclio commented May 4, 2019

r? @QuietMisdreavus

Copy link
Member

@QuietMisdreavus QuietMisdreavus left a comment

Choose a reason for hiding this comment

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

Looks like this fixes #48394, which i'd originally closed as "not a bug". >_>

I'll take another look at this soon, but i like what i see so far! I'm going to rope in the rest of @rust-lang/rustdoc and @rep-nop since this was a big doctest thing for this year. It doesn't even seem like that much of a code change, either!

}
}

panic::resume_unwind(box ());
Copy link
Member

Choose a reason for hiding this comment

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

This is clever! I wouldn't think that resume_unwind would suppress the panic message, but i guess that that only happens in the panic hook, not in the pre-main landing pad.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah! I got the idea from this PR: #59990

Copy link
Member

Choose a reason for hiding this comment

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

Would have been nice to also copy the explanatory comment from that PR. :)

@GuillaumeGomez
Copy link
Member

That's way better! Thanks a lot!

Copy link
Member

@QuietMisdreavus QuietMisdreavus left a comment

Choose a reason for hiding this comment

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

One little nit, otherwise the rest of this looks great!

if !stdout.is_empty() || !stderr.is_empty() {
if !stdout.is_empty() {
eprintln!("{}", stdout);
}
Copy link
Member

Choose a reason for hiding this comment

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

I feel like this printout would be better served by bringing back the "Test executable failed" message and maybe also prefixing each printout with stdout:\n{} and stderr:\n{} so it's obvious what's going on.

Copy link
Member

Choose a reason for hiding this comment

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

How about including the exit code as well?


if let Err(err) = res {
match err {
TestFailure::CompileError => (), // The compiler errors are enough
Copy link
Member

Choose a reason for hiding this comment

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

I think there should still be a message like "Couldn't compile the test." in this case.

@euclio euclio force-pushed the doctest-panic-messages branch 2 times, most recently from f1c60e7 to 0a1ee14 Compare May 11, 2019 18:04
@euclio
Copy link
Contributor Author

euclio commented May 11, 2019

Comments addressed.

@bors
Copy link
Contributor

bors commented May 22, 2019

☔ The latest upstream changes (presumably #61027) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label May 22, 2019
@euclio
Copy link
Contributor Author

euclio commented May 22, 2019

@QuietMisdreavus Rebased.

@GuillaumeGomez
Copy link
Member

Thanks!

@bors: r+

@bors
Copy link
Contributor

bors commented May 29, 2019

📌 Commit 89d437e has been approved by GuillaumeGomez

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 29, 2019
Centril added a commit to Centril/rust that referenced this pull request May 29, 2019
…illaumeGomez

do not print panic message on doctest failures

This PR cleans up rustdoc test output by silently unwinding on failure instead of using `panic!`. It also improves the clarity and consistency of the output on test failure, and adds test cases for failure modes that were previously untested.
Centril added a commit to Centril/rust that referenced this pull request May 29, 2019
…illaumeGomez

do not print panic message on doctest failures

This PR cleans up rustdoc test output by silently unwinding on failure instead of using `panic!`. It also improves the clarity and consistency of the output on test failure, and adds test cases for failure modes that were previously untested.
oli-obk added a commit to oli-obk/rust that referenced this pull request May 29, 2019
…illaumeGomez

do not print panic message on doctest failures

This PR cleans up rustdoc test output by silently unwinding on failure instead of using `panic!`. It also improves the clarity and consistency of the output on test failure, and adds test cases for failure modes that were previously untested.
bors added a commit that referenced this pull request May 29, 2019
Rollup of 7 pull requests

Successful merges:

 - #60549 (do not print panic message on doctest failures)
 - #60885 (strip synstructure consts from compiler docs)
 - #61217 (Account for short-hand init structs when suggesting conversion)
 - #61261 (is_union returns ty to avoid computing it twice)
 - #61293 (Print const generics properly in rustdoc)
 - #61310 (split libcore::mem into multiple files)
 - #61313 (Simplify Set1::insert)

Failed merges:

r? @ghost
@bors bors merged commit 89d437e into rust-lang:master May 29, 2019
@euclio euclio deleted the doctest-panic-messages branch January 30, 2020 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants