Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-3910

[Rust] Replace `color-backtrace` with `better-panic` for the tests

    XMLWordPrintableJSON

Details

    Description

      Replace the usage of `color-backtrace` for formatting the stacktrace/backtrace with `better-panic` crate.

       

      color-backtrace produces something like:

       running 1 test
      The application panicked (crashed).
      Message:  called `Result::unwrap()` on an `Err` value: VariantNotFound
      Location: avro/src/codec.rs:288Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
      Run with RUST_BACKTRACE=full to include source snippets.
      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                    ⋮ 11 frames hidden ⋮                              
      12: core::result::Result<T,E>::unwrap::h42875ca1fbe01988
          at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/result.rs:1077
      13: apache_avro::codec::tests::blah_codec_from_str::h31a897f50d0646ef
          at /home/martin/git/apache/avro/lang/rust/avro/src/codec.rs:288
      14: apache_avro::codec::tests::blah_codec_from_str::{{closure}}::hd50971d27dbdf844
          at /home/martin/git/apache/avro/lang/rust/avro/src/codec.rs:285
      15: core::ops::function::FnOnce::call_once::he1a6a7003e894c20
          at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/ops/function.rs:250
      16: core::ops::function::FnOnce::call_once::heaa6bd10e636ddeb
          at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/ops/function.rs:250
      17: test::__rust_begin_short_backtrace::h648a8e2968228ae1
          at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/test/src/lib.rs:626
      18: test::run_test_in_process::{{closure}}::h6f41f9e0cb0e01f3
          at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/test/src/lib.rs:649
      19: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::hdd10d814e6f87879
          at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/core/src/panic/unwind_safe.rs:271
      20: std::panicking::try::do_call::heb49837323e0a108
          at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:504
      21: std::panicking::try::h1c76451ee4678b45
          at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panicking.rs:468
      22: std::panic::catch_unwind::h4b3292a1ebe68a9f
          at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/std/src/panic.rs:142
      23: test::run_test_in_process::h199922650f75555c
          at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/test/src/lib.rs:649
      24: test::run_test::{{closure}}::hb30d8c3830867614
          at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/test/src/lib.rs:572
      25: test::run_test::{{closure}}::hb1d502edb82ef10a
          at /rustc/79e9716c980570bfd1f666e3b16ac583f0168962/library/test/src/lib.rs:600
                                    ⋮ 13 frames hidden ⋮                              
      test codec::tests::blah_codec_from_str ... FAILED
      

       

      better-panic produces:

       running 1 test
      Backtrace (most recent call first):
        File "rust:library/core/src/result.rs", line 1077, in core::result::Result<T,E>::unwrap
        File "/home/martin/git/apache/avro/lang/rust/avro/src/codec.rs", line 288, in apache_avro::codec::tests::blah_codec_from_str
          Codec::from_str("not a codec").unwrap();
        File "/home/martin/git/apache/avro/lang/rust/avro/src/codec.rs", line 285, in apache_avro::codec::tests::blah_codec_from_str::{{closure}}
          fn blah_codec_from_str() {
        File "rust:library/core/src/ops/function.rs", line 250, in core::ops::function::FnOnce::call_once
        File "rust:library/core/src/ops/function.rs", line 250, in core::ops::function::FnOnce::call_once
        File "rust:library/test/src/lib.rs", line 626, in test::__rust_begin_short_backtrace
        File "rust:library/test/src/lib.rs", line 649, in test::run_test_in_process::{{closure}}
        File "rust:library/core/src/panic/unwind_safe.rs", line 271, in <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
        File "rust:library/std/src/panicking.rs", line 504, in std::panicking::try::do_call
        File "rust:library/std/src/panicking.rs", line 468, in std::panicking::try
        File "rust:library/std/src/panic.rs", line 142, in std::panic::catch_unwind
        File "rust:library/test/src/lib.rs", line 649, in test::run_test_in_process
        File "rust:library/test/src/lib.rs", line 572, in test::run_test::{{closure}}
        File "rust:library/test/src/lib.rs", line 600, in test::run_test::{{closure}}
        File "rust:library/std/src/sys_common/backtrace.rs", line 154, in std::sys_common::backtrace::__rust_begin_short_backtrace
        File "rust:library/std/src/thread/mod.rs", line 529, in std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}
        File "rust:library/core/src/panic/unwind_safe.rs", line 271, in <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
        File "rust:library/std/src/panicking.rs", line 504, in std::panicking::try::do_call
        File "rust:library/std/src/panicking.rs", line 468, in std::panicking::try
        File "rust:library/std/src/panic.rs", line 142, in std::panic::catch_unwind
        File "rust:library/std/src/thread/mod.rs", line 528, in std::thread::Builder::spawn_unchecked_::{{closure}}
        File "rust:library/core/src/ops/function.rs", line 250, in core::ops::function::FnOnce::call_once{{vtable.shim}}
        File "rust:library/alloc/src/boxed.rs", line 2007, in <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
        File "rust:library/alloc/src/boxed.rs", line 2007, in <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
        File "rust:library/std/src/sys/unix/thread.rs", line 108, in std::sys::unix::thread::Thread::new::thread_start
        File "./nptl/./nptl/pthread_create.c", line 442, in start_thread
        File "./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S", line 81, in clone3The application panicked (crashed).
        called `Result::unwrap()` on an `Err` value: VariantNotFound
      in avro/src/codec.rs, line 288
      thread: codec::tests::blah_codec_from_str
      test codec::tests::blah_codec_from_str ... FAILED
      

       

      The benefits of using better-panic are:

      • it shows a snippet of the source code with the failure
      • it is configurable what to print

      Attachments

        Issue Links

          Activity

            People

              mgrigorov Martin Tzvetanov Grigorov
              mgrigorov Martin Tzvetanov Grigorov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m