Add Emscripten tests (#196)

See #194 

This installs (and caches) the emsdk toolchain at the last version compatible w/ stable rust. It also tests on both asmjs and wasm32, uses node by default, and works around an asm.js bug.
This commit is contained in:
Joseph Richey 2021-01-05 01:38:44 -08:00 committed by GitHub
parent e29ed04f28
commit 9d7a76c19e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 1 deletions

View File

@ -3,3 +3,7 @@
runner = 'wasm-bindgen-test-runner' runner = 'wasm-bindgen-test-runner'
[target.wasm32-wasi] [target.wasm32-wasi]
runner = 'wasmtime' runner = 'wasmtime'
# Just run on node by default (that's where emscripten is tested)
[target.'cfg(target_os = "emscripten")']
runner = 'node'

View File

@ -125,7 +125,6 @@ jobs:
override: true override: true
- run: cargo test --features=std - run: cargo test --features=std
# TODO: Add emscripten when it's working with Cross
cross-tests: cross-tests:
name: Cross Test name: Cross Test
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -224,6 +223,40 @@ jobs:
mv /tmp/wasmtime ~/.cargo/bin mv /tmp/wasmtime ~/.cargo/bin
- run: cargo test --target wasm32-wasi - run: cargo test --target wasm32-wasi
emscripten-tests:
name: Emscripten tests
runs-on: ubuntu-latest
env:
EMSDK_VERSION: 1.39.20 # Last emsdk compatible with Rust's LLVM 11
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- run: rustup target add wasm32-unknown-emscripten
- run: rustup target add asmjs-unknown-emscripten
- name: Cache emsdk
id: cache-emsdk
uses: actions/cache@v2
with:
path: ~/emsdk
key: ${{ runner.os }}-${{ env.EMSDK_VERSION }}-emsdk
- name: Install emsdk
if: steps.cache-emsdk.outputs.cache-hit != 'true'
run: |
git clone https://github.com/emscripten-core/emsdk.git ~/emsdk
cd ~/emsdk
./emsdk install $EMSDK_VERSION
./emsdk activate $EMSDK_VERSION
- run: echo "$HOME/emsdk/upstream/emscripten" >> $GITHUB_PATH
- name: wasm test
run: cargo test --target=wasm32-unknown-emscripten --features=std
- name: asm.js test
run: | # Debug info breaks on asm.js
RUSTFLAGS="$RUSTFLAGS -C debuginfo=0"
cargo test --target=asmjs-unknown-emscripten --features=std
build: build:
name: Build only name: Build only
runs-on: ubuntu-latest runs-on: ubuntu-latest