Skip to content

Commit c0595bd

Browse files
committed
Add emscripten tests
1 parent e29ed04 commit c0595bd

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

.cargo/config

+4
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

+33-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
env:
1212
CARGO_INCREMENTAL: 0
1313
RUSTFLAGS: "-Dwarnings"
14+
EMSDK_VERSION: 1.39.20 # Last emsdk compatible with Rust's LLVM 11
1415

1516
jobs:
1617
check-doc:
@@ -125,7 +126,6 @@ jobs:
125126
override: true
126127
- run: cargo test --features=std
127128

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

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

0 commit comments

Comments
 (0)