Skip to content

Commit eccbde4

Browse files
committed
Get tests on CI for wasm/wasi
1 parent 6e1af7d commit eccbde4

File tree

4 files changed

+34
-32
lines changed

4 files changed

+34
-32
lines changed

.github/workflows/psm.yml

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -255,32 +255,3 @@ jobs:
255255
with:
256256
command: build
257257
args: --target=${{ matrix.rust_target }} --manifest-path=psm/Cargo.toml
258-
259-
cross-build-without-std:
260-
runs-on: ubuntu-latest
261-
strategy:
262-
fail-fast: false
263-
matrix:
264-
rust_target:
265-
- wasm32-wasi
266-
# cannot be built because cross-toolchains are not easily available and LLVM fails
267-
# generating code when building libcore anyway...?
268-
# - sparcv9-sun-solaris
269-
# - sparc-unknown-linux-gnu
270-
timeout-minutes: 10
271-
steps:
272-
- uses: actions/checkout@v2
273-
- name: Install Rust nightly
274-
uses: actions-rs/toolchain@v1
275-
with:
276-
toolchain: nightly
277-
profile: minimal
278-
default: true
279-
- name: Fix-up toolchain
280-
run: |
281-
rustup component add rust-src --toolchain nightly --target ${{ matrix.rust_target }}
282-
- name: Build ${{ matrix.rust_target }}
283-
uses: actions-rs/cargo@v1
284-
with:
285-
command: build
286-
args: --target ${{ matrix.rust_target }} --manifest-path=psm/Cargo.toml -Zbuild-std=core

.github/workflows/stacker.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ jobs:
141141
- i686-unknown-freebsd
142142
- x86_64-unknown-freebsd
143143
- x86_64-unknown-netbsd
144-
- wasm32-wasi
145144
timeout-minutes: 10
146145
steps:
147146
- uses: actions/checkout@v2
@@ -181,3 +180,21 @@ jobs:
181180
with:
182181
command: build
183182
args: --target=${{ matrix.rust_target }}
183+
184+
wasm-test:
185+
runs-on: ubuntu-latest
186+
timeout-minutes: 10
187+
steps:
188+
- uses: actions/checkout@v1
189+
- name: Install Rust nightly
190+
uses: actions-rs/toolchain@v1
191+
with:
192+
toolchain: nightly
193+
default: true
194+
- run: rustup target add wasm32-wasi
195+
- run: |
196+
curl -Lf https://github.com/bytecodealliance/wasmtime/releases/download/v0.19.0/wasmtime-v0.19.0-x86_64-linux.tar.xz | tar xJf - -C ${{ runner.tool_cache }}
197+
echo ::add-path::${{ runner.tool_cache }}/wasmtime-v0.19.0-x86_64-linux
198+
echo ::set-env name=CARGO_BUILD_TARGET::wasm32-wasi
199+
echo ::set-env name=CARGO_TARGET_WASM32_WASI_RUNNER::wasmtime run --
200+
- run: cargo test --target wasm32-wasi --all -- --nocapture

tests/simple.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,10 @@ fn recurse(n: usize) {
1818

1919
#[test]
2020
fn foo() {
21-
recurse(10000);
21+
let limit = if cfg!(target_arch = "wasm32") {
22+
2000
23+
} else {
24+
10000
25+
};
26+
recurse(limit);
2227
}

tests/smoke.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,16 @@ fn deep() {
2121
}
2222
}
2323

24-
foo(256 * 1024, &mut []);
24+
let limit = if cfg!(target_arch = "wasm32") {
25+
2000
26+
} else {
27+
256 * 1024
28+
};
29+
foo(limit, &mut []);
2530
}
2631

2732
#[test]
33+
#[cfg_attr(target_arch = "wasm32", ignore)]
2834
fn panic() {
2935
fn foo(n: usize, s: &mut [u8]) {
3036
__stacker_black_box(s.as_ptr());
@@ -60,6 +66,7 @@ fn recursive<F: FnOnce()>(n: usize, f: F) -> usize {
6066
}
6167

6268
#[test]
69+
#[cfg_attr(target_arch = "wasm32", ignore)]
6370
fn catch_panic() {
6471
let panic_result = std::panic::catch_unwind(|| {
6572
recursive(100, || panic!());
@@ -68,6 +75,7 @@ fn catch_panic() {
6875
}
6976

7077
#[test]
78+
#[cfg_attr(target_arch = "wasm32", ignore)]
7179
fn catch_panic_inside() {
7280
stacker::grow(64 * 1024, || {
7381
let panic_result = std::panic::catch_unwind(|| {
@@ -78,6 +86,7 @@ fn catch_panic_inside() {
7886
}
7987

8088
#[test]
89+
#[cfg_attr(target_arch = "wasm32", ignore)]
8190
fn catch_panic_leaf() {
8291
stacker::grow(64 * 1024, || {
8392
let panic_result = std::panic::catch_unwind(|| panic!());

0 commit comments

Comments
 (0)