Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
format: render stack traces in results
Now when a test fails, we get output like the below, which allows us to see where things actually went wrong. This is a bit fugly because it displays the stack trace twice. This is because we're using thiserror which doesn't really provide us a nice way to override Display implementations (perhaps we should just hand craft those, but then what's the point of the macro?). This also requires us to use nightly, because std::backtrace and related functionality are not in stable yet. Hopefully they will arrive soon. (I did not add in all the macro tests for feature, since we don't necessarily care about building on stable right now...) Anyway, let's say this: Fixes project-machine#22 for now. Hopefully someone can come along in 6 months when the situation looks better and make things prettier, but for now this at least gives us functional backtraces. test tests::test_put_blob_correct_hash ... ok thread 'index::tests::test_can_open_new_index' panicked at 'called `Result::unwrap()` on an `Err` value: invalid image schema: -1 0: oci::index::Index::open at ./src/index.rs:46:68 1: oci::index::tests::test_can_open_new_index at ./src/index.rs:74:9 2: oci::index::tests::test_can_open_new_index::{{closure}} at ./src/index.rs:70:5 3: core::ops::function::FnOnce::call_once at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/core/src/ops/function.rs:227:5 4: core::ops::function::FnOnce::call_once at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/core/src/ops/function.rs:227:5 test::__rust_begin_short_backtrace at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/test/src/lib.rs:576:5 5: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/alloc/src/boxed.rs:1546:9 <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panic.rs:344:9 std::panicking::try::do_call at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panicking.rs:379:40 std::panicking::try at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panicking.rs:343:19 std::panic::catch_unwind at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panic.rs:431:14 test::run_test_in_process at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/test/src/lib.rs:599:18 test::run_test::run_test_inner::{{closure}} at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/test/src/lib.rs:491:39 6: test::run_test::run_test_inner::{{closure}} at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/test/src/lib.rs:518:37 std::sys_common::backtrace::__rust_begin_short_backtrace at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/sys_common/backtrace.rs:125:18 7: std::thread::Builder::spawn_unchecked::{{closure}}::{{closure}} at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/thread/mod.rs:474:17 <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panic.rs:344:9 std::panicking::try::do_call at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panicking.rs:379:40 std::panicking::try at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panicking.rs:343:19 std::panic::catch_unwind at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panic.rs:431:14 std::thread::Builder::spawn_unchecked::{{closure}} at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/thread/mod.rs:473:30 core::ops::function::FnOnce::call_once{{vtable.shim}} at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/core/src/ops/function.rs:227:5 8: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/alloc/src/boxed.rs:1546:9 <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/alloc/src/boxed.rs:1546:9 std::sys::unix::thread::Thread::new::thread_start at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/sys/unix/thread.rs:71:17 9: start_thread 10: clone ', oci/src/index.rs:74:45 stack backtrace: thread 'tests::test_put_get_index' panicked at 'called `Result::unwrap()` on an `Err` value: invalid image schema: -1 0: oci::index::Index::open at ./src/index.rs:46:68 1: oci::Image::get_index at ./src/lib.rs:130:9 2: oci::tests::test_put_get_index at ./src/lib.rs:186:22 3: oci::tests::test_put_get_index::{{closure}} at ./src/lib.rs:173:5 4: core::ops::function::FnOnce::call_once at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/core/src/ops/function.rs:227:5 5: core::ops::function::FnOnce::call_once at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/core/src/ops/function.rs:227:5 test::__rust_begin_short_backtrace at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/test/src/lib.rs:576:5 6: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/alloc/src/boxed.rs:1546:9 <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panic.rs:344:9 std::panicking::try::do_call at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panicking.rs:379:40 std::panicking::try at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panicking.rs:343:19 std::panic::catch_unwind at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panic.rs:431:14 test::run_test_in_process at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/test/src/lib.rs:599:18 test::run_test::run_test_inner::{{closure}} at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/test/src/lib.rs:491:39 7: test::run_test::run_test_inner::{{closure}} at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/test/src/lib.rs:518:37 std::sys_common::backtrace::__rust_begin_short_backtrace at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/sys_common/backtrace.rs:125:18 8: std::thread::Builder::spawn_unchecked::{{closure}}::{{closure}} at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/thread/mod.rs:474:17 <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panic.rs:344:9 std::panicking::try::do_call at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panicking.rs:379:40 std::panicking::try at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panicking.rs:343:19 std::panic::catch_unwind at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panic.rs:431:14 std::thread::Builder::spawn_unchecked::{{closure}} at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/thread/mod.rs:473:30 core::ops::function::FnOnce::call_once{{vtable.shim}} at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/core/src/ops/function.rs:227:5 9: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/alloc/src/boxed.rs:1546:9 <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/alloc/src/boxed.rs:1546:9 std::sys::unix::thread::Thread::new::thread_start at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/sys/unix/thread.rs:71:17 10: start_thread 11: clone ', oci/src/lib.rs:186:41 0: rust_begin_unwind at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panicking.rs:493:5 1: core::panicking::panic_fmt at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/core/src/panicking.rs:92:14 2: core::result::unwrap_failed at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/core/src/result.rs:1355:5 3: core::result::Result<T,E>::unwrap at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/core/src/result.rs:1037:23 4: oci::index::tests::test_can_open_new_index at ./src/index.rs:74:9 5: oci::index::tests::test_can_open_new_index::{{closure}} at ./src/index.rs:70:5 6: core::ops::function::FnOnce::call_once at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/core/src/ops/function.rs:227:5 7: core::ops::function::FnOnce::call_once at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/core/src/ops/function.rs:227:5 note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. stack backtrace: 0: rust_begin_unwind at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/std/src/panicking.rs:493:5 1: core::panicking::panic_fmt at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/core/src/panicking.rs:92:14 2: core::result::unwrap_failed at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/core/src/result.rs:1355:5 3: core::result::Result<T,E>::unwrap at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/core/src/result.rs:1037:23 4: oci::tests::test_put_get_index at ./src/lib.rs:186:22 5: oci::tests::test_put_get_index::{{closure}} at ./test index::tests::test_can_open_new_index ... src/lib.rs:FAILED173:5 6: core::ops::function::FnOnce::call_once at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/core/src/ops/function.rs:227:5 7: core::ops::function::FnOnce::call_once at /rustc/132b4e5d167b7e622fcc11fa2b67b931105b4de1/library/core/src/ops/function.rs:227:5 note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. Signed-off-by: Tycho Andersen <tycho@tycho.pizza>
- Loading branch information