From d8f8657886b08e1eb6cea9da4773ee18aa63d088 Mon Sep 17 00:00:00 2001 From: "Aode (lion)" Date: Sun, 26 Dec 2021 11:49:29 -0600 Subject: [PATCH] Fix tests (these seem very brittle) --- examples/theme_test_helper.rs | 2 +- tests/data/theme_error_control.txt | 68 +++++++++++++++--------------- tests/data/theme_panic_control.txt | 18 ++++---- 3 files changed, 45 insertions(+), 43 deletions(-) diff --git a/examples/theme_test_helper.rs b/examples/theme_test_helper.rs index 17cd24e..d142081 100644 --- a/examples/theme_test_helper.rs +++ b/examples/theme_test_helper.rs @@ -34,7 +34,7 @@ fn main() { let span = tracing::info_span!("get_error", msg); let _guard = span.enter(); let error = get_error(msg); - panic!(error) + std::panic::panic_any(error) } fn setup() { diff --git a/tests/data/theme_error_control.txt b/tests/data/theme_error_control.txt index e6876ac..daf7dfa 100644 --- a/tests/data/theme_error_control.txt +++ b/tests/data/theme_error_control.txt @@ -2,49 +2,49 @@ 0: test Location: - tests/theme.rs:1 + tests/theme.rs:17 Error: 0: error ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ SPANTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - 0: theme::get_error with msg="test" + + 0: theme::get_error with msg="test" at tests/theme.rs:11 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  ⋮ 5 frames hidden ⋮  - 6: theme::get_error::create_report::h982c27931cc8e4b1 - at : - 7: theme::get_error::{{closure}}::hae775e99e0b7d1c5 - at : - 8: core::option::Option::ok_or_else::hd4b57a8cb5c1870b - at /home/jlusby/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:558 - 9: theme::get_error::hfc71373d92f563f0 - at /home/jlusby/git/yaahc/color-eyre/tests/theme.rs:1 - 10: theme::test_error_backwards_compatibility::h4bf087e5e689a5d0 - at /home/jlusby/git/yaahc/color-eyre/tests/theme.rs:36 - 11: theme::test_error_backwards_compatibility::{{closure}}::hf172868901d86cb0 - at /home/jlusby/git/yaahc/color-eyre/tests/theme.rs:34 - 12: core::ops::function::FnOnce::call_once::h9b87751ef643fe90 - at /home/jlusby/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227 - 13: core::ops::function::FnOnce::call_once::hb2ff33e91aac5799 - at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/ops/function.rs:227 - 14: test::__rust_begin_short_backtrace::hc8fd71b19bc78390 - at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/test/src/lib.rs:516 - 15:  as core::ops::function::FnOnce>::call_once::hb8ab4b7e0de41b66 - at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/alloc/src/boxed.rs:1042 - 16:  as core::ops::function::FnOnce<()>>::call_once::hc48829c2ba8b55d6 - at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panic.rs:308 - 17: std::panicking::try::do_call::h95feedb4d9e8dd5b - at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:381 - 18: std::panicking::try::hc4c23f5f7d3bdd43 - at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:345 - 19: std::panic::catch_unwind::hf3a57d903cc5007a - at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panic.rs:382 - 20: test::run_test_in_process::h09c598ed2a1f6695 - at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/test/src/lib.rs:543 -  ⋮ 14 frames hidden ⋮  + 6: theme::get_error::create_report::hd9d97e4e76dee44c + at /home/asonix/Development/rust/color-eyre/tests/theme.rs:17 + 7: theme::get_error::{{closure}}::h4cc7ce7893f295cb + at /home/asonix/Development/rust/color-eyre/tests/theme.rs:25 + 8: core::option::Option::ok_or_else::hc00ef515ea43ef82 + at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/option.rs:954 + 9: theme::get_error::haf4b483cac8d076b + at /home/asonix/Development/rust/color-eyre/tests/theme.rs:25 + 10: theme::test_error_backwards_compatibility::hf4c9eaf012b11366 + at /home/asonix/Development/rust/color-eyre/tests/theme.rs:43 + 11: theme::test_error_backwards_compatibility::{{closure}}::h972249b6ebd599cb + at /home/asonix/Development/rust/color-eyre/tests/theme.rs:41 + 12: core::ops::function::FnOnce::call_once::h8855848bc65b81ec + at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/ops/function.rs:227 + 13: core::ops::function::FnOnce::call_once::h83cc023b85256d97 + at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/ops/function.rs:227 + 14: test::__rust_begin_short_backtrace::h7330e4e8b0549e26 + at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/test/src/lib.rs:585 + 15:  as core::ops::function::FnOnce>::call_once::h6b77566b8f386abb + at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/alloc/src/boxed.rs:1691 + 16:  as core::ops::function::FnOnce<()>>::call_once::h2ad5de64df41b71c + at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panic/unwind_safe.rs:271 + 17: std::panicking::try::do_call::he67b1e56b423a618 + at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:403 + 18: std::panicking::try::ha9224adcdd41a723 + at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:367 + 19: std::panic::catch_unwind::h9111b58ae0b27828 + at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panic.rs:133 + 20: test::run_test_in_process::h15b6b7d5919893aa + at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/test/src/lib.rs:608 +  ⋮ 15 frames hidden ⋮  Note: note Warning: warning diff --git a/tests/data/theme_panic_control.txt b/tests/data/theme_panic_control.txt index 3deef72..1ee72f4 100644 --- a/tests/data/theme_panic_control.txt +++ b/tests/data/theme_panic_control.txt @@ -1,21 +1,23 @@ - Finished dev [unoptimized + debuginfo] target(s) in 0.03s + Finished dev [unoptimized + debuginfo] target(s) in 0.02s Running `target/debug/examples/theme_test_helper` The application panicked (crashed). Message:  Location: examples/theme_test_helper.rs:37 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ SPANTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - 0: theme_test_helper::get_error with msg="test" + + 0: theme_test_helper::get_error with msg="test" at examples/theme_test_helper.rs:34 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  ⋮ 6 frames hidden ⋮  - 7: theme_test_helper::main::h0f7f307e00efc098 - at /home/jlusby/git/yaahc/color-eyre/examples/theme_test_helper.rs:37 - 8: core::ops::function::FnOnce::call_once::hc90fd75bf8c9f979 - at /home/jlusby/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227 -  ⋮ 11 frames hidden ⋮  + 7: std::panic::panic_any::hdb02375f91faf2b1 + at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panic.rs:57 + 8: theme_test_helper::main::hc643d5b602546a09 + at /home/asonix/Development/rust/color-eyre/examples/theme_test_helper.rs:37 + 9: core::ops::function::FnOnce::call_once::hb05b32a2aa2386ee + at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/ops/function.rs:227 +  ⋮ 15 frames hidden ⋮  Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering. Run with RUST_BACKTRACE=full to include source snippets.