Hi everyone. As I get more should_panic tests this issue gets more inconvinient. I'm looking for a way to disable panic stacktraces for should_panic tests (but keeping it for those who shouldn't panic!) but I've failed to do so.
Requirements are simple:
allow running test in multiple threads
simultaneosly do not show panic stacktraces from should_panic tests.
This is my best effort code which as you can imagine doesn't work since it's blinking and its output is different whenever test_a was running before test_b and test_c or not.
running 3 tests
test test_b ... FAILED
test test_a ... ok
test test_c ... FAILED
failures:
---- test_b stdout ----
thread 'test_b' panicked at 'wwoowow', src/lib.rs:14:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---- test_c stdout ----
thread 'test_c' panicked at 'wwoowow', src/lib.rs:19:5
failures:
test_b
test_c
It still show the stacktrace with cargo test -- --show-output which is default mode in cargo test command in IntelliJ-Rust. I really want some debug prints from tests but not panics form should_panic tests.
If you only care about those debug prints you can remove --show-output. The test harness will print it anyway for failed tests. Otherwise you got what you asked for. You asked for the output of tests even if they didn't fail, so you got saod output, including panic messages.
Consider I'm having two tests: one is one I'm currently debugging and I want to see its output. The other one is should_panic one and I don't want to see its output.
This is my situation and this is how I solve this.
Because I'm using IDEA and it defaults to --show-output when running all tests. And i'm always panicking myself when I see panics in output. This way I can use all default and feel myself safe from "oh no i broke something". it's also easier rather than making all new team members changing their IDE defaults to prevent this behvaior.