You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
running 1 test
test tests::test - should panic ... FAILED
failures:
---- tests::test stdout ----
thread 'tests::test' panicked at 'b', src/lib.rs:6:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
note: panic did not contain expected string
panic message: `"b"`,
expected substring: `"a"`
failures:
tests::test
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Instead, this happened:
running 1 test
test tests::test - should panic ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
My use-case is wanting to test a panic error message that contains an absolute path (which must be absolute due to the nature of what the error is trying to convey) which will vary based on what machine ran the test.
Since should_panic does not support globs/regex, I'm not able to test the whole error message, only the part up to the absolute path (or the part after it, but not both).
If function-like macros were supported here, I could use concat! + env!("CARGO_MANIFEST_DIR") etc to construct the absolute path in should_match's expected value.
I tried this code:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=1268154aa9d34acf6833b9affa7e6b81
I expected to see this happen:
Instead, this happened:
Changing
concat!("a")
to"a"
shows the expected error:https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=e0aa41c95b4cd19e82332b6f030987f5
The text was updated successfully, but these errors were encountered: