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

WASM support #78

Closed
cryptoquick opened this issue Oct 7, 2022 · 7 comments
Closed

WASM support #78

cryptoquick opened this issue Oct 7, 2022 · 7 comments

Comments

@cryptoquick
Copy link

Was trying to do something like this:

#[wasm_bindgen_test]
#[serial]
async fn my_func() {
    // ...
}

But received this compile-time error:

custom attribute panicked
message: async testing attempted with async feature disabled in serial_test!

It's strange, since async should be enabled by default according to the docs. Am I missing something, or is using this in a WASM context not yet possible?

@palfrey
Copy link
Owner

palfrey commented Oct 7, 2022

Not sure. Haven't tested this with WASM before, so I'm guessing some weird interaction is going on...

@cryptoquick
Copy link
Author

cryptoquick commented Oct 7, 2022

I'll say! Would you like me to provide you with an MRE?

Or, even better than an MRE, maybe contributing a check for that in your GitHub actions? I can open a PR.

@palfrey
Copy link
Owner

palfrey commented Oct 9, 2022

I'm unlikely to get around to fixing this any time in the next few weeks, given other personal stuff. If OTOH, you've got a PR that both demos the error and fixes things, I'd be interested and able to review that a lot sooner.

@cryptoquick
Copy link
Author

I'm not sure I could fix it, but I could certainly provide a test. And no need to prioritize this over personal stuff.

@palfrey
Copy link
Owner

palfrey commented Dec 10, 2022

Having just read wasm_bindgen_test I think a chunk of the problem is that it strips the async attribute from the test it spits out.

Although so does tokio so I'm a bit confused. OTOH, there does appear to be a bug here where serial_test_derive didn't have a async feature, so that warning should trigger on everything async, but it doesn't for some reason!

For reference, once I fix that (PR to come once I'm able to reproduce this in something that isn't wasm_bindgen_test) you then get the new error:

error[E0277]: `[closure@serial_test_test/src/lib.rs:347:5: 347:14]` is not a future
   --> serial_test_test/src/lib.rs:347:5
    |
347 |     #[serial]
    |     ^^^^^^^^^
    |     |
    |     `[closure@serial_test_test/src/lib.rs:347:5: 347:14]` is not a future
    |     consider calling this closure
    |
    = help: the trait `Future` is not implemented for closure `[closure@serial_test_test/src/lib.rs:347:5: 347:14]`
    = note: [closure@serial_test_test/src/lib.rs:347:5: 347:14] must be a future or must implement `IntoFuture` to be awaited
note: required by a bound in `local_async_serial_core`
   --> /home/palfrey/src/serial_test/serial_test/src/serial_code_lock.rs:50:15
    |
50  |     fut: impl std::future::Future<Output = ()>,
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `local_async_serial_core`
    = note: this error originates in the attribute macro `serial` (in Nightly builds, run with -Z macro-backtrace for more info)

@palfrey
Copy link
Owner

palfrey commented Dec 11, 2022

#82 should fix this. @cryptoquick Can you test that branch against your use case please?

@palfrey
Copy link
Owner

palfrey commented Dec 14, 2022

I've merged #82 and so closing this. Please re-open if there's still an issue with your use case.

@palfrey palfrey closed this as completed Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants