Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
49d78fc
Add GitHub issue templates
XAMPPRocky Jan 21, 2020
b846b42
Selectively disable sanitizer instrumentation
tmiasko Jan 12, 2020
1caa875
Apply LLVM sanitize attributes to generated entry wrapper
tmiasko Jan 16, 2020
80adde2
Add CodegenFnAttrFlags::NO_SANITIZE_ANY
tmiasko Feb 6, 2020
63980cd
Add a Hir wrapper type
Zoxc Feb 6, 2020
513e326
Add a `hir_krate` query
Zoxc Feb 6, 2020
20ce2f6
Move the `krate` method to Hir and remove the Krate dep node
Zoxc Feb 6, 2020
623dcb0
Remove the `Forest` type
Zoxc Feb 6, 2020
dc4fd3d
Comment tweaks
Zoxc Feb 6, 2020
a575495
Make `krate` private
Zoxc Feb 6, 2020
861b328
Respect --nocapture in panic=abort test mode
tmandry Feb 6, 2020
c39f209
Add myself to .mailmap
hanna-kruppe Feb 6, 2020
44edbc0
Remove HashStable impl for ast::Lifetime
Zoxc Feb 7, 2020
26020f5
clean up E0276 explanation
GuillaumeGomez Feb 7, 2020
2f1eaee
Rollup merge of #68164 - tmiasko:no-sanitize, r=nikomatsakis
Dylan-DPC Feb 7, 2020
f9ebad3
Rollup merge of #68413 - XAMPPRocky:master, r=Mark-Simulacrum
Dylan-DPC Feb 7, 2020
90f6267
Rollup merge of #68889 - Zoxc:hir-krate, r=eddyb
Dylan-DPC Feb 7, 2020
f734e47
Rollup merge of #68909 - tmandry:panic-abort-nocapture, r=alexcrichton
Dylan-DPC Feb 7, 2020
9047c57
Rollup merge of #68910 - hanna-kruppe:master, r=Mark-Simulacrum
Dylan-DPC Feb 7, 2020
88573a7
Rollup merge of #68919 - Zoxc:ast-lifetime, r=nikomatsakis
Dylan-DPC Feb 7, 2020
9681544
Rollup merge of #68928 - GuillaumeGomez:cleanup-e0276, r=Dylan-DPC
Dylan-DPC Feb 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Respect --nocapture in panic=abort test mode
  • Loading branch information
tmandry committed Feb 6, 2020
commit 861b328f7d62aebd1cfe381eb81bc7e80faf758e
26 changes: 17 additions & 9 deletions src/libtest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ use std::{
env, io,
io::prelude::Write,
panic::{self, catch_unwind, AssertUnwindSafe, PanicInfo},
process,
process::{Command, Termination},
process::{self, Command, Termination},
sync::mpsc::{channel, Sender},
sync::{Arc, Mutex},
thread,
Expand Down Expand Up @@ -457,9 +456,13 @@ pub fn run_test(
monitor_ch,
opts.time,
),
RunStrategy::SpawnPrimary => {
spawn_test_subprocess(desc, opts.time.is_some(), monitor_ch, opts.time)
}
RunStrategy::SpawnPrimary => spawn_test_subprocess(
desc,
opts.nocapture,
opts.time.is_some(),
monitor_ch,
opts.time,
),
};

// If the platform is single-threaded we're just going to run
Expand Down Expand Up @@ -558,6 +561,7 @@ fn run_test_in_process(

fn spawn_test_subprocess(
desc: TestDesc,
nocapture: bool,
report_time: bool,
monitor_ch: Sender<CompletedTest>,
time_opts: Option<time::TestTimeOptions>,
Expand All @@ -566,11 +570,15 @@ fn spawn_test_subprocess(
let args = env::args().collect::<Vec<_>>();
let current_exe = &args[0];

let mut command = Command::new(current_exe);
command.env(SECONDARY_TEST_INVOKER_VAR, desc.name.as_slice());
if nocapture {
command.stdout(process::Stdio::inherit());
command.stderr(process::Stdio::inherit());
}

let start = report_time.then(Instant::now);
let output = match Command::new(current_exe)
.env(SECONDARY_TEST_INVOKER_VAR, desc.name.as_slice())
.output()
{
let output = match command.output() {
Ok(out) => out,
Err(e) => {
let err = format!("Failed to spawn {} as child for test: {:?}", args[0], e);
Expand Down
39 changes: 39 additions & 0 deletions src/test/ui/test-panic-abort-nocapture.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// no-prefer-dynamic
// compile-flags: --test -Cpanic=abort -Zpanic_abort_tests
// run-flags: --test-threads=1 --nocapture
// run-fail
// check-run-results
// exec-env:RUST_BACKTRACE=0

// ignore-wasm no panic or subprocess support
// ignore-emscripten no panic or subprocess support

#![cfg(test)]

use std::io::Write;

#[test]
fn it_works() {
println!("about to succeed");
assert_eq!(1 + 1, 2);
}

#[test]
#[should_panic]
fn it_panics() {
println!("about to panic");
assert_eq!(1 + 1, 4);
}

#[test]
fn it_fails() {
println!("about to fail");
assert_eq!(1 + 1, 4);
}

#[test]
fn it_writes_to_stdio() {
println!("hello, world");
writeln!(std::io::stdout(), "testing123").unwrap();
writeln!(std::io::stderr(), "testing321").unwrap();
}
9 changes: 9 additions & 0 deletions src/test/ui/test-panic-abort-nocapture.run.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `2`,
right: `4`', $DIR/test-panic-abort-nocapture.rs:31:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `2`,
right: `4`', $DIR/test-panic-abort-nocapture.rs:25:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
testing321
23 changes: 23 additions & 0 deletions src/test/ui/test-panic-abort-nocapture.run.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

running 4 tests
test it_fails ... about to fail
FAILED
test it_panics ... about to panic
ok
test it_works ... about to succeed
ok
test it_writes_to_stdio ... hello, world
testing123
ok

failures:

---- it_fails stdout ----
---- it_fails stderr ----


failures:
it_fails

test result: FAILED. 3 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out