Commit Graph

98 Commits

Author SHA1 Message Date
Alex Crichton
40b68c66d9 Fix a bug in coalescing types with GC
When a duplicate type is found is should no longer be considered used!
2018-10-30 15:45:21 -07:00
Alex Crichton
91d68a0012 Add tests for the wasm-gc crate
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.
2018-10-29 15:49:35 -07:00
Alex Crichton
8d695b800d
Merge pull request #989 from alexcrichton/stable-ci
Promote CI jobs to using stable Rust
2018-10-28 14:14:49 -07:00
Alex Crichton
cfa4aa0e3e Promote CI jobs to using stable Rust
Everything should be stable now so let's test it!
2018-10-28 13:28:02 -07:00
Alex Crichton
0bc64338e8 Try to speed up CI with sccache
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`.
2018-10-28 12:53:48 -07:00
Alex Crichton
cb170ef94f
Merge pull request #972 from alexcrichton/bulk-memory
Implement support for WebAssembly threads
2018-10-23 11:30:59 +02:00
Alex Crichton
25b26f41e7 Implement support for WebAssembly threads
... 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!
2018-10-23 01:20:18 -07:00
Alex Crichton
cb9c9fb011 Shrink binary size of distributed wasm-bindgen
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.
2018-10-17 19:15:09 -07:00
Alex Crichton
d50e2f8605
Merge pull request #881 from alexcrichton/test-beta
Start running CI tests on Rust beta
2018-09-25 12:27:41 -07:00
Alex Crichton
5af3d72f42 Start running CI tests on Rust beta
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.
2018-09-25 10:36:28 -07:00
Alex Crichton
b932260b40 Temporarily disable Chrome on CI
It's been extremely flaky and is tracked by #882 for re-enabling.
2018-09-24 16:02:25 -07:00
Alex Crichton
e353c1cf6f Build examples and deploy to gh-pages
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.
2018-09-20 20:55:02 -07:00
Alex Crichton
300aca38c2 Squelch warnings in webidl tests 2018-09-18 14:30:24 -07:00
Alex Crichton
ce3068bb3a Work around Travis's own bug... 2018-09-17 18:35:05 -07:00
Nick Fitzgerald
3929e371dd ci: remove hack for broken libLLVM.so in nightly 2018-09-12 14:09:00 -07:00
Alex Crichton
269c491380
Gate web-sys APIs on activated features (#790)
* 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
2018-09-05 12:55:30 -07:00
Alex Crichton
df19b63c60 Hack around a broken nightly 2018-08-30 10:33:45 -07:00
Alex Crichton
0e38388e7b Remove package-lock.json
It shouldn't be critical now that we're no longer testing with it and the
examples build should be testing against the latest anyway!
2018-08-27 17:40:46 -07:00
Alex Crichton
7154372af9 Remove yarn tests on CI
We're not actually using them any more!
2018-08-27 17:39:40 -07:00
Alex Crichton
3c3e6c4498 Provide no input for yarn
Hopefully it won't hang waiting for input as a result
2018-08-20 14:15:42 -07:00
Alex Crichton
4c1bf937f2 Move the unsize feature behind a nightly Cargo feature
This should fully stabilize the `wasm-bindgen` crate, preparing us for stable
Rust!
2018-08-19 14:45:59 -07:00
Nick Fitzgerald
ff83594882 futures: Add sanity tests for conversion between Promises and Futures
Part of #614
2018-08-09 16:21:49 -07:00
Nick Fitzgerald
05dd67a63f ci: Also test wasm-bindgen-futures 2018-08-08 17:44:38 -07:00
Alex Crichton
0d18c8c397 Fix consuming a struct and returning a slice
This came up in a [recent comment][1] and it turns out we're accidentally
generating two `const ptr = ...` declarations, invalid JS! While Node doesn't
catch this it looks like firefox does.

[1]: https://github.com/rustwasm/wasm-bindgen/issues/329#issuecomment-411082013
2018-08-07 08:46:38 -07:00
Alex Crichton
b2977a4262 Delete wasm-bindgen-test-project-builder
No more tests use it!
2018-08-06 11:48:34 -07:00
Alex Crichton
0a2399a7f1 Migrate #![no_std] tests to wasm
This required getting a little creative in a few places, but otherwise these
tests shouldn't need the test builder any more.
2018-08-06 11:08:35 -07:00
Alex Crichton
6edf063c94 Allow disabling --debug in wasm-bindgen-test-runner
Afterwards remove the `non_debug` test as we're running the entire test suite in
non-debug mode!
2018-08-06 09:57:41 -07:00
Alex Crichton
0bdb31d41e Migrate the serde-serialize test to wasm 2018-08-06 09:43:55 -07:00
Alex Crichton
e9f9ede1fa Switch to openssl's vendored feature for musl builds
This should give us updates for free!
2018-08-05 10:40:08 -05:00
Alex Crichton
5d4c135c31 Run Chrome headless tests on CI
Closes #622
2018-08-04 10:48:49 -05:00
Alex Crichton
c4dcaee1b9
Prepare to have targeted error diagnostics (#604)
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
2018-08-01 17:15:27 -05:00
Alex Crichton
fce687cf7b Retry installing yarn on CI
This was flaky enough in the past that the extra tries should hopefully make
this less flaky
2018-08-01 14:56:14 -07:00
Alex Crichton
eee71de0ce
Support asynchronous tests (#600)
* 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!
2018-08-01 15:52:24 -05:00
Alex Crichton
4181afea45
Start migrating wasm_bindgen tests to wasm_bindgen_test (#602)
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!
2018-08-01 14:19:19 -05:00
Alex Crichton
1ef9067952 Install geckodriver for web-sys 2018-07-30 11:16:12 -07:00
Alex Crichton
4282ec25bd Move web-sys tests to the new test framework
Migrate most `web-sys` tests to the new `wasm_bindgen_test` framework with the
new headless browser capabilities!
2018-07-30 11:07:07 -07:00
Alex Crichton
63c86aa4e3 Download geckodriver for headless tests 2018-07-30 11:07:07 -07:00
Alex Crichton
74cb40189c Fix MUSL builder by compiling OpenSSL 2018-07-30 11:07:07 -07:00
Alex Crichton
7e16690f10
Migrate webidl tests to wasm_bindgen_test (#590)
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!
2018-07-30 11:06:29 -07:00
Alex Crichton
66649018ae
Speed up examples CI builder (#572)
No need to `npm install` a bunch of times, we only need to do it once!
2018-07-27 10:07:00 -07:00
Alex Crichton
f893e3475c Only publish artifacts for main crate changes 2018-07-26 15:51:43 -07:00
Alex Crichton
de0776948d Tweak travis config 2018-07-26 15:50:51 -07:00
Alex Crichton
eda1033246 Tweak Travis/AppVeyor config
* 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.
2018-07-26 11:31:38 -07:00
Alex Crichton
0d3f877ec4 Build tags on Travis 2018-07-26 10:16:11 -07:00
Alex Crichton
2da77fb8b0 Merge the cli and test-runner packages
Shouldn't be any need to have them versioned separately!
2018-07-20 22:42:36 -07:00
Alex Crichton
f8d336d711
Add a test harness to directly execute wasm tests (#524)
* 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.
2018-07-20 13:47:49 -05:00
Alex Macleod
722a87f324 Verbose npm ci output (#527)
Temporarily increase the output of npm ci to see what's happening regarding #517
2018-07-20 13:32:57 -05:00
Alex Crichton
512e280409 Update documentation step to build for js-sys 2018-07-19 13:04:29 -07:00
Alex Crichton
6eef5f7b52
Move the js module to a js_sys crate (#512)
* 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
2018-07-19 14:30:58 -05:00
R. Andrew Ohana
89e8a4561e use npm ci in ci (#481) 2018-07-14 22:45:58 -05:00