Skip to content

Commit 9d7a76c

Browse files
authored
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.
1 parent e29ed04 commit 9d7a76c

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

.cargo/config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
runner = 'wasm-bindgen-test-runner'
44
[target.wasm32-wasi]
55
runner = 'wasmtime'
6+
7+
# Just run on node by default (that's where emscripten is tested)
8+
[target.'cfg(target_os = "emscripten")']
9+
runner = 'node'

.github/workflows/tests.yml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ jobs:
125125
override: true
126126
- run: cargo test --features=std
127127

128-
# TODO: Add emscripten when it's working with Cross
129128
cross-tests:
130129
name: Cross Test
131130
runs-on: ubuntu-latest
@@ -224,6 +223,40 @@ jobs:
224223
mv /tmp/wasmtime ~/.cargo/bin
225224
- run: cargo test --target wasm32-wasi
226225

226+
emscripten-tests:
227+
name: Emscripten tests
228+
runs-on: ubuntu-latest
229+
env:
230+
EMSDK_VERSION: 1.39.20 # Last emsdk compatible with Rust's LLVM 11
231+
steps:
232+
- uses: actions/checkout@v2
233+
- uses: actions-rs/toolchain@v1
234+
with:
235+
profile: minimal
236+
toolchain: stable
237+
- run: rustup target add wasm32-unknown-emscripten
238+
- run: rustup target add asmjs-unknown-emscripten
239+
- name: Cache emsdk
240+
id: cache-emsdk
241+
uses: actions/cache@v2
242+
with:
243+
path: ~/emsdk
244+
key: ${{ runner.os }}-${{ env.EMSDK_VERSION }}-emsdk
245+
- name: Install emsdk
246+
if: steps.cache-emsdk.outputs.cache-hit != 'true'
247+
run: |
248+
git clone https://github.com/emscripten-core/emsdk.git ~/emsdk
249+
cd ~/emsdk
250+
./emsdk install $EMSDK_VERSION
251+
./emsdk activate $EMSDK_VERSION
252+
- run: echo "$HOME/emsdk/upstream/emscripten" >> $GITHUB_PATH
253+
- name: wasm test
254+
run: cargo test --target=wasm32-unknown-emscripten --features=std
255+
- name: asm.js test
256+
run: | # Debug info breaks on asm.js
257+
RUSTFLAGS="$RUSTFLAGS -C debuginfo=0"
258+
cargo test --target=asmjs-unknown-emscripten --features=std
259+
227260
build:
228261
name: Build only
229262
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)