From 5e53528b79ba4d7f1cfa025a45afaf1bec574e91 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 24 Jul 2018 22:35:15 +0200 Subject: [PATCH 01/12] Release notes: add some missing 1.28 libs stabilization --- RELEASES.md | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 503ce7ede0d7d..56c70a64b8c27 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -52,6 +52,16 @@ Stabilized APIs --------------- - [`Iterator::step_by`] - [`Path::ancestors`] +- [`SystemTime::UNIX_EPOCH`] +- [`alloc::GlobalAlloc`] +- [`alloc::Layout`] +- [`alloc::LayoutErr`] +- [`alloc::System`] +- [`alloc::alloc`] +- [`alloc::alloc_zeroed`] +- [`alloc::dealloc`] +- [`alloc::realloc`] +- [`alloc::handle_alloc_error`] - [`btree_map::Entry::or_default`] - [`fmt::Alignment`] - [`hash_map::Entry::or_default`] @@ -122,6 +132,16 @@ Compatibility Notes [cargo/5584]: https://github.com/rust-lang/cargo/pull/5584/ [`Iterator::step_by`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.step_by [`Path::ancestors`]: https://doc.rust-lang.org/std/path/struct.Path.html#method.ancestors +[`SystemTime::UNIX_EPOCH`]: https://doc.rust-lang.org/std/time/struct.SystemTime.html#associatedconstant.UNIX_EPOCH +[`alloc::GlobalAlloc`]: https://doc.rust-lang.org/std/alloc/trait.GlobalAlloc.html +[`alloc::Layout`]: https://doc.rust-lang.org/std/alloc/struct.Layout.html +[`alloc::LayoutErr`]: https://doc.rust-lang.org/std/alloc/struct.LayoutErr.html +[`alloc::System`]: https://doc.rust-lang.org/std/alloc/struct.System.html +[`alloc::alloc`]: https://doc.rust-lang.org/std/alloc/fn.alloc.html +[`alloc::alloc_zeroed`]: https://doc.rust-lang.org/std/alloc/fn.alloc_zeroed.html +[`alloc::dealloc`]: https://doc.rust-lang.org/std/alloc/fn.dealloc.html +[`alloc::realloc`]: https://doc.rust-lang.org/std/alloc/fn.realloc.html +[`alloc::handle_alloc_error`]: https://doc.rust-lang.org/std/alloc/fn.handle_alloc_error.html [`btree_map::Entry::or_default`]: https://doc.rust-lang.org/std/collections/btree_map/enum.Entry.html#method.or_default [`fmt::Alignment`]: https://doc.rust-lang.org/std/fmt/enum.Alignment.html [`hash_map::Entry::or_default`]: https://doc.rust-lang.org/std/collections/btree_map/enum.Entry.html#method.or_default @@ -3162,7 +3182,7 @@ Stabilized APIs * [`UnixDatagram::shutdown`](http://doc.rust-lang.org/std/os/unix/net/struct.UnixDatagram.html#method.shutdown) * RawFd impls for `UnixDatagram` * `{BTree,Hash}Map::values_mut` -* [`<[_]>::binary_search_by_key`](http://doc.rust-lang.org/beta/std/primitive.slice.html#method.binary_search_by_key) +* [`<[_]>::binary_search_by_key`](http://doc.rust-lang.org/std/primitive.slice.html#method.binary_search_by_key) Libraries --------- @@ -4080,7 +4100,7 @@ Compatibility Notes [1.6bh]: https://github.com/rust-lang/rust/pull/29811 [1.6c]: https://github.com/rust-lang/cargo/pull/2192 [1.6cc]: https://github.com/rust-lang/cargo/pull/2131 -[1.6co]: http://doc.rust-lang.org/beta/core/index.html +[1.6co]: http://doc.rust-lang.org/core/index.html [1.6dv]: https://github.com/rust-lang/rust/pull/30000 [1.6f]: https://github.com/rust-lang/rust/pull/29129 [1.6m]: https://github.com/rust-lang/rust/pull/29828 From c3c4615b0e9fb15a9088a850b41e5f1a40daf030 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Mon, 9 Jul 2018 10:32:49 -0500 Subject: [PATCH 02/12] rustdoc: set panic output before starting compiler thread pool --- src/librustdoc/test.rs | 52 ++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 6086c5a47c78c..f47f70480f8b2 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -232,31 +232,35 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize, ..config::basic_options().clone() }; - let (libdir, outdir) = driver::spawn_thread_pool(sessopts, |sessopts| { - // Shuffle around a few input and output handles here. We're going to pass - // an explicit handle into rustc to collect output messages, but we also - // want to catch the error message that rustc prints when it fails. - // - // We take our thread-local stderr (likely set by the test runner) and replace - // it with a sink that is also passed to rustc itself. When this function - // returns the output of the sink is copied onto the output of our own thread. - // - // The basic idea is to not use a default Handler for rustc, and then also - // not print things by default to the actual stderr. - struct Sink(Arc>>); - impl Write for Sink { - fn write(&mut self, data: &[u8]) -> io::Result { - Write::write(&mut *self.0.lock().unwrap(), data) - } - fn flush(&mut self) -> io::Result<()> { Ok(()) } + // Shuffle around a few input and output handles here. We're going to pass + // an explicit handle into rustc to collect output messages, but we also + // want to catch the error message that rustc prints when it fails. + // + // We take our thread-local stderr (likely set by the test runner) and replace + // it with a sink that is also passed to rustc itself. When this function + // returns the output of the sink is copied onto the output of our own thread. + // + // The basic idea is to not use a default Handler for rustc, and then also + // not print things by default to the actual stderr. + struct Sink(Arc>>); + impl Write for Sink { + fn write(&mut self, data: &[u8]) -> io::Result { + Write::write(&mut *self.0.lock().unwrap(), data) } - struct Bomb(Arc>>, Box); - impl Drop for Bomb { - fn drop(&mut self) { - let _ = self.1.write_all(&self.0.lock().unwrap()); - } + fn flush(&mut self) -> io::Result<()> { Ok(()) } + } + struct Bomb(Arc>>, Box); + impl Drop for Bomb { + fn drop(&mut self) { + let _ = self.1.write_all(&self.0.lock().unwrap()); } - let data = Arc::new(Mutex::new(Vec::new())); + } + let data = Arc::new(Mutex::new(Vec::new())); + + let old = io::set_panic(Some(box Sink(data.clone()))); + let _bomb = Bomb(data.clone(), old.unwrap_or(box io::stdout())); + + let (libdir, outdir) = driver::spawn_thread_pool(sessopts, |sessopts| { let codemap = Lrc::new(CodeMap::new_doctest( sessopts.file_path_mapping(), filename.clone(), line as isize - line_offset as isize )); @@ -264,8 +268,6 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize, Some(codemap.clone()), false, false); - let old = io::set_panic(Some(box Sink(data.clone()))); - let _bomb = Bomb(data.clone(), old.unwrap_or(box io::stdout())); // Compile the code let diagnostic_handler = errors::Handler::with_emitter(true, false, box emitter); From 7f0c8e4cde7bfb423488bdb54917741c04fb565b Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Mon, 9 Jul 2018 14:26:22 -0500 Subject: [PATCH 03/12] add ui test for failing doctest --- src/test/rustdoc-ui/failed-doctest-output.rs | 19 +++++++++++++++++ .../rustdoc-ui/failed-doctest-output.stdout | 21 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/test/rustdoc-ui/failed-doctest-output.rs create mode 100644 src/test/rustdoc-ui/failed-doctest-output.stdout 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 0000000000000..587a5def2ddb9 --- /dev/null +++ b/src/test/rustdoc-ui/failed-doctest-output.rs @@ -0,0 +1,19 @@ +// 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 or the MIT license +// , 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 + +// compile-flags:--test +// disable-ui-testing-normalization + +/// ``` +/// panic!("oh no"); +/// ``` +pub struct SomeStruct; 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 0000000000000..78cc0370d3141 --- /dev/null +++ b/src/test/rustdoc-ui/failed-doctest-output.stdout @@ -0,0 +1,21 @@ + +running 1 test +test src/test/rustdoc-ui/failed-doctest-output.rs - SomeStruct (line 16) ... FAILED + +failures: + +---- src/test/rustdoc-ui/failed-doctest-output.rs - SomeStruct (line 16) stdout ---- +thread 'src/test/rustdoc-ui/failed-doctest-output.rs - SomeStruct (line 16)' panicked at 'test executable failed: + +thread 'main' panicked at 'oh no', src/test/rustdoc-ui/failed-doctest-output.rs:3:1 +note: Run with `RUST_BACKTRACE=1` for a backtrace. + +', librustdoc/test.rs:367:17 +note: Run with `RUST_BACKTRACE=1` for a backtrace. + + +failures: + src/test/rustdoc-ui/failed-doctest-output.rs - SomeStruct (line 16) + +test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out + From 75d0a95bf85bc966c3444f935b36df549f2646c1 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Mon, 9 Jul 2018 19:11:06 -0500 Subject: [PATCH 04/12] report doctest compile failures correctly --- src/librustdoc/test.rs | 38 +++++++++---------- src/test/rustdoc-ui/failed-doctest-output.rs | 5 +++ .../rustdoc-ui/failed-doctest-output.stdout | 17 +++++++-- 3 files changed, 38 insertions(+), 22 deletions(-) diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index f47f70480f8b2..461785c8ff783 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -260,7 +260,7 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize, let old = io::set_panic(Some(box Sink(data.clone()))); let _bomb = Bomb(data.clone(), old.unwrap_or(box io::stdout())); - let (libdir, outdir) = driver::spawn_thread_pool(sessopts, |sessopts| { + let (libdir, outdir, compile_result) = driver::spawn_thread_pool(sessopts, |sessopts| { let codemap = Lrc::new(CodeMap::new_doctest( sessopts.file_path_mapping(), filename.clone(), line as isize - line_offset as isize )); @@ -312,28 +312,28 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize, Err(_) | Ok(Err(CompileIncomplete::Errored(_))) => Err(()) }; - match (compile_result, compile_fail) { - (Ok(()), true) => { - panic!("test compiled while it wasn't supposed to") - } - (Ok(()), false) => {} - (Err(()), true) => { - if error_codes.len() > 0 { - let out = String::from_utf8(data.lock().unwrap().to_vec()).unwrap(); - error_codes.retain(|err| !out.contains(err)); - } - } - (Err(()), false) => { - panic!("couldn't compile the test") + (libdir, outdir, compile_result) + }); + + match (compile_result, compile_fail) { + (Ok(()), true) => { + panic!("test compiled while it wasn't supposed to") + } + (Ok(()), false) => {} + (Err(()), true) => { + if error_codes.len() > 0 { + let out = String::from_utf8(data.lock().unwrap().to_vec()).unwrap(); + error_codes.retain(|err| !out.contains(err)); } } - - if error_codes.len() > 0 { - panic!("Some expected error codes were not found: {:?}", error_codes); + (Err(()), false) => { + panic!("couldn't compile the test") } + } - (libdir, outdir) - }); + if error_codes.len() > 0 { + panic!("Some expected error codes were not found: {:?}", error_codes); + } if no_run { return } diff --git a/src/test/rustdoc-ui/failed-doctest-output.rs b/src/test/rustdoc-ui/failed-doctest-output.rs index 587a5def2ddb9..21d3d94714abb 100644 --- a/src/test/rustdoc-ui/failed-doctest-output.rs +++ b/src/test/rustdoc-ui/failed-doctest-output.rs @@ -17,3 +17,8 @@ /// panic!("oh no"); /// ``` pub struct SomeStruct; + +/// ``` +/// no +/// ``` +pub struct OtherStruct; diff --git a/src/test/rustdoc-ui/failed-doctest-output.stdout b/src/test/rustdoc-ui/failed-doctest-output.stdout index 78cc0370d3141..08522d80225d1 100644 --- a/src/test/rustdoc-ui/failed-doctest-output.stdout +++ b/src/test/rustdoc-ui/failed-doctest-output.stdout @@ -1,9 +1,20 @@ -running 1 test +running 2 tests +test src/test/rustdoc-ui/failed-doctest-output.rs - OtherStruct (line 21) ... FAILED test src/test/rustdoc-ui/failed-doctest-output.rs - SomeStruct (line 16) ... FAILED failures: +---- src/test/rustdoc-ui/failed-doctest-output.rs - OtherStruct (line 21) stdout ---- +error[E0425]: cannot find value `no` in this scope + --> src/test/rustdoc-ui/failed-doctest-output.rs:22:1 + | +3 | no + | ^^ not found in this scope + +thread 'src/test/rustdoc-ui/failed-doctest-output.rs - OtherStruct (line 21)' panicked at 'couldn't compile the test', librustdoc/test.rs:332:13 +note: Run with `RUST_BACKTRACE=1` for a backtrace. + ---- src/test/rustdoc-ui/failed-doctest-output.rs - SomeStruct (line 16) stdout ---- thread 'src/test/rustdoc-ui/failed-doctest-output.rs - SomeStruct (line 16)' panicked at 'test executable failed: @@ -11,11 +22,11 @@ thread 'main' panicked at 'oh no', src/test/rustdoc-ui/failed-doctest-output.rs: note: Run with `RUST_BACKTRACE=1` for a backtrace. ', librustdoc/test.rs:367:17 -note: Run with `RUST_BACKTRACE=1` for a backtrace. failures: + src/test/rustdoc-ui/failed-doctest-output.rs - OtherStruct (line 21) src/test/rustdoc-ui/failed-doctest-output.rs - SomeStruct (line 16) -test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out +test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out From 6457f62b79616f7ee8a6045eb38659b2b6b033ae Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Mon, 9 Jul 2018 19:14:31 -0500 Subject: [PATCH 05/12] update stdout file with test path normalization --- .../rustdoc-ui/failed-doctest-output.stdout | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/test/rustdoc-ui/failed-doctest-output.stdout b/src/test/rustdoc-ui/failed-doctest-output.stdout index 08522d80225d1..e860079eb8162 100644 --- a/src/test/rustdoc-ui/failed-doctest-output.stdout +++ b/src/test/rustdoc-ui/failed-doctest-output.stdout @@ -1,32 +1,32 @@ running 2 tests -test src/test/rustdoc-ui/failed-doctest-output.rs - OtherStruct (line 21) ... FAILED -test src/test/rustdoc-ui/failed-doctest-output.rs - SomeStruct (line 16) ... FAILED +test $DIR/failed-doctest-output.rs - OtherStruct (line 21) ... FAILED +test $DIR/failed-doctest-output.rs - SomeStruct (line 16) ... FAILED failures: ----- src/test/rustdoc-ui/failed-doctest-output.rs - OtherStruct (line 21) stdout ---- +---- $DIR/failed-doctest-output.rs - OtherStruct (line 21) stdout ---- error[E0425]: cannot find value `no` in this scope - --> src/test/rustdoc-ui/failed-doctest-output.rs:22:1 + --> $DIR/failed-doctest-output.rs:22:1 | 3 | no | ^^ not found in this scope -thread 'src/test/rustdoc-ui/failed-doctest-output.rs - OtherStruct (line 21)' panicked at 'couldn't compile the test', librustdoc/test.rs:332:13 +thread '$DIR/failed-doctest-output.rs - OtherStruct (line 21)' panicked at 'couldn't compile the test', librustdoc/test.rs:332:13 note: Run with `RUST_BACKTRACE=1` for a backtrace. ----- src/test/rustdoc-ui/failed-doctest-output.rs - SomeStruct (line 16) stdout ---- -thread 'src/test/rustdoc-ui/failed-doctest-output.rs - SomeStruct (line 16)' panicked at 'test executable failed: +---- $DIR/failed-doctest-output.rs - SomeStruct (line 16) stdout ---- +thread '$DIR/failed-doctest-output.rs - SomeStruct (line 16)' panicked at 'test executable failed: -thread 'main' panicked at 'oh no', src/test/rustdoc-ui/failed-doctest-output.rs:3:1 +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: - src/test/rustdoc-ui/failed-doctest-output.rs - OtherStruct (line 21) - src/test/rustdoc-ui/failed-doctest-output.rs - SomeStruct (line 16) + $DIR/failed-doctest-output.rs - OtherStruct (line 21) + $DIR/failed-doctest-output.rs - SomeStruct (line 16) test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out From fb6e8f2433f5c6efe984f41bf6ecfd0b57031fee Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Mon, 16 Jul 2018 16:25:34 -0500 Subject: [PATCH 06/12] normalize test output so it can be run from repo root --- src/test/rustdoc-ui/failed-doctest-output.rs | 6 +++++- .../rustdoc-ui/failed-doctest-output.stdout | 18 +++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/test/rustdoc-ui/failed-doctest-output.rs b/src/test/rustdoc-ui/failed-doctest-output.rs index 21d3d94714abb..62cda9cb86bcb 100644 --- a/src/test/rustdoc-ui/failed-doctest-output.rs +++ b/src/test/rustdoc-ui/failed-doctest-output.rs @@ -9,15 +9,19 @@ // 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 -// disable-ui-testing-normalization +// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR" +// doctest fails at runtime /// ``` /// panic!("oh no"); /// ``` pub struct SomeStruct; +// doctest fails at compile time /// ``` /// no /// ``` diff --git a/src/test/rustdoc-ui/failed-doctest-output.stdout b/src/test/rustdoc-ui/failed-doctest-output.stdout index e860079eb8162..2ae633de12ebd 100644 --- a/src/test/rustdoc-ui/failed-doctest-output.stdout +++ b/src/test/rustdoc-ui/failed-doctest-output.stdout @@ -1,22 +1,22 @@ running 2 tests -test $DIR/failed-doctest-output.rs - OtherStruct (line 21) ... FAILED -test $DIR/failed-doctest-output.rs - SomeStruct (line 16) ... FAILED +test $DIR/failed-doctest-output.rs - OtherStruct (line 25) ... FAILED +test $DIR/failed-doctest-output.rs - SomeStruct (line 19) ... FAILED failures: ----- $DIR/failed-doctest-output.rs - OtherStruct (line 21) stdout ---- +---- $DIR/failed-doctest-output.rs - OtherStruct (line 25) stdout ---- error[E0425]: cannot find value `no` in this scope - --> $DIR/failed-doctest-output.rs:22:1 + --> $DIR/failed-doctest-output.rs:26:1 | 3 | no | ^^ not found in this scope -thread '$DIR/failed-doctest-output.rs - OtherStruct (line 21)' panicked at 'couldn't compile the test', librustdoc/test.rs:332:13 +thread '$DIR/failed-doctest-output.rs - OtherStruct (line 25)' 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 16) stdout ---- -thread '$DIR/failed-doctest-output.rs - SomeStruct (line 16)' panicked at 'test executable failed: +---- $DIR/failed-doctest-output.rs - SomeStruct (line 19) stdout ---- +thread '$DIR/failed-doctest-output.rs - SomeStruct (line 19)' 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. @@ -25,8 +25,8 @@ note: Run with `RUST_BACKTRACE=1` for a backtrace. failures: - $DIR/failed-doctest-output.rs - OtherStruct (line 21) - $DIR/failed-doctest-output.rs - SomeStruct (line 16) + $DIR/failed-doctest-output.rs - OtherStruct (line 25) + $DIR/failed-doctest-output.rs - SomeStruct (line 19) test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out From 2cca2f512cf31444b07da874ee458013cf30f1ea Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Thu, 19 Jul 2018 20:57:15 -0500 Subject: [PATCH 07/12] add failure-status to rustdoc doctest ui test --- src/test/rustdoc-ui/failed-doctest-output.rs | 1 + .../rustdoc-ui/failed-doctest-output.stdout | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/test/rustdoc-ui/failed-doctest-output.rs b/src/test/rustdoc-ui/failed-doctest-output.rs index 62cda9cb86bcb..62e495288cb9b 100644 --- a/src/test/rustdoc-ui/failed-doctest-output.rs +++ b/src/test/rustdoc-ui/failed-doctest-output.rs @@ -14,6 +14,7 @@ // compile-flags:--test // normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR" +// failure-status: 101 // doctest fails at runtime /// ``` diff --git a/src/test/rustdoc-ui/failed-doctest-output.stdout b/src/test/rustdoc-ui/failed-doctest-output.stdout index 2ae633de12ebd..cf417f8d412ee 100644 --- a/src/test/rustdoc-ui/failed-doctest-output.stdout +++ b/src/test/rustdoc-ui/failed-doctest-output.stdout @@ -1,22 +1,22 @@ running 2 tests -test $DIR/failed-doctest-output.rs - OtherStruct (line 25) ... FAILED -test $DIR/failed-doctest-output.rs - SomeStruct (line 19) ... FAILED +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 25) stdout ---- +---- $DIR/failed-doctest-output.rs - OtherStruct (line 26) stdout ---- error[E0425]: cannot find value `no` in this scope - --> $DIR/failed-doctest-output.rs:26:1 + --> $DIR/failed-doctest-output.rs:27:1 | 3 | no | ^^ not found in this scope -thread '$DIR/failed-doctest-output.rs - OtherStruct (line 25)' panicked at 'couldn't compile the test', librustdoc/test.rs:332:13 +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 19) stdout ---- -thread '$DIR/failed-doctest-output.rs - SomeStruct (line 19)' panicked at 'test executable failed: +---- $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. @@ -25,8 +25,8 @@ note: Run with `RUST_BACKTRACE=1` for a backtrace. failures: - $DIR/failed-doctest-output.rs - OtherStruct (line 25) - $DIR/failed-doctest-output.rs - SomeStruct (line 19) + $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 From 51847e32c0a0efb1cf0292dae5bcfb97ad9b84d0 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Fri, 20 Jul 2018 13:25:44 -0500 Subject: [PATCH 08/12] compiletest: don't overwrite failure-status if it was previously set --- src/tools/compiletest/src/header.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index f66f5c5b70e7e..4a2e98095adfe 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -396,6 +396,13 @@ impl TestProps { } }); + if self.failure_status == -1 { + self.failure_status = match config.mode { + Mode::RunFail => 101, + _ => 1, + }; + } + for key in &["RUST_TEST_NOCAPTURE", "RUST_TEST_THREADS"] { if let Ok(val) = env::var(key) { if self.exec_env.iter().find(|&&(ref x, _)| x == key).is_none() { From 425b5f4bd2adf4b00d7344dcfc382bc580092a32 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Tue, 24 Jul 2018 10:35:55 -0500 Subject: [PATCH 09/12] force the doctest rustc thread to share the name of the test --- src/librustc_driver/lib.rs | 22 +++++++++++++++++----- src/librustdoc/test.rs | 4 ++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 67fd5da8c92d9..dbb6cbaf78b20 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -1483,10 +1483,12 @@ fn parse_crate_attrs<'a>(sess: &'a Session, input: &Input) -> PResult<'a, Vec(f: F) -> Result> +/// Runs `f` in a suitable thread for running `rustc`; returns a `Result` with either the return +/// value of `f` or -- if a panic occurs -- the panic value. +/// +/// This version applies the given name to the thread. This is used by rustdoc to ensure consistent +/// doctest output across platforms and executions. +pub fn in_named_rustc_thread(name: String, f: F) -> Result> where F: FnOnce() -> R + Send + 'static, R: Send + 'static, { @@ -1530,7 +1532,7 @@ pub fn in_rustc_thread(f: F) -> Result> // The or condition is added from backward compatibility. if spawn_thread || env::var_os("RUST_MIN_STACK").is_some() { - let mut cfg = thread::Builder::new().name("rustc".to_string()); + let mut cfg = thread::Builder::new().name(name); // FIXME: Hacks on hacks. If the env is trying to override the stack size // then *don't* set it explicitly. @@ -1546,6 +1548,16 @@ pub fn in_rustc_thread(f: F) -> Result> } } +/// Runs `f` in a suitable thread for running `rustc`; returns a +/// `Result` with either the return value of `f` or -- if a panic +/// occurs -- the panic value. +pub fn in_rustc_thread(f: F) -> Result> + where F: FnOnce() -> R + Send + 'static, + R: Send + 'static, +{ + in_named_rustc_thread("rustc".to_string(), f) +} + /// Get a list of extra command-line flags provided by the user, as strings. /// /// This function is used during ICEs to show more information useful for diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 461785c8ff783..354729ff5e43d 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -548,7 +548,7 @@ impl Collector { debug!("Creating test {}: {}", name, test); self.tests.push(testing::TestDescAndFn { desc: testing::TestDesc { - name: testing::DynTestName(name), + name: testing::DynTestName(name.clone()), ignore: should_ignore, // compiler failures are test failures should_panic: testing::ShouldPanic::No, @@ -558,7 +558,7 @@ impl Collector { let panic = io::set_panic(None); let print = io::set_print(None); match { - rustc_driver::in_rustc_thread(move || with_globals(move || { + rustc_driver::in_named_rustc_thread(name, move || with_globals(move || { io::set_panic(panic); io::set_print(print); run_test(&test, From 0c72464b30eceb8f8432ea004a1986dd031788ef Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Wed, 25 Jul 2018 09:41:01 +0200 Subject: [PATCH 10/12] fix beta backport --- src/test/rustdoc-ui/failed-doctest-output.stdout | 4 ++-- src/tools/compiletest/src/header.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/rustdoc-ui/failed-doctest-output.stdout b/src/test/rustdoc-ui/failed-doctest-output.stdout index cf417f8d412ee..62f5f2566a6d6 100644 --- a/src/test/rustdoc-ui/failed-doctest-output.stdout +++ b/src/test/rustdoc-ui/failed-doctest-output.stdout @@ -12,7 +12,7 @@ error[E0425]: cannot find value `no` in this scope 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 +thread '$DIR/failed-doctest-output.rs - OtherStruct (line 26)' panicked at 'couldn't compile the test', librustdoc/test.rs:330:13 note: Run with `RUST_BACKTRACE=1` for a backtrace. ---- $DIR/failed-doctest-output.rs - SomeStruct (line 20) stdout ---- @@ -21,7 +21,7 @@ thread '$DIR/failed-doctest-output.rs - SomeStruct (line 20)' panicked at 'test 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 +', librustdoc/test.rs:365:17 failures: diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 4a2e98095adfe..ea06e87077a69 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -15,7 +15,7 @@ use std::io::BufReader; use std::path::{Path, PathBuf}; use common; -use common::Config; +use common::{Config, Mode}; use util; use extract_gdb_version; From b0f15d32b11e51c25fa708f50444d804c9e3dcdb Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 25 Jul 2018 10:55:22 -0700 Subject: [PATCH 11/12] beta: only true stage0 needs feature(global_allocator) We use `#[global_allocator]` for `stage0` builds of libstd, and also with `feature = "force_alloc_system"` that's set for a local rebuild, where the bootstrap compiler is the same version and otherwise uses the `--cfg stage1`. We only need the unstable `feature(global_allocator)` for a true `stage0` being 1.27. For rebuilds with 1.28, that feature is stable and causes a denied warning if it's enabled, so we should avoid it. --- src/libstd/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index a6061e96ae587..98ecd4f833dbf 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -331,9 +331,7 @@ // `force_alloc_system` is *only* intended as a workaround for local rebuilds // with a rustc without jemalloc. // FIXME(#44236) shouldn't need MSVC logic -#![cfg_attr(all(not(target_env = "msvc"), - any(all(stage0, not(test)), feature = "force_alloc_system")), - feature(global_allocator))] +#![cfg_attr(all(not(target_env = "msvc"), stage0, not(test)), feature(global_allocator))] #[cfg(all(not(target_env = "msvc"), any(all(stage0, not(test)), feature = "force_alloc_system")))] #[global_allocator] From 3fd32219b2a4cd377126bab2e30cd4595bf42290 Mon Sep 17 00:00:00 2001 From: kennytm Date: Thu, 26 Jul 2018 18:00:04 +0800 Subject: [PATCH 12/12] Run macOS jobs everywhere until Travis has fixed the problem. [skip ci] --- .travis.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2e6722cf85563..bc0c2886cd035 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,7 +36,6 @@ matrix: CI_JOB_NAME=dist-x86_64-apple-alt os: osx osx_image: xcode9.3-moar - if: branch = auto # macOS builders. These are placed near the beginning because they are very # slow to run. @@ -57,7 +56,6 @@ matrix: CI_JOB_NAME=x86_64-apple os: osx osx_image: xcode9.3-moar - if: branch = auto - env: > RUST_CHECK_TARGET=check @@ -71,7 +69,6 @@ matrix: CI_JOB_NAME=i686-apple os: osx osx_image: xcode9.3-moar - if: branch = auto # OSX builders producing releases. These do not run the full test suite and # just produce a bunch of artifacts. @@ -91,7 +88,6 @@ matrix: CI_JOB_NAME=dist-i686-apple os: osx osx_image: xcode9.3-moar - if: branch = auto - env: > RUST_CHECK_TARGET=dist @@ -105,7 +101,6 @@ matrix: CI_JOB_NAME=dist-x86_64-apple os: osx osx_image: xcode9.3-moar - if: branch = auto # Linux builders, remaining docker images - env: IMAGE=arm-android