Adjust test directives
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
This commit is contained in:
parent
c73598f0fb
commit
dc3a586eed
4 changed files with 23 additions and 33 deletions
|
@ -1,9 +1,12 @@
|
|||
//@ compile-flags: --test
|
||||
//@ run-flags: --test-threads=1 --nocapture
|
||||
//@ run-fail
|
||||
//@ check-run-results
|
||||
//@ compile-flags: --test
|
||||
//@ exec-env:RUST_BACKTRACE=0
|
||||
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
|
||||
//@ run-flags: --test-threads=1
|
||||
//@ normalize-stdout: "TypeId\(0x[0-9a-f]+\)" -> "TypeId($$HEX)"
|
||||
//@ needs-threads
|
||||
//@ needs-unwind (panic)
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
|
@ -37,6 +40,7 @@ fn should_panic_with_substring_panics_with_incorrect_string() {
|
|||
|
||||
#[test]
|
||||
#[should_panic = "message"]
|
||||
#[expect(non_fmt_panics)]
|
||||
fn should_panic_with_substring_panics_with_non_string_value() {
|
||||
panic!(123); //~ WARNING panic message is not a string literal
|
||||
panic!(123);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
thread 'should_panic_with_any_message' panicked at $DIR/test-should-panic-failed-show-span.rs:14:5:
|
||||
Panic!
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
|
||||
thread 'should_panic_with_message' panicked at $DIR/test-should-panic-failed-show-span.rs:20:5:
|
||||
message
|
||||
|
||||
thread 'should_panic_with_substring_panics_with_incorrect_string' panicked at $DIR/test-should-panic-failed-show-span.rs:38:5:
|
||||
ZOMGWTFBBQ
|
||||
|
||||
thread 'should_panic_with_substring_panics_with_non_string_value' panicked at $DIR/test-should-panic-failed-show-span.rs:45:5:
|
||||
Box<dyn Any>
|
|
@ -10,22 +10,16 @@ test should_panic_with_substring_panics_with_non_string_value - should panic ...
|
|||
failures:
|
||||
|
||||
---- should_panic_with_any_message_does_not_panic stdout ----
|
||||
note: test did not panic as expected at $DIR/test-should-panic-failed-show-span.rs:22:4
|
||||
note: test did not panic as expected at $DIR/test-should-panic-failed-show-span.rs:25:4
|
||||
---- should_panic_with_message_does_not_panic stdout ----
|
||||
note: test did not panic as expected at $DIR/test-should-panic-failed-show-span.rs:28:4
|
||||
note: test did not panic as expected at $DIR/test-should-panic-failed-show-span.rs:31:4
|
||||
---- should_panic_with_substring_panics_with_incorrect_string stdout ----
|
||||
|
||||
thread 'should_panic_with_substring_panics_with_incorrect_string' panicked at $DIR/test-should-panic-failed-show-span.rs:35:5:
|
||||
ZOMGWTFBBQ
|
||||
note: panic did not contain expected string
|
||||
panic message: `"ZOMGWTFBBQ"`,
|
||||
expected substring: `"message"`
|
||||
---- should_panic_with_substring_panics_with_non_string_value stdout ----
|
||||
|
||||
thread 'should_panic_with_substring_panics_with_non_string_value' panicked at $DIR/test-should-panic-failed-show-span.rs:41:5:
|
||||
Box<dyn Any>
|
||||
note: expected panic with string value,
|
||||
found non-string value: `TypeId(0x56ced5e4a15bd89050bb9674fa2df013)`
|
||||
found non-string value: `TypeId($HEX)`
|
||||
expected substring: `"message"`
|
||||
|
||||
failures:
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
warning: panic message is not a string literal
|
||||
--> $DIR/test-should-panic-failed-show-span.rs:41:12
|
||||
|
|
||||
LL | panic!(123);
|
||||
| ^^^
|
||||
|
|
||||
= note: this usage of `panic!()` is deprecated; it will be a hard error in Rust 2021
|
||||
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
|
||||
= note: `#[warn(non_fmt_panics)]` on by default
|
||||
help: add a "{}" format string to `Display` the message
|
||||
|
|
||||
LL | panic!("{}", 123);
|
||||
| +++++
|
||||
help: or use std::panic::panic_any instead
|
||||
|
|
||||
LL - panic!(123);
|
||||
LL + std::panic::panic_any(123);
|
||||
|
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue