Skip to content

Commit

Permalink
Add emscripten tests
Browse files Browse the repository at this point in the history
  • Loading branch information
josephlr committed Jan 5, 2021
1 parent e29ed04 commit c0595bd
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .cargo/config
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
runner = 'wasm-bindgen-test-runner'
[target.wasm32-wasi]
runner = 'wasmtime'

# Just run on node by default (that's where emscripten is tested)
[target.'cfg(target_os = "emscripten")']
runner = 'node'
34 changes: 33 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Dwarnings"
EMSDK_VERSION: 1.39.20 # Last emsdk compatible with Rust's LLVM 11

jobs:
check-doc:
Expand Down Expand Up @@ -125,7 +126,6 @@ jobs:
override: true
- run: cargo test --features=std

# TODO: Add emscripten when it's working with Cross
cross-tests:
name: Cross Test
runs-on: ubuntu-latest
Expand Down Expand Up @@ -224,6 +224,38 @@ jobs:
mv /tmp/wasmtime ~/.cargo/bin
- run: cargo test --target wasm32-wasi

emscripten-tests:
name: Emscripten tests
runs-on: ubuntu-latest
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 information doesn't work with asm.js
RUSTFLAGS="$RUSTFLAGS -C debuginfo=0"
cargo test --target=asmjs-unknown-emscripten --features=std
build:
name: Build only
runs-on: ubuntu-latest
Expand Down

0 comments on commit c0595bd

Please sign in to comment.