Skip to content

Commit 9512b55

Browse files
sterlingjensendjc
authored andcommitted
Silence only panics that expect panic
On panic, evaluate the test case for the expected panic flag, silence if so flagged.
1 parent 6f2402b commit 9512b55

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

data-url/tests/wpt.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
#[macro_use]
22
extern crate serde;
33

4-
fn run_data_url(input: String, expected_mime: Option<String>, expected_body: Option<Vec<u8>>) {
4+
fn run_data_url(
5+
input: String,
6+
expected_mime: Option<String>,
7+
expected_body: Option<Vec<u8>>,
8+
expected_panic: bool,
9+
) {
10+
let priorhook = std::panic::take_hook();
11+
std::panic::set_hook(Box::new(move |p| {
12+
if !expected_panic {
13+
priorhook(p);
14+
}
15+
}));
516
let url = data_url::DataUrl::process(&input);
617
if let Some(expected_mime) = expected_mime {
718
let url = url.unwrap();
@@ -43,7 +54,7 @@ where
4354
format!("data: URL {:?}", input),
4455
should_panic,
4556
rustc_test::TestFn::dyn_test_fn(move || {
46-
run_data_url(input, expected_mime, expected_body)
57+
run_data_url(input, expected_mime, expected_body, should_panic)
4758
}),
4859
);
4960
}

0 commit comments

Comments
 (0)