-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement #[should_panic(expected = "...")]
handling
#3293
Conversation
2ac981f
to
2357053
Compare
2357053
to
77ce92d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for implementing this! This is a welcome addition
Looking through the code, I don't see tests for the failing case where the test should panic but actually doesn't. It would be great to have tests for that.
I can't find a place for failing tests. |
CI is failing for unrelated reasons. |
#[wasm_bindgen_test] | ||
#[should_panic] | ||
async fn should_panic() { | ||
panic!() | ||
} | ||
|
||
#[wasm_bindgen_test] | ||
#[should_panic = "error message"] | ||
async fn should_panic_string() { | ||
panic!("error message") | ||
} | ||
|
||
#[wasm_bindgen_test] | ||
#[should_panic(expected = "error message")] | ||
async fn should_panic_expected() { | ||
panic!("error message") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these tests a part of wasm-bindgen-futures
's test suite?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was testing it with async functions to make sure that the parsing is correct.
3de85ce
to
542ba73
Compare
542ba73
to
d917ae4
Compare
490bc52
to
2804245
Compare
352238f
to
135f8b7
Compare
36b972a
to
b596082
Compare
b596082
to
76469b3
Compare
Co-Authored-By: Liam Murphy <43807659+Liamolucko@users.noreply.github.com>
16193f6
to
8e0a9d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Apparently, rustwasm#3293 didn't quite update them properly, causing CI to fail. I'm not sure why CI passed when checking the PR but failed on `main`, but this should fix the CI failure.
* Update expected results for UI tests Apparently, #3293 didn't quite update them properly, causing CI to fail. I'm not sure why CI passed when checking the PR but failed on `main`, but this should fix the CI failure. * Use updated trybuild It looks like trybuild moved where it puts its output, and so CI's up-to-date trybuild and my older local trybuild disagreed on what a path should be.
Catching panics was already in place, it was just a matter of properly parsing
should_panic
and printing the correct error messages.I tried to stay as close as possible to the output Rust gives.
EDIT:
I found out later that there was no proper way to "only" get the panic message, so I just customized the panic hook to store any panic message in the thread local output we already had around.
Fixes #2286.