Skip to content

Commit

Permalink
Pass ignore attribute to unsupported tests (#4360)
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda authored Dec 16, 2024
1 parent a4bc41b commit e250852
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
* Fixed passing large arrays into Rust failing because of internal memory allocations invalidating the memory buffer.
[#4353](https://github.com/rustwasm/wasm-bindgen/pull/4353)

* Pass along an `ignore` attribute to `unsupported` tests.
[#4360](https://github.com/rustwasm/wasm-bindgen/pull/4360)

--------------------------------------------------------------------------------

## [0.2.99](https://github.com/rustwasm/wasm-bindgen/compare/0.2.98...0.2.99)
Expand Down
18 changes: 15 additions & 3 deletions crates/test-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub fn wasm_bindgen_test(
None => quote! { ::core::option::Option::None },
};

let ignore = match ignore {
let ignore_par = match &ignore {
Some(Some(lit)) => {
quote! { ::core::option::Option::Some(::core::option::Option::Some(#lit)) }
}
Expand All @@ -89,9 +89,9 @@ pub fn wasm_bindgen_test(
};

let test_body = if attributes.r#async {
quote! { cx.execute_async(test_name, #ident, #should_panic_par, #ignore); }
quote! { cx.execute_async(test_name, #ident, #should_panic_par, #ignore_par); }
} else {
quote! { cx.execute_sync(test_name, #ident, #should_panic_par, #ignore); }
quote! { cx.execute_sync(test_name, #ident, #should_panic_par, #ignore_par); }
};

// We generate a `#[no_mangle]` with a known prefix so the test harness can
Expand Down Expand Up @@ -130,6 +130,18 @@ pub fn wasm_bindgen_test(
quote! { #[cfg_attr(not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "none"))), #should_panic)] }
)
}

if let Some(ignore) = ignore {
let ignore = if let Some(lit) = ignore {
quote! { ignore = #lit }
} else {
quote! { ignore }
};

tokens.extend(
quote! { #[cfg_attr(not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "none"))), #ignore)] }
)
}
}

tokens.extend(leading_tokens);
Expand Down

0 comments on commit e250852

Please sign in to comment.