Skip to content

Commit

Permalink
travis: Fix wasm32 CI
Browse files Browse the repository at this point in the history
Split emscripten stuff into its own target and stop relying on cargo web
to download/manage then emscripten toolchain. We can just get it
ourselves. We also now run the emscripten tests.

Signed-off-by: Joe Richey <joerichey@google.com>
  • Loading branch information
josephlr committed Apr 27, 2020
1 parent 33b859b commit 143ce67
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
32 changes: 20 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@ matrix:
- name: "Linux, beta"
rust: beta

- name: "WASM via emscripten, stdweb, wasm-bindgen and WASI"
rust: nightly
- name: "WASM via stdweb, wasm-bindgen and WASI"
rust: stable
addons:
firefox: latest
chrome: stable
install:
- rustup target add wasm32-unknown-unknown
- rustup target add wasm32-unknown-emscripten
- rustup target add asmjs-unknown-emscripten
- rustup target add wasm32-wasi
# Get latest geckodriver
- export VERSION=$(curl -s https://api.github.com/repos/mozilla/geckodriver/releases/latest | jq -r ".tag_name")
Expand All @@ -60,15 +58,7 @@ matrix:
- tar -xzf wasm-bindgen.tar.gz --strip-components=1
# Place the runner binaries in our PATH
- mv cargo-web wasmtime wasm-bindgen-test-runner $HOME/.cargo/bin
# Download and setup emscripten
- cargo web prepare-emscripten
env: EMCC_CFLAGS="-s ERROR_ON_UNDEFINED_SYMBOLS=0"
script:
# We cannot run emscripten test binaries (see rust-lang/rust#63649).
# However, we can still build and link all tests to make sure that works.
# This is actually useful as it finds stuff such as rust-random/rand#669
- cargo web test --target wasm32-unknown-emscripten --no-run
- cargo web test --target asmjs-unknown-emscripten --no-run
# wasi tests
- cargo test --target wasm32-wasi
# stdweb tests (Node, Chrome)
Expand All @@ -79,6 +69,24 @@ matrix:
- GECKODRIVER=$PWD/geckodriver cargo test --target wasm32-unknown-unknown --features=test-in-browser
- CHROMEDRIVER=$PWD/chromedriver cargo test --target wasm32-unknown-unknown --features=test-in-browser

- name: "WASM via Emscripten"
rust: stable
env:
- CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_RUNNER=node
- CARGO_TARGET_ASMJS_UNKNOWN_EMSCRIPTEN_RUNNER=node
install:
- rustup target add wasm32-unknown-emscripten
- rustup target add asmjs-unknown-emscripten
- export VERSION=1.39.13 # Pin version for stability
- git clone https://github.com/emscripten-core/emsdk.git
- ./emsdk/emsdk install $VERSION
- ./emsdk/emsdk activate $VERSION
- source ./emsdk/emsdk_env.sh
script:
- cargo test --target wasm32-unknown-emscripten
# Prevent 'wasm2js does not support source maps yet' error.
- RUSTFLAGS='-C debuginfo=0' cargo test --target asmjs-unknown-emscripten

- name: "Linux, nightly, docs"
rust: nightly
os: linux
Expand Down
3 changes: 2 additions & 1 deletion tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ fn test_huge() {
getrandom(&mut huge).unwrap();
}

#[cfg(any(unix, windows, target_os = "redox", target_os = "fuchsia"))]
// On WASM, the thread API always fails/panics
#[cfg(not(target_arch = "wasm32"))]
#[test]
fn test_multithreading() {
use std::sync::mpsc::channel;
Expand Down

0 comments on commit 143ce67

Please sign in to comment.