Skip to content
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

less verbose way to have wasm and non-wasm tests? #1768

Closed
mikemoraned opened this issue Sep 14, 2019 · 3 comments
Closed

less verbose way to have wasm and non-wasm tests? #1768

mikemoraned opened this issue Sep 14, 2019 · 3 comments
Labels

Comments

@mikemoraned
Copy link

Summary

In image-rs/imageproc#386 I am extending https://github.com/image-rs/imageproc to have wasm tests by re-using the existing tests. The way I am doing this is based on this post, https://www.reddit.com/r/rust/comments/a80rst/pure_wasm_crate_testing/ec8q9r3/ i.e.

#[cfg_attr(not(target_arch = "wasm32"), test)]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn test_connected_components_eight_white_background() {
...
}

However, this is verbose compared to #[test]. Given the above post was 8 months ago, is there now a better way to do this?

If not, is there any WIP I could help with to make it more succinct?

@alexcrichton
Copy link
Contributor

Currently there's not a less verbose way of doing this, but I agree that there should be! I'm not entirely sure what this would look like though

@dcormier
Copy link

dcormier commented Dec 6, 2020

Maybe it would be nice if something like #[wasm_bindgen_test(also_non_wasm)] worked.

@daxpedda
Copy link
Collaborator

Addressed by #4150.

In the next breaking change we should probably do the reverse: by default apply test and add an option to opt-out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants