Skip to content

Commit

Permalink
Fix triggering lints in testing facilities (#4195)
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda authored Oct 13, 2024
1 parent 5e98a17 commit 3b46cbe
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 31 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
* Fixed unused string enums generating JS values.
[#4193](https://github.com/rustwasm/wasm-bindgen/pull/4193)

* Fixed triggering lints in testing facilities.
[#4195](https://github.com/rustwasm/wasm-bindgen/pull/4195)

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

## [0.2.95](https://github.com/rustwasm/wasm-bindgen/compare/0.2.94...0.2.95)
Expand Down
16 changes: 9 additions & 7 deletions crates/test-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,15 @@ pub fn wasm_bindgen_test(
let wasm_bindgen_path = attributes.wasm_bindgen_path;
tokens.extend(
quote! {
#[no_mangle]
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
#[cfg_attr(wasm_bindgen_unstable_test_coverage, coverage(off))]
pub extern "C" fn #name(cx: &#wasm_bindgen_path::__rt::Context) {
let test_name = ::core::concat!(::core::module_path!(), "::", ::core::stringify!(#ident));
#test_body
}
const _: () = {
#[no_mangle]
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
#[cfg_attr(wasm_bindgen_unstable_test_coverage, coverage(off))]
pub extern "C" fn #name(cx: &#wasm_bindgen_path::__rt::Context) {
let test_name = ::core::concat!(::core::module_path!(), "::", ::core::stringify!(#ident));
#test_body
}
};
},
);

Expand Down
60 changes: 36 additions & 24 deletions crates/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,40 +56,52 @@ macro_rules! console_log {
#[macro_export]
macro_rules! wasm_bindgen_test_configure {
(run_in_browser $($others:tt)*) => (
#[link_section = "__wasm_bindgen_test_unstable"]
#[cfg(target_arch = "wasm32")]
pub static __WBG_TEST_RUN_IN_BROWSER: [u8; 1] = [0x01];
$crate::wasm_bindgen_test_configure!($($others)*);
const _: () = {
#[link_section = "__wasm_bindgen_test_unstable"]
#[cfg(target_arch = "wasm32")]
pub static __WBG_TEST_RUN_IN_BROWSER: [u8; 1] = [0x01];
$crate::wasm_bindgen_test_configure!($($others)*);
};
);
(run_in_worker $($others:tt)*) => (
#[link_section = "__wasm_bindgen_test_unstable"]
#[cfg(target_arch = "wasm32")]
pub static __WBG_TEST_RUN_IN_DEDICATED_WORKER: [u8; 1] = [0x02];
$crate::wasm_bindgen_test_configure!($($others)*);
const _: () = {
#[link_section = "__wasm_bindgen_test_unstable"]
#[cfg(target_arch = "wasm32")]
pub static __WBG_TEST_RUN_IN_DEDICATED_WORKER: [u8; 1] = [0x02];
$crate::wasm_bindgen_test_configure!($($others)*);
};
);
(run_in_dedicated_worker $($others:tt)*) => (
#[link_section = "__wasm_bindgen_test_unstable"]
#[cfg(target_arch = "wasm32")]
pub static __WBG_TEST_RUN_IN_DEDICATED_WORKER: [u8; 1] = [0x02];
$crate::wasm_bindgen_test_configure!($($others)*);
const _: () = {
#[link_section = "__wasm_bindgen_test_unstable"]
#[cfg(target_arch = "wasm32")]
pub static __WBG_TEST_RUN_IN_DEDICATED_WORKER: [u8; 1] = [0x02];
$crate::wasm_bindgen_test_configure!($($others)*);
};
);
(run_in_shared_worker $($others:tt)*) => (
#[link_section = "__wasm_bindgen_test_unstable"]
#[cfg(target_arch = "wasm32")]
pub static __WBG_TEST_RUN_IN_SHARED_WORKER: [u8; 1] = [0x03];
$crate::wasm_bindgen_test_configure!($($others)*);
const _: () = {
#[link_section = "__wasm_bindgen_test_unstable"]
#[cfg(target_arch = "wasm32")]
pub static __WBG_TEST_RUN_IN_SHARED_WORKER: [u8; 1] = [0x03];
$crate::wasm_bindgen_test_configure!($($others)*);
};
);
(run_in_service_worker $($others:tt)*) => (
#[link_section = "__wasm_bindgen_test_unstable"]
#[cfg(target_arch = "wasm32")]
pub static __WBG_TEST_RUN_IN_SERVICE_WORKER: [u8; 1] = [0x04];
$crate::wasm_bindgen_test_configure!($($others)*);
const _: () = {
#[link_section = "__wasm_bindgen_test_unstable"]
#[cfg(target_arch = "wasm32")]
pub static __WBG_TEST_RUN_IN_SERVICE_WORKER: [u8; 1] = [0x04];
$crate::wasm_bindgen_test_configure!($($others)*);
};
);
(run_in_node_experimental $($others:tt)*) => (
#[link_section = "__wasm_bindgen_test_unstable"]
#[cfg(target_arch = "wasm32")]
pub static __WBG_TEST_run_in_node_experimental: [u8; 1] = [0x05];
$crate::wasm_bindgen_test_configure!($($others)*);
const _: () = {
#[link_section = "__wasm_bindgen_test_unstable"]
#[cfg(target_arch = "wasm32")]
pub static __WBG_TEST_run_in_node_experimental: [u8; 1] = [0x05];
$crate::wasm_bindgen_test_configure!($($others)*);
};
);
() => ()
}
Expand Down

0 comments on commit 3b46cbe

Please sign in to comment.