summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.cargo/config.toml5
-rw-r--r--README.md4
-rw-r--r--crates/parser/src/conversion.rs2
-rw-r--r--crates/tinywasm/Cargo.toml12
-rw-r--r--crates/tinywasm/src/runtime/executor/mod.rs5
-rw-r--r--crates/tinywasm/tests/generate-charts.rs16
-rw-r--r--crates/tinywasm/tests/generated/mvp.csv (renamed from crates/tinywasm/tests/mvp.csv)2
-rw-r--r--crates/tinywasm/tests/generated/progress-mvp.svg (renamed from crates/tinywasm/tests/progress-mvp.svg)4
-rw-r--r--crates/tinywasm/tests/mvp.rs40
-rw-r--r--crates/tinywasm/tests/test-mvp.rs22
-rw-r--r--crates/tinywasm/tests/test-wast.rs31
-rw-r--r--crates/tinywasm/tests/testsuite/run.rs9
12 files changed, 103 insertions, 49 deletions
diff --git a/.cargo/config.toml b/.cargo/config.toml
index f9691ee..743421a 100644
--- a/.cargo/config.toml
+++ b/.cargo/config.toml
@@ -2,5 +2,6 @@
version-dev="workspaces version --no-git-commit --force tinywasm*"
dev="run -- -l debug run"
-test-mvp="test --package tinywasm --test mvp -- test_mvp --exact --nocapture --ignored"
-generate-charts="test --package tinywasm --test mvp -- generate_charts --ignored"
+test-mvp="test --package tinywasm --test test-mvp"
+test-wast="test --package tinywasm --test test-wast --"
+generate-charts="test --package tinywasm --test generate-charts"
diff --git a/README.md b/README.md
index e272fff..00b828e 100644
--- a/README.md
+++ b/README.md
@@ -18,8 +18,8 @@
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.
<p align="center">
- <a href="https://raw.githubusercontent.com/explodingcamera/tinywasm/main/crates/tinywasm/tests/progress-mvp.svg">
- <img align="center" src="./crates/tinywasm/tests/progress-mvp.svg" width="800" alt="">
+ <a href="https://raw.githubusercontent.com/explodingcamera/tinywasm/main/crates/tinywasm/tests/generated/progress-mvp.svg">
+ <img align="center" src="./crates/tinywasm/tests/generated/progress-mvp.svg" width="800" alt="">
</a>
</p>
diff --git a/crates/parser/src/conversion.rs b/crates/parser/src/conversion.rs
index 7d3215d..700cb0c 100644
--- a/crates/parser/src/conversion.rs
+++ b/crates/parser/src/conversion.rs
@@ -242,7 +242,7 @@ pub(crate) fn process_const_operators(ops: OperatorsReader) -> Result<ConstInstr
assert!(ops.len() >= 2);
assert!(matches!(ops[ops.len() - 1], wasmparser::Operator::End));
- Ok(process_const_operator(ops[ops.len() - 2].clone())?)
+ process_const_operator(ops[ops.len() - 2].clone())
}
pub fn process_const_operator(op: wasmparser::Operator) -> Result<ConstInstruction> {
diff --git a/crates/tinywasm/Cargo.toml b/crates/tinywasm/Cargo.toml
index 77f4247..852c31c 100644
--- a/crates/tinywasm/Cargo.toml
+++ b/crates/tinywasm/Cargo.toml
@@ -31,3 +31,15 @@ default=["std", "parser", "logging"]
logging=["log", "tinywasm-types/logging", "tinywasm-parser?/logging"]
std=["tinywasm-parser?/std", "tinywasm-types/std"]
parser=["tinywasm-parser"]
+
+[[test]]
+name="generate-charts"
+harness=false
+
+[[test]]
+name="test-mvp"
+harness=false
+
+[[test]]
+name="test-wast"
+harness=false
diff --git a/crates/tinywasm/src/runtime/executor/mod.rs b/crates/tinywasm/src/runtime/executor/mod.rs
index 93ebbd2..7f916f5 100644
--- a/crates/tinywasm/src/runtime/executor/mod.rs
+++ b/crates/tinywasm/src/runtime/executor/mod.rs
@@ -307,6 +307,11 @@ fn exec_one(
I32DivU => checked_arithmetic_cast!(checked_div, i32, u32, stack, crate::Trap::DivisionByZero),
I64DivU => checked_arithmetic_cast!(checked_div, i64, u64, stack, crate::Trap::DivisionByZero),
+ I32RemS => checked_arithmetic!(checked_rem, i32, stack, crate::Trap::DivisionByZero),
+ I64RemS => checked_arithmetic!(checked_rem, i64, stack, crate::Trap::DivisionByZero),
+ I32RemU => checked_arithmetic_cast!(checked_rem, i32, u32, stack, crate::Trap::DivisionByZero),
+ I64RemU => checked_arithmetic_cast!(checked_rem, i64, u64, stack, crate::Trap::DivisionByZero),
+
F32ConvertI32S => conv_1!(i32, f32, stack),
F32ConvertI64S => conv_1!(i64, f32, stack),
F64ConvertI32S => conv_1!(i32, f64, stack),
diff --git a/crates/tinywasm/tests/generate-charts.rs b/crates/tinywasm/tests/generate-charts.rs
new file mode 100644
index 0000000..f80b092
--- /dev/null
+++ b/crates/tinywasm/tests/generate-charts.rs
@@ -0,0 +1,16 @@
+mod charts;
+use eyre::Result;
+
+fn main() -> Result<()> {
+ generate_charts()
+}
+
+fn generate_charts() -> Result<()> {
+ // Create a line chart
+ charts::create_progress_chart(
+ std::path::Path::new("./tests/generated/mvp.csv"),
+ std::path::Path::new("./tests/generated/progress-mvp.svg"),
+ )?;
+
+ Ok(())
+}
diff --git a/crates/tinywasm/tests/mvp.csv b/crates/tinywasm/tests/generated/mvp.csv
index fccb69d..37ea08e 100644
--- a/crates/tinywasm/tests/mvp.csv
+++ b/crates/tinywasm/tests/generated/mvp.csv
@@ -1,4 +1,4 @@
0.0.3,9258,7567,[{"name":"address.wast","passed":0,"failed":54},{"name":"align.wast","passed":0,"failed":109},{"name":"binary-leb128.wast","passed":66,"failed":25},{"name":"binary.wast","passed":104,"failed":8},{"name":"block.wast","passed":0,"failed":171},{"name":"br.wast","passed":0,"failed":21},{"name":"br_if.wast","passed":0,"failed":30},{"name":"br_table.wast","passed":0,"failed":25},{"name":"call.wast","passed":0,"failed":22},{"name":"call_indirect.wast","passed":0,"failed":56},{"name":"comments.wast","passed":4,"failed":4},{"name":"const.wast","passed":702,"failed":76},{"name":"conversions.wast","passed":0,"failed":93},{"name":"custom.wast","passed":10,"failed":1},{"name":"data.wast","passed":0,"failed":61},{"name":"elem.wast","passed":0,"failed":76},{"name":"endianness.wast","passed":0,"failed":1},{"name":"exports.wast","passed":21,"failed":73},{"name":"f32.wast","passed":1005,"failed":1509},{"name":"f32_bitwise.wast","passed":1,"failed":363},{"name":"f32_cmp.wast","passed":2401,"failed":6},{"name":"f64.wast","passed":1005,"failed":1509},{"name":"f64_bitwise.wast","passed":1,"failed":363},{"name":"f64_cmp.wast","passed":2401,"failed":6},{"name":"fac.wast","passed":0,"failed":2},{"name":"float_exprs.wast","passed":269,"failed":591},{"name":"float_literals.wast","passed":34,"failed":129},{"name":"float_memory.wast","passed":0,"failed":6},{"name":"float_misc.wast","passed":138,"failed":303},{"name":"forward.wast","passed":1,"failed":4},{"name":"func.wast","passed":4,"failed":75},{"name":"func_ptrs.wast","passed":0,"failed":16},{"name":"global.wast","passed":4,"failed":49},{"name":"i32.wast","passed":0,"failed":96},{"name":"i64.wast","passed":0,"failed":42},{"name":"if.wast","passed":0,"failed":118},{"name":"imports.wast","passed":1,"failed":156},{"name":"inline-module.wast","passed":0,"failed":1},{"name":"int_exprs.wast","passed":38,"failed":70},{"name":"int_literals.wast","passed":5,"failed":46},{"name":"labels.wast","passed":1,"failed":28},{"name":"left-to-right.wast","passed":0,"failed":1},{"name":"linking.wast","passed":1,"failed":66},{"name":"load.wast","passed":0,"failed":60},{"name":"local_get.wast","passed":2,"failed":34},{"name":"local_set.wast","passed":5,"failed":48},{"name":"local_tee.wast","passed":0,"failed":42},{"name":"loop.wast","passed":0,"failed":43},{"name":"memory.wast","passed":0,"failed":34},{"name":"memory_grow.wast","passed":0,"failed":19},{"name":"memory_redundancy.wast","passed":0,"failed":1},{"name":"memory_size.wast","passed":0,"failed":6},{"name":"memory_trap.wast","passed":0,"failed":172},{"name":"names.wast","passed":484,"failed":1},{"name":"nop.wast","passed":0,"failed":5},{"name":"return.wast","passed":0,"failed":21},{"name":"select.wast","passed":0,"failed":32},{"name":"skip-stack-guard-page.wast","passed":0,"failed":11},{"name":"stack.wast","passed":0,"failed":2},{"name":"start.wast","passed":0,"failed":10},{"name":"store.wast","passed":0,"failed":59},{"name":"switch.wast","passed":1,"failed":27},{"name":"token.wast","passed":16,"failed":42},{"name":"traps.wast","passed":3,"failed":33},{"name":"type.wast","passed":1,"failed":2},{"name":"unreachable.wast","passed":0,"failed":59},{"name":"unreached-invalid.wast","passed":0,"failed":118},{"name":"unwind.wast","passed":1,"failed":49},{"name":"utf8-custom-section-id.wast","passed":176,"failed":0},{"name":"utf8-import-field.wast","passed":176,"failed":0},{"name":"utf8-import-module.wast","passed":176,"failed":0},{"name":"utf8-invalid-encoding.wast","passed":0,"failed":176}]
0.0.4,9258,10909,[{"name":"address.wast","passed":0,"failed":54},{"name":"align.wast","passed":0,"failed":109},{"name":"binary-leb128.wast","passed":66,"failed":25},{"name":"binary.wast","passed":104,"failed":8},{"name":"block.wast","passed":0,"failed":171},{"name":"br.wast","passed":0,"failed":21},{"name":"br_if.wast","passed":0,"failed":30},{"name":"br_table.wast","passed":0,"failed":25},{"name":"call.wast","passed":0,"failed":22},{"name":"call_indirect.wast","passed":0,"failed":56},{"name":"comments.wast","passed":4,"failed":4},{"name":"const.wast","passed":702,"failed":76},{"name":"conversions.wast","passed":0,"failed":93},{"name":"custom.wast","passed":10,"failed":1},{"name":"data.wast","passed":0,"failed":61},{"name":"elem.wast","passed":0,"failed":76},{"name":"endianness.wast","passed":0,"failed":1},{"name":"exports.wast","passed":21,"failed":73},{"name":"f32.wast","passed":1005,"failed":1509},{"name":"f32_bitwise.wast","passed":1,"failed":363},{"name":"f32_cmp.wast","passed":2401,"failed":6},{"name":"f64.wast","passed":1005,"failed":1509},{"name":"f64_bitwise.wast","passed":1,"failed":363},{"name":"f64_cmp.wast","passed":2401,"failed":6},{"name":"fac.wast","passed":0,"failed":2},{"name":"float_exprs.wast","passed":269,"failed":591},{"name":"float_literals.wast","passed":34,"failed":129},{"name":"float_memory.wast","passed":0,"failed":6},{"name":"float_misc.wast","passed":138,"failed":303},{"name":"forward.wast","passed":1,"failed":4},{"name":"func.wast","passed":4,"failed":75},{"name":"func_ptrs.wast","passed":0,"failed":16},{"name":"global.wast","passed":4,"failed":49},{"name":"i32.wast","passed":0,"failed":96},{"name":"i64.wast","passed":0,"failed":42},{"name":"if.wast","passed":0,"failed":118},{"name":"imports.wast","passed":1,"failed":156},{"name":"inline-module.wast","passed":0,"failed":1},{"name":"int_exprs.wast","passed":38,"failed":70},{"name":"int_literals.wast","passed":5,"failed":46},{"name":"labels.wast","passed":1,"failed":28},{"name":"left-to-right.wast","passed":0,"failed":1},{"name":"linking.wast","passed":1,"failed":66},{"name":"load.wast","passed":0,"failed":60},{"name":"local_get.wast","passed":2,"failed":34},{"name":"local_set.wast","passed":5,"failed":48},{"name":"local_tee.wast","passed":0,"failed":42},{"name":"loop.wast","passed":0,"failed":43},{"name":"memory.wast","passed":0,"failed":34},{"name":"memory_grow.wast","passed":0,"failed":19},{"name":"memory_redundancy.wast","passed":0,"failed":1},{"name":"memory_size.wast","passed":0,"failed":6},{"name":"memory_trap.wast","passed":0,"failed":172},{"name":"names.wast","passed":484,"failed":1},{"name":"nop.wast","passed":0,"failed":5},{"name":"return.wast","passed":0,"failed":21},{"name":"select.wast","passed":0,"failed":32},{"name":"skip-stack-guard-page.wast","passed":0,"failed":11},{"name":"stack.wast","passed":0,"failed":2},{"name":"start.wast","passed":0,"failed":10},{"name":"store.wast","passed":0,"failed":59},{"name":"switch.wast","passed":1,"failed":27},{"name":"token.wast","passed":16,"failed":42},{"name":"traps.wast","passed":3,"failed":33},{"name":"type.wast","passed":1,"failed":2},{"name":"unreachable.wast","passed":0,"failed":59},{"name":"unreached-invalid.wast","passed":0,"failed":118},{"name":"unwind.wast","passed":1,"failed":49},{"name":"utf8-custom-section-id.wast","passed":176,"failed":0},{"name":"utf8-import-field.wast","passed":176,"failed":0},{"name":"utf8-import-module.wast","passed":176,"failed":0},{"name":"utf8-invalid-encoding.wast","passed":0,"failed":176}]
0.0.5,11135,9093,[{"name":"address.wast","passed":1,"failed":259},{"name":"align.wast","passed":108,"failed":48},{"name":"binary-leb128.wast","passed":78,"failed":13},{"name":"binary.wast","passed":107,"failed":5},{"name":"block.wast","passed":170,"failed":53},{"name":"br.wast","passed":20,"failed":77},{"name":"br_if.wast","passed":29,"failed":89},{"name":"br_table.wast","passed":24,"failed":150},{"name":"call.wast","passed":18,"failed":73},{"name":"call_indirect.wast","passed":34,"failed":136},{"name":"comments.wast","passed":5,"failed":3},{"name":"const.wast","passed":778,"failed":0},{"name":"conversions.wast","passed":25,"failed":594},{"name":"custom.wast","passed":10,"failed":1},{"name":"data.wast","passed":22,"failed":39},{"name":"elem.wast","passed":27,"failed":72},{"name":"endianness.wast","passed":1,"failed":68},{"name":"exports.wast","passed":90,"failed":6},{"name":"f32.wast","passed":1018,"failed":1496},{"name":"f32_bitwise.wast","passed":4,"failed":360},{"name":"f32_cmp.wast","passed":2407,"failed":0},{"name":"f64.wast","passed":1018,"failed":1496},{"name":"f64_bitwise.wast","passed":4,"failed":360},{"name":"f64_cmp.wast","passed":2407,"failed":0},{"name":"fac.wast","passed":1,"failed":7},{"name":"float_exprs.wast","passed":275,"failed":625},{"name":"float_literals.wast","passed":112,"failed":51},{"name":"float_memory.wast","passed":0,"failed":90},{"name":"float_misc.wast","passed":138,"failed":303},{"name":"forward.wast","passed":1,"failed":4},{"name":"func.wast","passed":81,"failed":91},{"name":"func_ptrs.wast","passed":7,"failed":29},{"name":"global.wast","passed":50,"failed":60},{"name":"i32.wast","passed":85,"failed":375},{"name":"i64.wast","passed":31,"failed":385},{"name":"if.wast","passed":116,"failed":125},{"name":"imports.wast","passed":23,"failed":160},{"name":"inline-module.wast","passed":1,"failed":0},{"name":"int_exprs.wast","passed":38,"failed":70},{"name":"int_literals.wast","passed":25,"failed":26},{"name":"labels.wast","passed":13,"failed":16},{"name":"left-to-right.wast","passed":0,"failed":96},{"name":"linking.wast","passed":5,"failed":127},{"name":"load.wast","passed":59,"failed":38},{"name":"local_get.wast","passed":18,"failed":18},{"name":"local_set.wast","passed":38,"failed":15},{"name":"local_tee.wast","passed":41,"failed":56},{"name":"loop.wast","passed":42,"failed":78},{"name":"memory.wast","passed":30,"failed":49},{"name":"memory_grow.wast","passed":11,"failed":85},{"name":"memory_redundancy.wast","passed":1,"failed":7},{"name":"memory_size.wast","passed":6,"failed":36},{"name":"memory_trap.wast","passed":1,"failed":181},{"name":"names.wast","passed":484,"failed":2},{"name":"nop.wast","passed":4,"failed":84},{"name":"return.wast","passed":20,"failed":64},{"name":"select.wast","passed":28,"failed":120},{"name":"skip-stack-guard-page.wast","passed":1,"failed":10},{"name":"stack.wast","passed":2,"failed":5},{"name":"start.wast","passed":4,"failed":16},{"name":"store.wast","passed":59,"failed":9},{"name":"switch.wast","passed":2,"failed":26},{"name":"token.wast","passed":39,"failed":19},{"name":"traps.wast","passed":4,"failed":32},{"name":"type.wast","passed":3,"failed":0},{"name":"unreachable.wast","passed":0,"failed":64},{"name":"unreached-invalid.wast","passed":118,"failed":0},{"name":"unwind.wast","passed":9,"failed":41},{"name":"utf8-custom-section-id.wast","passed":176,"failed":0},{"name":"utf8-import-field.wast","passed":176,"failed":0},{"name":"utf8-import-module.wast","passed":176,"failed":0},{"name":"utf8-invalid-encoding.wast","passed":176,"failed":0}]
-0.0.6-alpha.0,11273,8955,[{"name":"address.wast","passed":5,"failed":255},{"name":"align.wast","passed":108,"failed":48},{"name":"binary-leb128.wast","passed":85,"failed":6},{"name":"binary.wast","passed":109,"failed":3},{"name":"block.wast","passed":170,"failed":53},{"name":"br.wast","passed":20,"failed":77},{"name":"br_if.wast","passed":29,"failed":89},{"name":"br_table.wast","passed":24,"failed":150},{"name":"call.wast","passed":18,"failed":73},{"name":"call_indirect.wast","passed":34,"failed":136},{"name":"comments.wast","passed":5,"failed":3},{"name":"const.wast","passed":778,"failed":0},{"name":"conversions.wast","passed":25,"failed":594},{"name":"custom.wast","passed":10,"failed":1},{"name":"data.wast","passed":47,"failed":14},{"name":"elem.wast","passed":27,"failed":72},{"name":"endianness.wast","passed":1,"failed":68},{"name":"exports.wast","passed":90,"failed":6},{"name":"f32.wast","passed":1018,"failed":1496},{"name":"f32_bitwise.wast","passed":4,"failed":360},{"name":"f32_cmp.wast","passed":2407,"failed":0},{"name":"f64.wast","passed":1018,"failed":1496},{"name":"f64_bitwise.wast","passed":4,"failed":360},{"name":"f64_cmp.wast","passed":2407,"failed":0},{"name":"fac.wast","passed":1,"failed":7},{"name":"float_exprs.wast","passed":279,"failed":621},{"name":"float_literals.wast","passed":112,"failed":51},{"name":"float_memory.wast","passed":6,"failed":84},{"name":"float_misc.wast","passed":138,"failed":303},{"name":"forward.wast","passed":1,"failed":4},{"name":"func.wast","passed":81,"failed":91},{"name":"func_ptrs.wast","passed":8,"failed":28},{"name":"global.wast","passed":51,"failed":59},{"name":"i32.wast","passed":85,"failed":375},{"name":"i64.wast","passed":31,"failed":385},{"name":"if.wast","passed":116,"failed":125},{"name":"imports.wast","passed":71,"failed":112},{"name":"inline-module.wast","passed":1,"failed":0},{"name":"int_exprs.wast","passed":38,"failed":70},{"name":"int_literals.wast","passed":25,"failed":26},{"name":"labels.wast","passed":13,"failed":16},{"name":"left-to-right.wast","passed":0,"failed":96},{"name":"linking.wast","passed":17,"failed":115},{"name":"load.wast","passed":59,"failed":38},{"name":"local_get.wast","passed":18,"failed":18},{"name":"local_set.wast","passed":38,"failed":15},{"name":"local_tee.wast","passed":41,"failed":56},{"name":"loop.wast","passed":42,"failed":78},{"name":"memory.wast","passed":34,"failed":45},{"name":"memory_grow.wast","passed":11,"failed":85},{"name":"memory_redundancy.wast","passed":1,"failed":7},{"name":"memory_size.wast","passed":6,"failed":36},{"name":"memory_trap.wast","passed":2,"failed":180},{"name":"names.wast","passed":485,"failed":1},{"name":"nop.wast","passed":4,"failed":84},{"name":"return.wast","passed":20,"failed":64},{"name":"select.wast","passed":28,"failed":120},{"name":"skip-stack-guard-page.wast","passed":1,"failed":10},{"name":"stack.wast","passed":2,"failed":5},{"name":"start.wast","passed":9,"failed":11},{"name":"store.wast","passed":59,"failed":9},{"name":"switch.wast","passed":2,"failed":26},{"name":"token.wast","passed":56,"failed":2},{"name":"traps.wast","passed":4,"failed":32},{"name":"type.wast","passed":3,"failed":0},{"name":"unreachable.wast","passed":0,"failed":64},{"name":"unreached-invalid.wast","passed":118,"failed":0},{"name":"unwind.wast","passed":9,"failed":41},{"name":"utf8-custom-section-id.wast","passed":176,"failed":0},{"name":"utf8-import-field.wast","passed":176,"failed":0},{"name":"utf8-import-module.wast","passed":176,"failed":0},{"name":"utf8-invalid-encoding.wast","passed":176,"failed":0}]
+0.0.6-alpha.0,11286,8942,[{"name":"address.wast","passed":5,"failed":255},{"name":"align.wast","passed":108,"failed":48},{"name":"binary-leb128.wast","passed":85,"failed":6},{"name":"binary.wast","passed":109,"failed":3},{"name":"block.wast","passed":170,"failed":53},{"name":"br.wast","passed":20,"failed":77},{"name":"br_if.wast","passed":29,"failed":89},{"name":"br_table.wast","passed":24,"failed":150},{"name":"call.wast","passed":18,"failed":73},{"name":"call_indirect.wast","passed":34,"failed":136},{"name":"comments.wast","passed":5,"failed":3},{"name":"const.wast","passed":778,"failed":0},{"name":"conversions.wast","passed":25,"failed":594},{"name":"custom.wast","passed":10,"failed":1},{"name":"data.wast","passed":47,"failed":14},{"name":"elem.wast","passed":27,"failed":72},{"name":"endianness.wast","passed":1,"failed":68},{"name":"exports.wast","passed":90,"failed":6},{"name":"f32.wast","passed":1018,"failed":1496},{"name":"f32_bitwise.wast","passed":4,"failed":360},{"name":"f32_cmp.wast","passed":2407,"failed":0},{"name":"f64.wast","passed":1018,"failed":1496},{"name":"f64_bitwise.wast","passed":4,"failed":360},{"name":"f64_cmp.wast","passed":2407,"failed":0},{"name":"fac.wast","passed":1,"failed":7},{"name":"float_exprs.wast","passed":279,"failed":621},{"name":"float_literals.wast","passed":112,"failed":51},{"name":"float_memory.wast","passed":6,"failed":84},{"name":"float_misc.wast","passed":138,"failed":303},{"name":"forward.wast","passed":1,"failed":4},{"name":"func.wast","passed":81,"failed":91},{"name":"func_ptrs.wast","passed":8,"failed":28},{"name":"global.wast","passed":51,"failed":59},{"name":"i32.wast","passed":85,"failed":375},{"name":"i64.wast","passed":31,"failed":385},{"name":"if.wast","passed":116,"failed":125},{"name":"imports.wast","passed":71,"failed":112},{"name":"inline-module.wast","passed":1,"failed":0},{"name":"int_exprs.wast","passed":51,"failed":57},{"name":"int_literals.wast","passed":25,"failed":26},{"name":"labels.wast","passed":13,"failed":16},{"name":"left-to-right.wast","passed":0,"failed":96},{"name":"linking.wast","passed":17,"failed":115},{"name":"load.wast","passed":59,"failed":38},{"name":"local_get.wast","passed":18,"failed":18},{"name":"local_set.wast","passed":38,"failed":15},{"name":"local_tee.wast","passed":41,"failed":56},{"name":"loop.wast","passed":42,"failed":78},{"name":"memory.wast","passed":34,"failed":45},{"name":"memory_grow.wast","passed":11,"failed":85},{"name":"memory_redundancy.wast","passed":1,"failed":7},{"name":"memory_size.wast","passed":6,"failed":36},{"name":"memory_trap.wast","passed":2,"failed":180},{"name":"names.wast","passed":485,"failed":1},{"name":"nop.wast","passed":4,"failed":84},{"name":"return.wast","passed":20,"failed":64},{"name":"select.wast","passed":28,"failed":120},{"name":"skip-stack-guard-page.wast","passed":1,"failed":10},{"name":"stack.wast","passed":2,"failed":5},{"name":"start.wast","passed":9,"failed":11},{"name":"store.wast","passed":59,"failed":9},{"name":"switch.wast","passed":2,"failed":26},{"name":"token.wast","passed":56,"failed":2},{"name":"traps.wast","passed":4,"failed":32},{"name":"type.wast","passed":3,"failed":0},{"name":"unreachable.wast","passed":0,"failed":64},{"name":"unreached-invalid.wast","passed":118,"failed":0},{"name":"unwind.wast","passed":9,"failed":41},{"name":"utf8-custom-section-id.wast","passed":176,"failed":0},{"name":"utf8-import-field.wast","passed":176,"failed":0},{"name":"utf8-import-module.wast","passed":176,"failed":0},{"name":"utf8-invalid-encoding.wast","passed":176,"failed":0}]
diff --git a/crates/tinywasm/tests/progress-mvp.svg b/crates/tinywasm/tests/generated/progress-mvp.svg
index 7ea5e5d..8715df5 100644
--- a/crates/tinywasm/tests/progress-mvp.svg
+++ b/crates/tinywasm/tests/generated/progress-mvp.svg
@@ -49,11 +49,11 @@ v0.0.5 (11135)
</text>
<polyline fill="none" opacity="1" stroke="#000000" stroke-width="1" points="648,345 648,350 "/>
<text x="875" y="355" dy="0.76em" text-anchor="middle" font-family="Victor Mono" font-size="12.096774193548388" opacity="1" fill="#000000">
-v0.0.6-alpha.0 (11273)
+v0.0.6-alpha.0 (11286)
</text>
<polyline fill="none" opacity="1" stroke="#000000" stroke-width="1" points="875,345 875,350 "/>
<rect x="85" y="212" width="217" height="132" opacity="0.5" fill="#0000FF" stroke="none"/>
-<rect x="312" y="212" width="217" height="132" opacity="0.5" fill="#0000FF" stroke="none"/>
<rect x="767" y="183" width="217" height="161" opacity="0.5" fill="#0000FF" stroke="none"/>
+<rect x="312" y="212" width="217" height="132" opacity="0.5" fill="#0000FF" stroke="none"/>
<rect x="539" y="185" width="218" height="159" opacity="0.5" fill="#0000FF" stroke="none"/>
</svg>
diff --git a/crates/tinywasm/tests/mvp.rs b/crates/tinywasm/tests/mvp.rs
deleted file mode 100644
index e02436f..0000000
--- a/crates/tinywasm/tests/mvp.rs
+++ /dev/null
@@ -1,40 +0,0 @@
-mod charts;
-mod testsuite;
-
-use eyre::{eyre, Result};
-use testsuite::TestSuite;
-
-#[test]
-#[ignore]
-fn generate_charts() -> Result<()> {
- // Create a line chart
- charts::create_progress_chart(
- std::path::Path::new("./tests/mvp.csv"),
- std::path::Path::new("./tests/progress-mvp.svg"),
- )?;
-
- // // Create a bar chart
- // charts::create_bar_chart(
- // std::path::Path::new("./tests/mvp.csv"),
- // std::path::Path::new("./tests/mvp_bar_chart.png"),
- // )?;
-
- Ok(())
-}
-
-#[test]
-#[ignore]
-fn test_mvp() -> Result<()> {
- let mut test_suite = TestSuite::new();
-
- test_suite.run(wasm_testsuite::MVP_TESTS)?;
- test_suite.save_csv("./tests/mvp.csv", env!("CARGO_PKG_VERSION"))?;
-
- if test_suite.failed() {
- eprintln!("\n\nfailed one or more tests:\n{:#?}", test_suite);
- Err(eyre!("failed one or more tests"))
- } else {
- println!("\n\npassed all tests:\n{:#?}", test_suite);
- Ok(())
- }
-}
diff --git a/crates/tinywasm/tests/test-mvp.rs b/crates/tinywasm/tests/test-mvp.rs
new file mode 100644
index 0000000..eab372b
--- /dev/null
+++ b/crates/tinywasm/tests/test-mvp.rs
@@ -0,0 +1,22 @@
+mod testsuite;
+use eyre::{eyre, Result};
+use testsuite::TestSuite;
+
+fn main() -> Result<()> {
+ test_mvp()
+}
+
+fn test_mvp() -> Result<()> {
+ let mut test_suite = TestSuite::new();
+
+ test_suite.run(wasm_testsuite::MVP_TESTS)?;
+ test_suite.save_csv("./tests/generated/mvp.csv", env!("CARGO_PKG_VERSION"))?;
+
+ if test_suite.failed() {
+ eprintln!("\n\nfailed one or more tests:\n{:#?}", test_suite);
+ Err(eyre!("failed one or more tests"))
+ } else {
+ println!("\n\npassed all tests:\n{:#?}", test_suite);
+ Ok(())
+ }
+}
diff --git a/crates/tinywasm/tests/test-wast.rs b/crates/tinywasm/tests/test-wast.rs
new file mode 100644
index 0000000..47e7d95
--- /dev/null
+++ b/crates/tinywasm/tests/test-wast.rs
@@ -0,0 +1,31 @@
+use eyre::{bail, Result};
+use testsuite::TestSuite;
+
+mod testsuite;
+
+fn main() -> Result<()> {
+ let args = std::env::args().collect::<Vec<_>>();
+ if args.len() < 2 {
+ bail!("usage: cargo test-wast <wast-file>")
+ }
+
+ let wast_file = &args[1];
+ test_wast(wast_file)?;
+ Ok(())
+}
+
+fn test_wast(wast_file: &str) -> Result<()> {
+ let args = std::env::args().collect::<Vec<_>>();
+ println!("args: {:?}", args);
+
+ let mut test_suite = TestSuite::new();
+ test_suite.run(&[wast_file])?;
+
+ if test_suite.failed() {
+ eprintln!("\n\nfailed one or more tests:\n{:#?}", test_suite);
+ bail!("failed one or more tests")
+ } else {
+ println!("\n\npassed all tests:\n{:#?}", test_suite);
+ Ok(())
+ }
+}
diff --git a/crates/tinywasm/tests/testsuite/run.rs b/crates/tinywasm/tests/testsuite/run.rs
index ec4715b..23c470c 100644
--- a/crates/tinywasm/tests/testsuite/run.rs
+++ b/crates/tinywasm/tests/testsuite/run.rs
@@ -1,4 +1,5 @@
use crate::testsuite::util::*;
+use std::borrow::Cow;
use super::TestSuite;
use eyre::{eyre, Result};
@@ -10,7 +11,13 @@ impl TestSuite {
tests.iter().for_each(|group| {
let test_group = self.test_group(group);
- let wast = wasm_testsuite::get_test_wast(group).expect("failed to get test wast");
+ let wast = if group.starts_with("./") {
+ let file = std::fs::read(group).expect("failed to read test wast");
+ Cow::Owned(file)
+ } else {
+ wasm_testsuite::get_test_wast(group).expect("failed to get test wast")
+ };
+
let wast = std::str::from_utf8(&wast).expect("failed to convert wast to utf8");
let mut lexer = Lexer::new(wast);