This commit adds a test harness and the beginnings of a test suite for
the crate that performs GC over a wasm module. This crate historically
has had zero tests because it was thought that it would no longer be
used once LLD landed with `--gc-sections`, but `wasm-bindgen` has come
to rely more and more on `wasm-gc` for various purposes.
The last release of `wasm-bindgen` was also released with a bug in the
recently refactored support in the `wasm-gc` crate, providing a perfect
time and motivation to start writing some tests!
All tests added here are `*.wat` files which contain the expected output
after the gc pass is executed. Tests are automatically updated with
`BLESS_TESTS=1` in the environment, which is the expected way to
generate the output for each test.
This configures sccache for Linux/OSX/Windows in an attempt to speed up
CI by reusing the results of previous builds, cached on the network with
`sccache`.
... and add a parallel raytracing demo!
This commit adds enough support to `wasm-bindgen` to produce a workable
wasm binary *today* with the experimental WebAssembly threads support
implemented in Firefox Nightly. I've tried to comment what's going on in
the commits and such, but at a high level the changes made here are:
* A new transformation, living in a new `wasm-bindgen-threads-xform`
crate, prepares a wasm module for parallel execution. This performs a
number of mundane tasks which I hope to detail in a blog post later on.
* The `--no-modules` output is enhanced with more support for when
shared memory is enabled, allowing passing in the module/memory to
initialize the wasm instance on multiple threads (sharing both module
and memory).
* The `wasm-bindgen` crate now offers the ability, in `--no-modules`
mode, to get a handle on the `WebAssembly.Module` instance.
* The example itself requires Xargo to recompile the standard library
with atomics and an experimental feature enabled. Afterwards it
experimentally also enables threading support in wasm-bindgen.
I've also added hopefully enough CI support to compile this example in a
builder so we can upload it and poke around live online. I hope to
detail more about the technical details here in a blog post soon as
well!
This shaves a little over 2MB off the download locally for Linux,
removing debuginfo (which no one's probably gonna use anyway) as well as
switching from jemalloc to the system allocator.
We'll graduate these to stable once 1.30.0 is released, but for now
let's start testing beta! Some matrix entries remain on nightly, but the
bulk of tests are switching to beta.
Rejigger Travis slightly to take advantage of build stages to build the
`gh-pages` branch amongst a set of builders, and then when they're all
done we synchronize and deploy the site. For now use S3 as a backing
store for data between jobs.
* Gate `web-sys` APIs on activated features
Currently the compile times of `web-sys` are unfortunately prohibitive,
increasing the barrier to using it. This commit updates the crate to instead
have all APIs gated by a set of Cargo features which affect what bindings are
generated at compile time (and which are then compiled by rustc). It's
significantly faster to activate only a handful of features vs all thousand of
them!
A magical env var is added to print the list of all features that should be
generated, and then necessary logic is added to ferry features from the build
script to the webidl crate which then uses that as a filter to remove items
after parsing. Currently parsing is pretty speedy so we'll unconditionally parse
all WebIDL files, but this may change in the future!
For now this will make the `web-sys` crate a bit less ergonomic to use as lots
of features will need to be specified, but it should make it much more
approachable in terms of first-user experience with compile times.
* Fix AppVeyor testing web-sys
* FIx a typo
* Udpate feature listings from rebase conflicts
* Add some crate docs and such
This commit starts to add infrastructure for targeted diagnostics in the
`#[wasm_bindgen]` attribute, intended eventually at providing much better errors
as they'll be pointing to exactly the code in question rather than always to a
`#[wasm_bindgen]` attribute.
The general changes are are:
* A new `Diagnostic` error type is added to the backend. A `Diagnostic` is
created with a textual error or with a span, and it can also be created from a
list of diagnostics. A `Diagnostic` implements `ToTokens` which emits a bunch
of invocations of `compile_error!` that will cause rustc to later generate
errors.
* Fallible implementations of `ToTokens` have switched to using a new trait,
`TryToTokens`, which returns a `Result` to use `?` with.
* The `MacroParse` trait has changed to returning a `Result` to propagate errors
upwards.
* A new `ui-tests` crate was added which uses `compiletest_rs` to add UI tests.
These UI tests will verify that our output improves over time and does not
regress. This test suite is added to CI as a new builder as well.
* No `Diagnostic` instances are created just yet, everything continues to panic
and return `Ok`, with the one exception of the top-level invocations of
`syn::parse` which now create a `Diagnostic` and pass it along.
This commit does not immediately improve diagnostics but the intention is that
it is laying the groundwork for improving diagnostics over time. It should
ideally be much easier to contribute improved diagnostics after this commit!
cc #601
* Tweak the implementation of heap closures
This commit updates the implementation of the `Closure` type to internally store
an `Rc` and be suitable for dropping a `Closure` during the execution of the
closure. This is currently needed for promises but may be generally useful as
well!
* Support asynchronous tests
This commit adds support for executing tests asynchronously. This is modeled
by tests returning a `Future` instead of simply executing inline, and is
signified with `#[wasm_bindgen_test(async)]`.
Support for this is added through a new `wasm-bindgen-futures` crate which is a
binding between the `futures` crate and JS `Promise` objects.
Lots more details can be found in the details of the commit, but one of the end
results is that the `web-sys` tests are now entirely contained in the same test
suite and don't need `npm install` to be run to execute them!
* Review tweaks
* Add some bindings for `Function.call` to `js_sys`
Name them `call0`, `call1`, `call2`, ... for the number of arguments being
passed.
* Use oneshots channels with `JsFuture`
It did indeed clean up the implementation!
This commit starts migrating the `wasm_bindgen` tests to the `wasm_bindgen_test`
framework, starting to assemble the coffin for
`wasm-bindgen-test-project-builder`. Over time all of the tests in
`tests/all/*.rs` should be migrated to `wasm_bindgen_test`, although they may
not all want to go into a monolithic test suite so we can continue to test for
some more subtle situations with `#[wasm_bindgen]`.
In the meantime those, the `tests/all/api.rs` tests can certainly migrate!
This commit moves the `webidl/tests` folder to a new `crates/webidl-tests` crate
(to have a test-only build script) and ports them to the `#[wasm_bindgen_test]`
attribute, which should hopefully make testing much speedier for execution!
* Fix running dist builds on tags
* Only run dist builds on tags, no need to run the full matrix.
* Fix dist builds on AppVeyor to include `wasm-bindgen-test-runner.exe`
* Only cache `~/.cargo` on Travis for the guide build, the `target` dir changes
too much to cache it.
* Add a test harness to directly execute wasm tests
This commits adds a few new crates and infrastructure to enable comands like:
cargo test --target wasm32-unknown-unknown
The intention here is to make it as low-friction as possible to write wasm tests
and also have them execute in a reasonable amount of time. Eventually this is
also hopefully enough support to do things like headless testing!
For now though this is defintely MVP status rather than fully fleshed out.
There's some more information at `crates/test/README.md` about how it works and
how to use it, but for now this is mainly intended to play around with locally
in this repository for our own tests.
* Port a numbe of `js-sys` tests to the new test framework
This commit ports a number of existing tests for the `js-sys` crate over to the
new test framework created in the previous commit, showing off how they can be
executed as well as drastictlly simplifying the tests themselves! This is
intended to be a proof of concept for now which we can refine over time. This
should also show off that it's possible to incrementally move over to the new
test framework.
* Move the `js` module to a `js_sys` crate
* Update js-sys tests to pass again
* Update binding_to_unimplemented_apis_doesnt_break_everything
Remove its dependency on the `js` module
* Update metadata for js-sys
* Fix the `closures` example