Skip to content

Enable cargo test where possible #175

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

Merged
merged 1 commit into from
Apr 28, 2018
Merged

Enable cargo test where possible #175

merged 1 commit into from
Apr 28, 2018

Conversation

alexcrichton
Copy link
Contributor

Currently #[wasm_bindgen] generates a bunch of references to symbols that
don't actually exist on non-wasm targets, making it more difficult to get a
crate working across multiple platforms. This commit updates the symbol
references to be dummy ones that panic on non-wasm targets to allow simple
testing/benchmarking to work on native targets.

While this isn't a perfect solution for #114 it's probably as good as we can do
for now pending upstream Cargo features, so I'm gonna say that it...

Closes #114

@alexcrichton
Copy link
Contributor Author

cc @fitzgen, I'm curious what you think of this approach.

The tl;dr; is that wasm-bindgen should be fine to mix in with cross-platform code, but if you invoke any imported functionality (aka anything that would otherwise call out to JS) then it panics at runtime.

Currently `#[wasm_bindgen]` generates a bunch of references to symbols that
don't actually exist on non-wasm targets, making it more difficult to get a
crate working across multiple platforms. This commit updates the symbol
references to be dummy ones that panic on non-wasm targets to allow simple
testing/benchmarking to work on native targets.

While this isn't a perfect solution for #114 it's probably as good as we can do
for now pending upstream Cargo features, so I'm gonna say that it...

Closes #114
@alexcrichton alexcrichton merged commit 9bab720 into master Apr 28, 2018
@alexcrichton alexcrichton deleted the non-wasm branch April 28, 2018 16:17
Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This enables cargo test in a crate that uses #[wasm_bindgen], right? 👍

LGTM!

@alexcrichton
Copy link
Contributor Author

@fitzgen I think you'll still need to do something like crate-type = ["cdylib", "rlib"], but otherwise it should be at least a big step towards making it work!

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

Successfully merging this pull request may close these issues.

2 participants