-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
rustdoc: set panic output before starting compiler thread pool #52181
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d17a378
rustdoc: set panic output before starting compiler thread pool
QuietMisdreavus 3365419
add ui test for failing doctest
QuietMisdreavus 41e7ac1
report doctest compile failures correctly
QuietMisdreavus ffbd2b9
update stdout file with test path normalization
QuietMisdreavus d965371
normalize test output so it can be run from repo root
QuietMisdreavus d3569d2
add failure-status to rustdoc doctest ui test
QuietMisdreavus e3bc713
compiletest: don't overwrite failure-status if it was previously set
QuietMisdreavus 76e33b4
force the doctest rustc thread to share the name of the test
QuietMisdreavus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// Issue #51162: A failed doctest was not printing its stdout/stderr | ||
// FIXME: if/when the output of the test harness can be tested on its own, this test should be | ||
// adapted to use that, and that normalize line can go away | ||
|
||
// compile-flags:--test | ||
// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR" | ||
// failure-status: 101 | ||
|
||
// doctest fails at runtime | ||
/// ``` | ||
/// panic!("oh no"); | ||
/// ``` | ||
pub struct SomeStruct; | ||
|
||
// doctest fails at compile time | ||
/// ``` | ||
/// no | ||
/// ``` | ||
pub struct OtherStruct; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
running 2 tests | ||
test $DIR/failed-doctest-output.rs - OtherStruct (line 26) ... FAILED | ||
test $DIR/failed-doctest-output.rs - SomeStruct (line 20) ... FAILED | ||
|
||
failures: | ||
|
||
---- $DIR/failed-doctest-output.rs - OtherStruct (line 26) stdout ---- | ||
error[E0425]: cannot find value `no` in this scope | ||
--> $DIR/failed-doctest-output.rs:27:1 | ||
| | ||
3 | no | ||
| ^^ not found in this scope | ||
|
||
thread '$DIR/failed-doctest-output.rs - OtherStruct (line 26)' panicked at 'couldn't compile the test', librustdoc/test.rs:332:13 | ||
note: Run with `RUST_BACKTRACE=1` for a backtrace. | ||
|
||
---- $DIR/failed-doctest-output.rs - SomeStruct (line 20) stdout ---- | ||
thread '$DIR/failed-doctest-output.rs - SomeStruct (line 20)' panicked at 'test executable failed: | ||
|
||
thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:3:1 | ||
note: Run with `RUST_BACKTRACE=1` for a backtrace. | ||
|
||
', librustdoc/test.rs:367:17 | ||
|
||
|
||
failures: | ||
$DIR/failed-doctest-output.rs - OtherStruct (line 26) | ||
$DIR/failed-doctest-output.rs - SomeStruct (line 20) | ||
|
||
test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
While this new arrangement delays the printing of the collected output to a later, more appropriate stage, doesn't this still leave the panic handler eating more data, if there is any? Should the panic handler also be restored? (Or maybe it's otherwise guaranteed to exit before that can happen? Sorry, not familiar with the code here.)
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.
My assumption is that because this is what it was doing beforehand, it's not much harm to leave it. Before I had this version, I tried calling
set_panic
to switch the sink back in thisDrop
call. It didn't change anything about the output, so I set it back. Each test will set the panic writer to a fresh buffer, so there's no chance of test outputs accumulating.However, if any panic occurs outside of this function, the output will be swallowed. This may be what we want, but it's something to consider.