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

Support crate attribute in proc-macro wasm_bindgen_test #3588

Closed
FirelightFlagboy opened this issue Aug 31, 2023 · 2 comments · Fixed by #3593
Closed

Support crate attribute in proc-macro wasm_bindgen_test #3588

FirelightFlagboy opened this issue Aug 31, 2023 · 2 comments · Fixed by #3593

Comments

@FirelightFlagboy
Copy link
Contributor

FirelightFlagboy commented Aug 31, 2023

Motivation

We have multiple crates that we would like to test using wasm-bindgen-test.

For the ease-of-use on our side we create a proc-macro that wrap multiple other proc-macro (rstest, tokio::test, custom testbed) for testing.

To use that proc-macro the developer would have to import (add as a dependency) a single crate that provide the proc-macro + re-export rstest, tokio::test and testbed.

But to support wasm-bindgen-test we're required to alongside the test crate to also import wasm-bindgen-test and we would like to have it re-exported in the test crate instead.

Currently wasm-bindgen-test proc macro use a fixed path to the crate wasm_bindgen_test (cf the generated function by the proc-macro wasm_bindgen_test

#[no_mangle]
pub extern "C" fn __wbgt_case_1_invalid_type_deserialization_2(
    cx: &::wasm_bindgen_test::__rt::Context,
) {
    let test_name = "misc::serde_invalid_type_deserialization::case_1_invalid_type_deserialization";
    cx.execute_sync(test_name, case_1_invalid_type_deserialization, None);
}

Proposed Solution

A solution would be to do something like tokio::test handle renaming the crate with the crate attribute provided to the proc-macro.

A clear and concise description of the feature you would like to add, and how it solves the motivating problem.

Alternatives

An alternative would have to add wasm-bindgen-test to each of our crates that will be tested with it.
For the easy-of-use we would have preferred to import a single crate that re-expose those utility crates.

Additional Context

This feature will required to:

@daxpedda
Copy link
Collaborator

daxpedda commented Sep 2, 2023

I have done this for the wasm_bindgen macro here: #3360.
Happy to review a PR implementing this for wasm_bindgen_test as well!

FirelightFlagboy added a commit to FirelightFlagboy/wasm-bindgen that referenced this issue Sep 4, 2023
This attribute allow to specify a path where `wasm-bindgen-test` can be
accessed.

Closes rustwasm#3588
@FirelightFlagboy
Copy link
Contributor Author

I've create a PR (#3593)

FirelightFlagboy added a commit to FirelightFlagboy/wasm-bindgen that referenced this issue Sep 4, 2023
This attribute allow to specify a path where `wasm-bindgen-test` can be
accessed.

Closes rustwasm#3588
FirelightFlagboy added a commit to FirelightFlagboy/wasm-bindgen that referenced this issue Sep 4, 2023
This attribute allow to specify a path where `wasm-bindgen-test` can be
accessed.

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

Successfully merging a pull request may close this issue.

2 participants