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

Commit ac6b812

Browse files
tests: improve wast tests
Signed-off-by: Henry <[email protected]>
1 parent 295a48c commit ac6b812

File tree

12 files changed

+103
-49
lines changed

12 files changed

+103
-49
lines changed

.cargo/config.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
version-dev="workspaces version --no-git-commit --force tinywasm*"
33
dev="run -- -l debug run"
44

5-
test-mvp="test --package tinywasm --test mvp -- test_mvp --exact --nocapture --ignored"
6-
generate-charts="test --package tinywasm --test mvp -- generate_charts --ignored"
5+
test-mvp="test --package tinywasm --test test-mvp"
6+
test-wast="test --package tinywasm --test test-wast --"
7+
generate-charts="test --package tinywasm --test generate-charts"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
I'm currently working on supporting the WebAssembly MVP (1.0) specification. You can see the current status in the graph below. The goal is to support all the features of the MVP specification and then move on to the next version.
1919

2020
<p align="center">
21-
<a href="https://raw.githubusercontent.com/explodingcamera/tinywasm/main/crates/tinywasm/tests/progress-mvp.svg">
22-
<img align="center" src="./crates/tinywasm/tests/progress-mvp.svg" width="800" alt="">
21+
<a href="https://raw.githubusercontent.com/explodingcamera/tinywasm/main/crates/tinywasm/tests/generated/progress-mvp.svg">
22+
<img align="center" src="./crates/tinywasm/tests/generated/progress-mvp.svg" width="800" alt="">
2323
</a>
2424
</p>
2525

crates/parser/src/conversion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ pub(crate) fn process_const_operators(ops: OperatorsReader) -> Result<ConstInstr
242242
assert!(ops.len() >= 2);
243243
assert!(matches!(ops[ops.len() - 1], wasmparser::Operator::End));
244244

245-
Ok(process_const_operator(ops[ops.len() - 2].clone())?)
245+
process_const_operator(ops[ops.len() - 2].clone())
246246
}
247247

248248
pub fn process_const_operator(op: wasmparser::Operator) -> Result<ConstInstruction> {

crates/tinywasm/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,15 @@ default=["std", "parser", "logging"]
3131
logging=["log", "tinywasm-types/logging", "tinywasm-parser?/logging"]
3232
std=["tinywasm-parser?/std", "tinywasm-types/std"]
3333
parser=["tinywasm-parser"]
34+
35+
[[test]]
36+
name="generate-charts"
37+
harness=false
38+
39+
[[test]]
40+
name="test-mvp"
41+
harness=false
42+
43+
[[test]]
44+
name="test-wast"
45+
harness=false

crates/tinywasm/src/runtime/executor/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,11 @@ fn exec_one(
307307
I32DivU => checked_arithmetic_cast!(checked_div, i32, u32, stack, crate::Trap::DivisionByZero),
308308
I64DivU => checked_arithmetic_cast!(checked_div, i64, u64, stack, crate::Trap::DivisionByZero),
309309

310+
I32RemS => checked_arithmetic!(checked_rem, i32, stack, crate::Trap::DivisionByZero),
311+
I64RemS => checked_arithmetic!(checked_rem, i64, stack, crate::Trap::DivisionByZero),
312+
I32RemU => checked_arithmetic_cast!(checked_rem, i32, u32, stack, crate::Trap::DivisionByZero),
313+
I64RemU => checked_arithmetic_cast!(checked_rem, i64, u64, stack, crate::Trap::DivisionByZero),
314+
310315
F32ConvertI32S => conv_1!(i32, f32, stack),
311316
F32ConvertI64S => conv_1!(i64, f32, stack),
312317
F64ConvertI32S => conv_1!(i32, f64, stack),
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
mod charts;
2+
use eyre::Result;
3+
4+
fn main() -> Result<()> {
5+
generate_charts()
6+
}
7+
8+
fn generate_charts() -> Result<()> {
9+
// Create a line chart
10+
charts::create_progress_chart(
11+
std::path::Path::new("./tests/generated/mvp.csv"),
12+
std::path::Path::new("./tests/generated/progress-mvp.svg"),
13+
)?;
14+
15+
Ok(())
16+
}

crates/tinywasm/tests/mvp.csv renamed to crates/tinywasm/tests/generated/mvp.csv

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

crates/tinywasm/tests/progress-mvp.svg renamed to crates/tinywasm/tests/generated/progress-mvp.svg

Lines changed: 2 additions & 2 deletions
Loading

crates/tinywasm/tests/mvp.rs

Lines changed: 0 additions & 40 deletions
This file was deleted.

crates/tinywasm/tests/test-mvp.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
mod testsuite;
2+
use eyre::{eyre, Result};
3+
use testsuite::TestSuite;
4+
5+
fn main() -> Result<()> {
6+
test_mvp()
7+
}
8+
9+
fn test_mvp() -> Result<()> {
10+
let mut test_suite = TestSuite::new();
11+
12+
test_suite.run(wasm_testsuite::MVP_TESTS)?;
13+
test_suite.save_csv("./tests/generated/mvp.csv", env!("CARGO_PKG_VERSION"))?;
14+
15+
if test_suite.failed() {
16+
eprintln!("\n\nfailed one or more tests:\n{:#?}", test_suite);
17+
Err(eyre!("failed one or more tests"))
18+
} else {
19+
println!("\n\npassed all tests:\n{:#?}", test_suite);
20+
Ok(())
21+
}
22+
}

0 commit comments

Comments
 (0)