Skip to content

Commit 51d4b35

Browse files
alexcrichtongnzlbg
authored andcommitted
Hook tests up to node.js
We can even test some of the functions!
1 parent ab3e5f9 commit 51d4b35

File tree

7 files changed

+122
-35
lines changed

7 files changed

+122
-35
lines changed

ci/docker/wasm32-unknown-unknown/Dockerfile

+19-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
FROM ubuntu:18.04 as node
2+
3+
RUN apt-get update -y && apt-get install -y \
4+
g++ \
5+
git \
6+
make \
7+
python
8+
9+
10+
# Install `node`
11+
RUN git clone https://github.com/nodejs/node --depth 1
12+
WORKDIR node
13+
RUN ./configure --prefix=/node-install
14+
RUN make -j$(nproc) install
15+
116
FROM ubuntu:18.04
217

318
RUN apt-get update -y && apt-get install -y --no-install-recommends \
@@ -16,12 +31,8 @@ RUN git clone --recursive https://github.com/WebAssembly/wabt
1631
RUN make -C wabt -j$(nproc)
1732
ENV PATH=$PATH:/wabt/bin
1833

19-
# Install `wasm-bindgen-test-runner`
20-
RUN curl -L https://github.com/rustwasm/wasm-bindgen/releases/download/0.2.19/wasm-bindgen-0.2.19-x86_64-unknown-linux-musl.tar.gz \
21-
| tar xzf -
22-
ENV PATH=$PATH:/wasm-bindgen-0.2.19-x86_64-unknown-linux-musl
23-
ENV CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-bindgen-test-runner
34+
COPY --from=node /node-install /
35+
ENV PATH=$PATH:/node-install/bin
2436

25-
# Install `node`
26-
RUN curl https://nodejs.org/dist/v10.8.0/node-v10.8.0-linux-x64.tar.xz | tar xJf -
27-
ENV PATH=$PATH:/node-v10.8.0-linux-x64/bin
37+
COPY docker/wasm32-unknown-unknown/wasm-entrypoint.sh /wasm-entrypoint.sh
38+
ENTRYPOINT ["/wasm-entrypoint.sh"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
# Download an appropriate version of wasm-bindgen based off of what's being used
6+
# in the lock file. Ideally we'd use `wasm-pack` at some point for this!
7+
version=$(grep -A 1 'name = "wasm-bindgen"' Cargo.lock | grep version)
8+
version=$(echo $version | awk '{print $3}' | sed 's/"//g')
9+
curl -L https://github.com/rustwasm/wasm-bindgen/releases/download/$version/wasm-bindgen-$version-x86_64-unknown-linux-musl.tar.gz \
10+
| tar xzf - -C target
11+
export PATH=$PATH:`pwd`/target/wasm-bindgen-$version-x86_64-unknown-linux-musl
12+
export CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-bindgen-test-runner
13+
export NODE_ARGS=--experimental-wasm-simd
14+
15+
exec "$@"

ci/run.sh

+10-4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ STD_DETECT="--manifest-path=crates/std_detect/Cargo.toml"
5151
STDSIMD_EXAMPLES="--manifest-path=examples/Cargo.toml"
5252
cargo_test "${CORE_ARCH}"
5353
cargo_test "${CORE_ARCH} --release"
54+
5455
if [ "$NOSTD" != "1" ]; then
5556
cargo_test "${STD_DETECT}"
5657
cargo_test "${STD_DETECT} --release"
@@ -72,10 +73,15 @@ case ${TARGET} in
7273
cargo_test "--release"
7374
;;
7475
wasm32-unknown-unknown*)
75-
# There's no node or other runtime which supports the most recent SIMD
76-
# proposal, but hopefully that's coming soon! For now just test that we
77-
# can codegen with no LLVM faults, and we'll remove `--no-run` at a
78-
# later date.
76+
# Attempt to actually run some SIMD tests in node.js. Unfortunately
77+
# though node.js (transitively through v8) doesn't have support for the
78+
# full SIMD spec yet, only some functions. As a result only pass in
79+
# some target features and a special `--cfg`
80+
export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+simd128 --cfg only_node_compatible_functions"
81+
cargo_test "--release"
82+
83+
# After that passes make sure that all intrinsics compile, passing in
84+
# the extra feature to compile in non-node-compatible SIMD.
7985
export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+simd128,+unimplemented-simd128"
8086
cargo_test "--release --no-run"
8187
;;

crates/core_arch/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ stdsimd-test = { version = "0.*", path = "../stdsimd-test" }
2929
std_detect = { version = "0.*", path = "../std_detect" }
3030

3131
[target.wasm32-unknown-unknown.dev-dependencies]
32-
wasm-bindgen-test = "=0.2.19"
32+
wasm-bindgen-test = "0.2.39"
3333

3434
[package.metadata.docs.rs]
35-
rustdoc-args = [ "--cfg", "dox" ]
35+
rustdoc-args = [ "--cfg", "dox" ]

0 commit comments

Comments
 (0)