diff options
| author | bors <bors@rust-lang.org> | 2017-05-10 11:37:22 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-05-10 11:37:22 +0000 |
| commit | 25a161765fb90f2bfc78bda8fef944048e72bd26 (patch) | |
| tree | 0dc21722451293bbedf2367b1fea0fa06c112bb7 /src/libtest | |
| parent | 2b97174ada7fb1854269558ed2cf3b089e58beee (diff) | |
| parent | ca8b75466cef854d30fdf7614c2358b1eb46816e (diff) | |
| download | rust-25a161765fb90f2bfc78bda8fef944048e72bd26.tar.gz rust-25a161765fb90f2bfc78bda8fef944048e72bd26.zip | |
Auto merge of #41815 - Yamakaky:improve-backtrace-bottom, r=alexcrichton
Improve cleaning of the bottom of the backtrace Following https://github.com/rust-lang/rust/pull/40264. It only cleans the bottom of the trace (after the main). It handles correctly the normal main, tests, benchmarks and threads. I kept `skipped_before` since it will be used later for the cleaning of the top.
Diffstat (limited to 'src/libtest')
| -rw-r--r-- | src/libtest/lib.rs | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 35f2fbca69f..0d615db3deb 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -1314,12 +1314,16 @@ pub fn convert_benchmarks_to_tests(tests: Vec<TestDescAndFn>) -> Vec<TestDescAnd let testfn = match x.testfn { DynBenchFn(bench) => { DynTestFn(Box::new(move |()| { - bench::run_once(|b| bench.run(b)) + bench::run_once(|b| { + __rust_begin_short_backtrace(|| bench.run(b)) + }) })) } StaticBenchFn(benchfn) => { DynTestFn(Box::new(move |()| { - bench::run_once(|b| benchfn(b)) + bench::run_once(|b| { + __rust_begin_short_backtrace(|| benchfn(b)) + }) })) } f => f, @@ -1425,12 +1429,24 @@ pub fn run_test(opts: &TestOpts, monitor_ch.send((desc, TrMetrics(mm), Vec::new())).unwrap(); return; } - DynTestFn(f) => run_test_inner(desc, monitor_ch, opts.nocapture, f), - StaticTestFn(f) => run_test_inner(desc, monitor_ch, opts.nocapture, - Box::new(move |()| f())), + DynTestFn(f) => { + let cb = move |()| { + __rust_begin_short_backtrace(|| f.call_box(())) + }; + run_test_inner(desc, monitor_ch, opts.nocapture, Box::new(cb)) + } + StaticTestFn(f) => + run_test_inner(desc, monitor_ch, opts.nocapture, + Box::new(move |()| __rust_begin_short_backtrace(f))), } } +/// Fixed frame used to clean the backtrace with `RUST_BACKTRACE=1`. +#[inline(never)] +fn __rust_begin_short_backtrace<F: FnOnce()>(f: F) { + f() +} + fn calc_result(desc: &TestDesc, task_result: Result<(), Box<Any + Send>>) -> TestResult { match (&desc.should_panic, task_result) { (&ShouldPanic::No, Ok(())) | |
