Skip to content
This repository was archived by the owner on Oct 3, 2025. It is now read-only.

Commit 398b2af

Browse files
test: make tests work on more targets (#11)
- Tests can now be run on more targets (Fixes #7) - Nightly version has been updated to fix broken builds in some cases (Fixes #8)
1 parent acb91b8 commit 398b2af

File tree

24 files changed

+193
-110
lines changed

24 files changed

+193
-110
lines changed

.cargo/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ test-mvp="test --package tinywasm --test test-mvp --release -- --enable "
55
test-2="test --package tinywasm --test test-two --release -- --enable "
66
test-wast="test --package tinywasm --test test-wast -- --enable "
77
test-wast-release="test --package tinywasm --test test-wast --release -- --enable "
8-
generate-charts="test --package tinywasm --test generate-charts -- --enable "
8+
generate-charts="run --package scripts --bin generate-charts --release"
99
benchmark="bench -p benchmarks --bench"

.github/workflows/test.yaml

Lines changed: 88 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,25 @@ on:
77
branches: [main]
88

99
jobs:
10+
build-wasm:
11+
name: Build wasm
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
submodules: true
17+
- name: Install Rust toolchain & Binaryen
18+
run: rustup update && rustup target add wasm32-unknown-unknown && sudo apt-get install -y binaryen wabt
19+
- name: Build wasm
20+
run: ./examples/rust/build.sh
21+
- name: Save artifacts
22+
uses: actions/upload-artifact@v4
23+
with:
24+
name: wasm
25+
path: examples/rust/out
26+
1027
test-std:
28+
needs: build-wasm
1129
name: Test with default features on stable Rust
1230
runs-on: ubuntu-latest
1331

@@ -16,15 +34,14 @@ jobs:
1634
with:
1735
submodules: true
1836

19-
- name: Install stable Rust toolchain & Binaryen
20-
run: |
21-
rustup update stable
22-
rustup update nightly
23-
rustup target add wasm32-unknown-unknown
24-
sudo apt-get install -y binaryen wabt
37+
- name: Install latest stable Rust toolchain
38+
run: rustup update stable
2539

26-
- name: Build wasm
27-
run: ./examples/rust/build.sh
40+
- name: Load wasm
41+
uses: actions/download-artifact@v4
42+
with:
43+
name: wasm
44+
path: examples/rust/out
2845

2946
- name: Build (stable)
3047
run: cargo +stable build --workspace
@@ -36,6 +53,7 @@ jobs:
3653
run: cargo +stable test-mvp
3754

3855
test-no-std:
56+
needs: build-wasm
3957
name: Test without default features on nightly Rust
4058
runs-on: ubuntu-latest
4159

@@ -44,14 +62,14 @@ jobs:
4462
with:
4563
submodules: true
4664

47-
- name: Install nightly Rust toolchain & Binaryen
48-
run: |
49-
rustup update nightly
50-
rustup target add wasm32-unknown-unknown
51-
sudo apt-get install -y binaryen wabt
65+
- name: Install latest nightly Rust toolchain
66+
run: rustup update nightly
5267

53-
- name: Build wasm
54-
run: ./examples/rust/build.sh
68+
- name: Load wasm
69+
uses: actions/download-artifact@v4
70+
with:
71+
name: wasm
72+
path: examples/rust/out
5573

5674
- name: Build (nightly, no default features)
5775
run: cargo +nightly build --workspace --no-default-features
@@ -61,3 +79,58 @@ jobs:
6179

6280
- name: Run MVP testsuite (nightly)
6381
run: cargo +nightly test-mvp
82+
83+
test-m1:
84+
needs: build-wasm
85+
name: Test on arm64 (Apple M1)
86+
runs-on: macos-14
87+
steps:
88+
- uses: actions/checkout@v4
89+
with:
90+
submodules: true
91+
- name: Install stable Rust toolchain
92+
run: rustup update stable
93+
94+
- name: Load wasm
95+
uses: actions/download-artifact@v4
96+
with:
97+
name: wasm
98+
path: examples/rust/out
99+
100+
- name: Build (stable)
101+
run: cargo +stable build
102+
- name: Run tests (stable)
103+
run: cargo +stable test
104+
- name: Run MVP testsuite
105+
run: cargo +stable test-mvp
106+
107+
test-armv7:
108+
needs: build-wasm
109+
name: Test on armv7 (32-Bit Raspberry Pi)
110+
runs-on: ubuntu-latest
111+
112+
steps:
113+
- uses: actions/checkout@v4
114+
with:
115+
submodules: true
116+
117+
- name: Load wasm
118+
uses: actions/download-artifact@v4
119+
with:
120+
name: wasm
121+
path: examples/rust/out
122+
123+
- name: Run all tests (for the default workspace members)
124+
uses: houseabsolute/[email protected]
125+
with:
126+
command: test
127+
target: armv7-unknown-linux-gnueabihf
128+
toolchain: nightly
129+
130+
- name: Run MVP testsuite
131+
uses: houseabsolute/[email protected]
132+
with:
133+
command: test
134+
args: "-p tinywasm --test test-mvp --release -- --enable"
135+
target: armv7-unknown-linux-gnueabihf
136+
toolchain: nightly

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
### Changed
1313

1414
- Improved documentation and added more tests
15+
- Tests can now be run on more targets
16+
- Nightly version has been updated to fix broken builds in some cases
1517
- Enhance support for scripted language bindings by making Imports and Module cloneable
18+
- Add `aarch64-apple-darwin` and `armv7-unknown-linux-gnueabihf` targets to CI
1619

1720
### Removed
1821

@@ -75,7 +78,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7578

7679
**All Commits**: https://github.com/explodingcamera/tinywasm/compare/v0.1.0...v0.2.0
7780

78-
- Support for br_table
81+
- Support for `br_table`
7982
- Memory trapping improvements
8083
- Implicit function label scopes
8184
- else Instructions

Cargo.lock

Lines changed: 16 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members=["crates/*"]
2+
members=["crates/*", "benchmarks", "scripts"]
33
default-members=[".", "crates/tinywasm", "crates/types", "crates/parser"]
44
resolver="2"
55

@@ -40,4 +40,4 @@ debug=true
4040

4141
[patch.crates-io]
4242
# https://github.com/servo/pathfinder/pull/548 & https://github.com/servo/pathfinder/issues/558
43-
pathfinder_simd={git="https://github.com/explodingcamera/pathfinder", rev="4ada8c2484f6bdd2a57546f055000c2df8e65eab"}
43+
pathfinder_simd={git="https://github.com/servo/pathfinder", rev="30419d07660dc11a21e42ef4a7fa329600cff152"}

crates/benchmarks/Cargo.toml renamed to benchmarks/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition.workspace=true
55

66
[dependencies]
77
criterion={version="0.5", features=["html_reports"]}
8-
tinywasm={path="../../crates/tinywasm", features=["unsafe"]}
8+
tinywasm={path="../crates/tinywasm", features=["unsafe"]}
99
wat={version="1.0"}
1010
wasmi={version="0.31", features=["std"]}
1111
wasmer={version="4.2", features=["cranelift", "singlepass"]}

crates/benchmarks/benches/argon2id.rs renamed to benchmarks/benches/argon2id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn run_native(params: (i32, i32, i32)) {
3636
run_native(params.0, params.1, params.2)
3737
}
3838

39-
const ARGON2ID: &[u8] = include_bytes!("../../../examples/rust/out/argon2id.wasm");
39+
const ARGON2ID: &[u8] = include_bytes!("../../examples/rust/out/argon2id.wasm");
4040
fn criterion_benchmark(c: &mut Criterion) {
4141
let twasm = wasm_to_twasm(ARGON2ID);
4242
let params = (1000, 2, 1);

crates/benchmarks/benches/fibonacci.rs renamed to benchmarks/benches/fibonacci.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn run_native_recursive(n: i32) -> i32 {
4545
run_native_recursive(n - 1) + run_native_recursive(n - 2)
4646
}
4747

48-
const FIBONACCI: &[u8] = include_bytes!("../../../examples/rust/out/fibonacci.wasm");
48+
const FIBONACCI: &[u8] = include_bytes!("../../examples/rust/out/fibonacci.wasm");
4949
fn criterion_benchmark(c: &mut Criterion) {
5050
let twasm = wasm_to_twasm(FIBONACCI);
5151

crates/benchmarks/benches/selfhosted.rs renamed to benchmarks/benches/selfhosted.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use criterion::{criterion_group, criterion_main, Criterion};
44

55
fn run_native() {
66
use tinywasm::*;
7-
let module = tinywasm::Module::parse_bytes(include_bytes!("../../../examples/rust/out/print.wasm")).expect("parse");
7+
let module = tinywasm::Module::parse_bytes(include_bytes!("../../examples/rust/out/print.wasm")).expect("parse");
88
let mut store = Store::default();
99
let mut imports = Imports::default();
1010
imports.define("env", "printi32", Extern::typed_func(|_: FuncContext<'_>, _: i32| Ok(()))).expect("define");
@@ -51,7 +51,7 @@ fn run_wasmer(wasm: &[u8]) {
5151
hello.call(&mut store, &[]).expect("call");
5252
}
5353

54-
const TINYWASM: &[u8] = include_bytes!("../../../examples/rust/out/tinywasm.wasm");
54+
const TINYWASM: &[u8] = include_bytes!("../../examples/rust/out/tinywasm.wasm");
5555
fn criterion_benchmark(c: &mut Criterion) {
5656
{
5757
let mut group = c.benchmark_group("selfhosted-parse");

crates/benchmarks/benches/util/mod.rs renamed to benchmarks/benches/util/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(dead_code)]
22

3-
use tinywasm::{self, parser::Parser, types::TinyWasmModule};
3+
use tinywasm::{parser::Parser, types::TinyWasmModule};
44

55
pub fn parse_wasm(wasm: &[u8]) -> TinyWasmModule {
66
let parser = Parser::new();

0 commit comments

Comments
 (0)