about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-07-24 19:34:11 +0000
committerbors <bors@rust-lang.org>2018-07-24 19:34:11 +0000
commit487e961c6ae072d969e148def0b0856c2367ae00 (patch)
tree75e387657438fab491eae50a57a2f6fb4c2287e3 /src/test
parentf498e4ec1b57c3245a2fb8e0d5d836ed56760d2d (diff)
parent76e33b4eb4f116b02d3754efd67e4fba0c9b3f93 (diff)
downloadrust-487e961c6ae072d969e148def0b0856c2367ae00.tar.gz
rust-487e961c6ae072d969e148def0b0856c2367ae00.zip
Auto merge of #52181 - QuietMisdreavus:panicked-tester, r=GuillaumeGomez
rustdoc: set panic output before starting compiler thread pool

When the compiler was updated to run on a thread pool, rustdoc's processing of compiler/doctest stderr/stdout was moved into each compiler thread. However, this caused output of the test to be lost if the test failed at *runtime* instead of compile time. This change sets up the `set_panic` call and output bomb before starting the compiler thread pool, so that the `Drop` call that writes back to the test's stdout happens after the test runs, not just after it compiles.

Fixes https://github.com/rust-lang/rust/issues/51162
Diffstat (limited to 'src/test')
-rw-r--r--src/test/rustdoc-ui/failed-doctest-output.rs29
-rw-r--r--src/test/rustdoc-ui/failed-doctest-output.stdout32
2 files changed, 61 insertions, 0 deletions
diff --git a/src/test/rustdoc-ui/failed-doctest-output.rs b/src/test/rustdoc-ui/failed-doctest-output.rs
new file mode 100644
index 00000000000..62e495288cb
--- /dev/null
+++ b/src/test/rustdoc-ui/failed-doctest-output.rs
@@ -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;
diff --git a/src/test/rustdoc-ui/failed-doctest-output.stdout b/src/test/rustdoc-ui/failed-doctest-output.stdout
new file mode 100644
index 00000000000..cf417f8d412
--- /dev/null
+++ b/src/test/rustdoc-ui/failed-doctest-output.stdout
@@ -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
+