summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorHenry <mail@henrygressmann.de>2026-08-10 16:21:47 +0200
committerHenry <mail@henrygressmann.de>2026-08-10 16:21:47 +0200
commit70c5bb2e4816f7ee458a6180845af3bd6b1d2d1d (patch)
treeefaff316f2fb7a84d641faf70c20d49ead3c0cbc /crates
parent666c7f59301acc9fcef10ac2da5beb464e57d665 (diff)
chore: cleanup tests / devdeps, fix doom example
Signed-off-by: Henry <mail@henrygressmann.de>
Diffstat (limited to 'crates')
-rw-r--r--crates/cli/Cargo.toml6
-rw-r--r--crates/cli/src/bin.rs2
-rw-r--r--crates/cli/src/cmd/compile.rs2
-rw-r--r--crates/cli/src/cmd/completion.rs2
-rw-r--r--crates/cli/src/cmd/dump.rs2
-rw-r--r--crates/cli/src/cmd/inspect.rs2
-rw-r--r--crates/cli/src/cmd/run.rs8
-rw-r--r--crates/cli/src/cmd/wast.rs2
-rw-r--r--crates/cli/src/engine_flags.rs2
-rw-r--r--crates/cli/src/lib.rs4
-rw-r--r--crates/cli/src/load.rs2
-rw-r--r--crates/cli/src/testsuite.rs (renamed from crates/tinywasm/tests/testsuite/mod.rs)40
-rw-r--r--crates/cli/src/value_parse.rs6
-rw-r--r--crates/cli/src/wast_runner.rs80
-rw-r--r--crates/tinywasm/Cargo.toml27
-rw-r--r--crates/tinywasm/benches/argon2id.rs47
-rw-r--r--crates/tinywasm/benches/fibonacci.rs53
-rw-r--r--crates/tinywasm/benches/memory_backends.rs152
-rw-r--r--crates/tinywasm/benches/tinywasm.rs50
-rw-r--r--crates/tinywasm/benches/tinywasm_modes.rs99
-rw-r--r--crates/tinywasm/tests/host_func_signature_check.rs18
-rw-r--r--crates/tinywasm/tests/import_linking.rs7
-rw-r--r--crates/tinywasm/tests/imported_table_init.rs3
-rw-r--r--crates/tinywasm/tests/internal_refs.rs13
-rw-r--r--crates/tinywasm/tests/memory_backends.rs31
-rw-r--r--crates/tinywasm/tests/memory_ref_api.rs3
-rw-r--r--crates/tinywasm/tests/module_descriptors.rs8
-rw-r--r--crates/tinywasm/tests/resume_execution.rs3
-rw-r--r--crates/tinywasm/tests/start_function.rs3
-rw-r--r--crates/tinywasm/tests/store_ownership.rs11
-rw-r--r--crates/tinywasm/tests/test-wasm-1.rs6
-rw-r--r--crates/tinywasm/tests/test-wasm-2.rs6
-rw-r--r--crates/tinywasm/tests/test-wasm-3.rs6
-rw-r--r--crates/tinywasm/tests/test-wasm-custom-page-sizes.rs6
-rw-r--r--crates/tinywasm/tests/test-wasm-custom.rs6
-rw-r--r--crates/tinywasm/tests/test-wasm-gc.rs6
-rw-r--r--crates/tinywasm/tests/test-wasm-latest.rs6
-rw-r--r--crates/tinywasm/tests/test-wasm-memory64.rs6
-rw-r--r--crates/tinywasm/tests/test-wasm-multi-memory.rs6
-rw-r--r--crates/tinywasm/tests/test-wasm-relaxed-simd.rs6
-rw-r--r--crates/tinywasm/tests/test-wasm-simd.rs6
-rw-r--r--crates/tinywasm/tests/test-wasm-threads.rs6
-rw-r--r--crates/tinywasm/tests/test-wasm-wide-arithmetic.rs6
-rw-r--r--crates/tinywasm/tests/test-wast.rs17
-rw-r--r--crates/tinywasm/tests/typed_globals.rs5
-rw-r--r--crates/tinywasm/tests/typed_lookup.rs5
46 files changed, 175 insertions, 618 deletions
diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml
index 17b56e6..1aae437 100644
--- a/crates/cli/Cargo.toml
+++ b/crates/cli/Cargo.toml
@@ -23,12 +23,14 @@ path = "src/bin.rs"
[dependencies]
anstream = { version = "1.0" }
+anyhow.workspace = true
clap = { version = "4.6", features = ["derive"] }
clap_complete = "4.6"
-eyre.workspace = true
log.workspace = true
owo-colors = { workspace = true }
pretty_env_logger.workspace = true
+serde = { workspace = true, optional = true }
+serde_json = { workspace = true, optional = true }
tinywasm = { workspace = true, features = [
"archive",
"canonicalize-nans",
@@ -39,6 +41,7 @@ tinywasm = { workspace = true, features = [
"std",
"validate",
] }
+wasm-testsuite = { workspace = true, optional = true }
wast = { workspace = true, optional = true }
wat = { workspace = true, optional = true }
@@ -49,5 +52,6 @@ tempfile = "3.27"
[features]
default = ["wast", "wat"]
+tests = ["dep:serde", "dep:serde_json", "dep:wasm-testsuite", "wast"]
wast = ["dep:wast"]
wat = ["dep:wat"]
diff --git a/crates/cli/src/bin.rs b/crates/cli/src/bin.rs
index 592fda7..d630fcf 100644
--- a/crates/cli/src/bin.rs
+++ b/crates/cli/src/bin.rs
@@ -1,5 +1,5 @@
+use anyhow::Result;
use clap::Parser;
-use eyre::Result;
use tinywasm_cli::{Cli, run_cli};
fn main() -> Result<()> {
diff --git a/crates/cli/src/cmd/compile.rs b/crates/cli/src/cmd/compile.rs
index 93e38d5..c7007ee 100644
--- a/crates/cli/src/cmd/compile.rs
+++ b/crates/cli/src/cmd/compile.rs
@@ -1,4 +1,4 @@
-use eyre::Result;
+use anyhow::Result;
use crate::cli::CompileArgs;
use crate::load::{default_twasm_output_path, load_compilable_module, write_output_bytes};
diff --git a/crates/cli/src/cmd/completion.rs b/crates/cli/src/cmd/completion.rs
index 5815f57..b3aec7c 100644
--- a/crates/cli/src/cmd/completion.rs
+++ b/crates/cli/src/cmd/completion.rs
@@ -1,7 +1,7 @@
use std::io;
+use anyhow::Result;
use clap::CommandFactory;
-use eyre::Result;
use crate::cli::{Cli, CompletionArgs};
diff --git a/crates/cli/src/cmd/dump.rs b/crates/cli/src/cmd/dump.rs
index 7a88cc2..da98a0b 100644
--- a/crates/cli/src/cmd/dump.rs
+++ b/crates/cli/src/cmd/dump.rs
@@ -1,5 +1,5 @@
use anstream::println;
-use eyre::Result;
+use anyhow::Result;
use owo_colors::OwoColorize;
use tinywasm::types::{ExternalKind, ImportKind};
diff --git a/crates/cli/src/cmd/inspect.rs b/crates/cli/src/cmd/inspect.rs
index ea2cec7..cf7cb5f 100644
--- a/crates/cli/src/cmd/inspect.rs
+++ b/crates/cli/src/cmd/inspect.rs
@@ -1,4 +1,4 @@
-use eyre::Result;
+use anyhow::Result;
use crate::cli::ModuleInputArgs;
use crate::load::load_module;
diff --git a/crates/cli/src/cmd/run.rs b/crates/cli/src/cmd/run.rs
index 06f29f1..3d25641 100644
--- a/crates/cli/src/cmd/run.rs
+++ b/crates/cli/src/cmd/run.rs
@@ -1,4 +1,4 @@
-use eyre::Result;
+use anyhow::Result;
use tinywasm::types::ExportType;
use tinywasm::{ModuleInstance, Store};
@@ -8,7 +8,7 @@ use crate::output::print_results;
use crate::value_parse::parse_invocation_args;
pub fn run(args: RunArgs) -> Result<()> {
- let module_path = args.module.as_deref().ok_or_else(|| eyre::eyre!("missing module path"))?;
+ let module_path = args.module.as_deref().ok_or_else(|| anyhow::anyhow!("missing module path"))?;
let loaded = load_module(module_path)?;
let mut store = Store::new(args.engine.build_engine()?);
let instance = ModuleInstance::instantiate_no_start(&mut store, &loaded.module, None)?;
@@ -26,7 +26,7 @@ pub fn run(args: RunArgs) -> Result<()> {
(true, ExportType::Func(ty)) => Some(ty),
_ => None,
})
- .ok_or_else(|| eyre::eyre!("export is not a function: {export}"))?;
+ .ok_or_else(|| anyhow::anyhow!("export is not a function: {export}"))?;
let func = instance.func_untyped(&store, export)?;
let params = parse_invocation_args(func_ty, &args.args)?;
let results = func.call(&mut store, &params)?;
@@ -40,7 +40,7 @@ pub fn run(args: RunArgs) -> Result<()> {
}
let start = instance.func_untyped(&store, "_start").map_err(|_| {
- eyre::eyre!(
+ anyhow::anyhow!(
"module has no start function or `_start` export. Use `tinywasm inspect {module_path}` or `tinywasm run --invoke <export> {module_path}`"
)
})?;
diff --git a/crates/cli/src/cmd/wast.rs b/crates/cli/src/cmd/wast.rs
index ef9c263..c669a0a 100644
--- a/crates/cli/src/cmd/wast.rs
+++ b/crates/cli/src/cmd/wast.rs
@@ -1,6 +1,6 @@
use std::path::PathBuf;
-use eyre::Result;
+use anyhow::Result;
use crate::cli::WastArgs;
use crate::wast_runner::WastRunner;
diff --git a/crates/cli/src/engine_flags.rs b/crates/cli/src/engine_flags.rs
index c8df1fe..3d90847 100644
--- a/crates/cli/src/engine_flags.rs
+++ b/crates/cli/src/engine_flags.rs
@@ -1,5 +1,5 @@
+use anyhow::{Result, bail};
use clap::{Args, ValueEnum};
-use eyre::{Result, bail};
use tinywasm::{Engine, StackConfig, engine::FuelPolicy};
#[derive(Args, Clone, Default)]
diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs
index bef6b72..877bfe1 100644
--- a/crates/cli/src/lib.rs
+++ b/crates/cli/src/lib.rs
@@ -3,12 +3,14 @@ pub mod cmd;
pub mod engine_flags;
pub mod load;
pub mod output;
+#[cfg(feature = "tests")]
+pub mod testsuite;
pub mod value_parse;
#[cfg(feature = "wast")]
pub mod wast_runner;
+use anyhow::Result;
use clap::CommandFactory;
-use eyre::Result;
pub use cli::{Cli, Commands};
diff --git a/crates/cli/src/load.rs b/crates/cli/src/load.rs
index 9f7c616..12c0e1f 100644
--- a/crates/cli/src/load.rs
+++ b/crates/cli/src/load.rs
@@ -2,7 +2,7 @@ use std::ffi::OsStr;
use std::io::{Read, Write};
use std::path::Path;
-use eyre::{Context, Result, bail};
+use anyhow::{Context, Result, bail};
use tinywasm::Module;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
diff --git a/crates/tinywasm/tests/testsuite/mod.rs b/crates/cli/src/testsuite.rs
index ea44c29..032aa88 100644
--- a/crates/tinywasm/tests/testsuite/mod.rs
+++ b/crates/cli/src/testsuite.rs
@@ -1,11 +1,22 @@
-#![allow(dead_code)]
-
-use eyre::{Result, eyre};
+use crate::wast_runner::{GroupResult, TestFile as RunnerTestFile, WastRunner};
use owo_colors::OwoColorize;
use serde::{Deserialize, Serialize};
use std::fmt::{Display, Formatter};
use std::io::{BufRead, BufReader, Seek, SeekFrom};
-use tinywasm_cli::wast_runner::{GroupResult, TestFile as RunnerTestFile, WastRunner};
+
+/// Result type used by the WAST test utilities.
+pub type TestResult<T> = core::result::Result<T, Box<dyn core::error::Error>>;
+
+#[derive(Debug)]
+struct TestFailure(String);
+
+impl Display for TestFailure {
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+ f.write_str(&self.0)
+ }
+}
+
+impl core::error::Error for TestFailure {}
#[derive(Serialize, Deserialize)]
pub struct TestGroupResult {
@@ -27,7 +38,7 @@ impl TestSuite {
Self { runner: WastRunner::new() }
}
- pub fn run_paths(&mut self, tests: &[std::path::PathBuf]) -> Result<()> {
+ pub fn run_paths(&mut self, tests: &[std::path::PathBuf]) -> TestResult<()> {
let mut files = Vec::new();
for path in tests {
if path.is_dir() {
@@ -51,38 +62,43 @@ impl TestSuite {
let name = path.to_string_lossy().into_owned();
Ok((name, contents))
})
- .collect::<Result<Vec<_>>>()?;
+ .collect::<TestResult<Vec<_>>>()?;
self.runner.run_files(runner_files.iter().map(|(name, contents)| RunnerTestFile {
name: name.clone(),
parent: name.clone(),
contents,
- }))
+ }))?;
+ Ok(())
}
- pub fn run_files<'a>(&mut self, tests: impl IntoIterator<Item = wasm_testsuite::data::TestFile<'a>>) -> Result<()> {
+ pub fn run_files<'a>(
+ &mut self,
+ tests: impl IntoIterator<Item = wasm_testsuite::data::TestFile<'a>>,
+ ) -> TestResult<()> {
self.runner.run_files(tests.into_iter().map(|file| RunnerTestFile {
name: file.name().to_string(),
parent: file.parent().to_string(),
contents: file.raw(),
- }))
+ }))?;
+ Ok(())
}
pub fn print_errors(&self) {
self.runner.print_errors();
}
- pub fn report_status(&self) -> Result<()> {
+ pub fn report_status(&self) -> TestResult<()> {
if self.runner.failed() {
println!();
- Err(eyre!(format!("{}:\n{self}", "failed one or more tests".red().bold())))
+ Err(TestFailure(format!("{}:\n{self}", "failed one or more tests".red().bold())).into())
} else {
println!("{self}");
Ok(())
}
}
- pub fn save_csv(&self, path: &str, version: &str) -> Result<()> {
+ pub fn save_csv(&self, path: &str, version: &str) -> TestResult<()> {
use std::fs::OpenOptions;
use std::io::Write;
diff --git a/crates/cli/src/value_parse.rs b/crates/cli/src/value_parse.rs
index eabbdc4..3191eaf 100644
--- a/crates/cli/src/value_parse.rs
+++ b/crates/cli/src/value_parse.rs
@@ -1,4 +1,4 @@
-use eyre::{Result, bail};
+use anyhow::{Result, bail};
use tinywasm::types::{FuncType, WasmType, WasmValue};
use crate::output::format_wasm_type;
@@ -33,8 +33,8 @@ fn parse_arg(index: usize, ty: WasmType, value: &str) -> Result<WasmValue> {
Ok(parsed)
}
-fn format_error(index: usize, ty: WasmType, value: &str, error: impl core::fmt::Display) -> eyre::Report {
- eyre::eyre!("failed to parse argument {} as {} from `{value}`: {error}", index + 1, format_wasm_type(ty))
+fn format_error(index: usize, ty: WasmType, value: &str, error: impl core::fmt::Display) -> anyhow::Error {
+ anyhow::anyhow!("failed to parse argument {} as {} from `{value}`: {error}", index + 1, format_wasm_type(ty))
}
#[cfg(test)]
diff --git a/crates/cli/src/wast_runner.rs b/crates/cli/src/wast_runner.rs
index 24483b6..1b8ae9c 100644
--- a/crates/cli/src/wast_runner.rs
+++ b/crates/cli/src/wast_runner.rs
@@ -5,7 +5,7 @@ use std::panic::{self, AssertUnwindSafe};
use std::path::PathBuf;
use std::time::Duration;
-use eyre::{Context, Result, bail, eyre};
+use anyhow::{Context, Result, anyhow, bail};
use log::{debug, error};
use tinywasm::types::{
AbstractHeapType as TinyAbstractHeapType, AnyRef, ExternRef, FuncRef, MemoryType, RefType, RefValue, TableType,
@@ -111,7 +111,7 @@ impl WastRunner {
self.print_errors();
if self.failed() {
anstream::println!("{self}");
- Err(eyre!("failed one or more tests"))
+ Err(anyhow!("failed one or more tests"))
} else {
anstream::println!("{self}");
Ok(())
@@ -238,7 +238,7 @@ impl WastRunner {
test_group.add_result(
&format!("Register({i})"),
span.linecol_in(wast_raw),
- Err(eyre!("module instance to register was not found")),
+ Err(anyhow!("module instance to register was not found")),
);
continue;
}
@@ -251,7 +251,7 @@ impl WastRunner {
.expect("failed to instantiate module");
(name, instance)
})
- .map_err(|e| eyre!("failed to parse wat module: {}", try_downcast_panic(e)));
+ .map_err(|e| anyhow!("failed to parse wat module: {}", try_downcast_panic(e)));
match &result {
Err(err) => debug!("failed to parse module: {err:?}"),
@@ -263,7 +263,7 @@ impl WastRunner {
ModuleDefinition(module) => {
let result =
catch_unwind_silent(|| parse_quote_module(module).expect("failed to parse module definition"))
- .map_err(|err| eyre!("failed to parse module definition: {}", try_downcast_panic(err)));
+ .map_err(|err| anyhow!("failed to parse module definition: {}", try_downcast_panic(err)));
if let Ok((name, module)) = &result {
module_registry.define(module.clone(), name.clone());
@@ -280,10 +280,10 @@ impl WastRunner {
let result = catch_unwind_silent(|| {
let module = module_registry
.definition(module)
- .ok_or_else(|| eyre!("module definition was not found"))?;
+ .ok_or_else(|| anyhow!("module definition was not found"))?;
Self::instantiate_module(&mut store, &module_registry, &module)
})
- .map_err(|err| eyre!("failed to instantiate module definition: {}", try_downcast_panic(err)))
+ .map_err(|err| anyhow!("failed to instantiate module definition: {}", try_downcast_panic(err)))
.and_then(|result| result);
if let Ok(instance) = &result {
@@ -301,7 +301,7 @@ impl WastRunner {
continue;
};
let res = catch_unwind_silent(|| parse_module_bytes(&encoded))
- .map_err(|e| eyre!("failed to parse module (expected): {}", try_downcast_panic(e)))
+ .map_err(|e| anyhow!("failed to parse module (expected): {}", try_downcast_panic(e)))
.and_then(|res| res);
test_group.add_result(
&format!("AssertMalformed({i})"),
@@ -314,7 +314,7 @@ impl WastRunner {
{
continue;
}
- Err(eyre!("expected module to be malformed: {message}"))
+ Err(anyhow!("expected module to be malformed: {message}"))
}
Err(_) => Ok(()),
},
@@ -326,13 +326,13 @@ impl WastRunner {
continue;
}
let res = catch_unwind_silent(move || parse_module_bytes(&module.encode().unwrap()))
- .map_err(|e| eyre!("failed to parse module (invalid): {}", try_downcast_panic(e)))
+ .map_err(|e| anyhow!("failed to parse module (invalid): {}", try_downcast_panic(e)))
.and_then(|res| res);
test_group.add_result(
&format!("AssertInvalid({i})"),
span.linecol_in(wast_raw),
match res {
- Ok(_) => Err(eyre!("expected module to be invalid")),
+ Ok(_) => Err(anyhow!("expected module to be invalid")),
Err(_) => Ok(()),
},
);
@@ -346,7 +346,7 @@ impl WastRunner {
test_group.add_result(
&format!("AssertExhaustion({i})"),
span.linecol_in(wast_raw),
- Err(eyre!("expected trap")),
+ Err(anyhow!("expected trap")),
);
continue;
};
@@ -354,7 +354,7 @@ impl WastRunner {
test_group.add_result(
&format!("AssertExhaustion({i})"),
span.linecol_in(wast_raw),
- Err(eyre!("expected trap: {}, got: {}", message, trap.message())),
+ Err(anyhow!("expected trap: {}, got: {}", message, trap.message())),
);
continue;
}
@@ -382,14 +382,14 @@ impl WastRunner {
Err(err) => test_group.add_result(
&format!("AssertTrap({i})"),
span.linecol_in(wast_raw),
- Err(eyre!("test panicked: {}", try_downcast_panic(err))),
+ Err(anyhow!("test panicked: {}", try_downcast_panic(err))),
),
Ok(Err(tinywasm::Error::Trap(trap))) => {
if !message.starts_with(trap.message()) && !trap.message().starts_with(message) {
test_group.add_result(
&format!("AssertTrap({i})"),
span.linecol_in(wast_raw),
- Err(eyre!("expected trap: {}, got: {}", message, trap.message())),
+ Err(anyhow!("expected trap: {}, got: {}", message, trap.message())),
);
continue;
}
@@ -398,12 +398,12 @@ impl WastRunner {
Ok(Err(err)) => test_group.add_result(
&format!("AssertTrap({i})"),
span.linecol_in(wast_raw),
- Err(eyre!("expected trap, {}, got: {:?}", message, err)),
+ Err(anyhow!("expected trap, {}, got: {:?}", message, err)),
),
Ok(Ok(())) => test_group.add_result(
&format!("AssertTrap({i})"),
span.linecol_in(wast_raw),
- Err(eyre!("expected trap {}, got Ok", message)),
+ Err(anyhow!("expected trap {}, got Ok", message)),
),
}
}
@@ -426,10 +426,10 @@ impl WastRunner {
exec_fn_instance(module, &mut store, invoke.name, &args).map(|_| ())
});
let result = match res {
- Err(err) => Err(eyre!("test panicked: {}", try_downcast_panic(err))),
+ Err(err) => Err(anyhow!("test panicked: {}", try_downcast_panic(err))),
Ok(Err(tinywasm::Error::Exception(_))) => Ok(()),
- Ok(Err(err)) => Err(eyre!("expected exception, got: {err:?}")),
- Ok(Ok(())) => Err(eyre!("expected exception, got Ok")),
+ Ok(Err(err)) => Err(anyhow!("expected exception, got: {err:?}")),
+ Ok(Ok(())) => Err(anyhow!("expected exception, got Ok")),
};
test_group.add_result(&format!("AssertException({i})"), span.linecol_in(wast_raw), result);
}
@@ -444,7 +444,7 @@ impl WastRunner {
Err(err) => test_group.add_result(
&format!("AssertUnlinkable({i})"),
span.linecol_in(wast_raw),
- Err(eyre!("test panicked: {}", try_downcast_panic(err))),
+ Err(anyhow!("test panicked: {}", try_downcast_panic(err))),
),
Ok(Err(tinywasm::Error::Linker(err))) => {
if err.message() != message
@@ -454,7 +454,7 @@ impl WastRunner {
test_group.add_result(
&format!("AssertUnlinkable({i})"),
span.linecol_in(wast_raw),
- Err(eyre!("expected linker error: {}, got: {}", message, err.message())),
+ Err(anyhow!("expected linker error: {}, got: {}", message, err.message())),
);
continue;
}
@@ -463,12 +463,12 @@ impl WastRunner {
Ok(Err(err)) => test_group.add_result(
&format!("AssertUnlinkable({i})"),
span.linecol_in(wast_raw),
- Err(eyre!("expected linker error, {}, got: {:?}", message, err)),
+ Err(anyhow!("expected linker error, {}, got: {:?}", message, err)),
),
Ok(Ok(_)) => test_group.add_result(
&format!("AssertUnlinkable({i})"),
span.linecol_in(wast_raw),
- Err(eyre!("expected linker error {}, got Ok", message)),
+ Err(anyhow!("expected linker error {}, got Ok", message)),
),
}
}
@@ -483,7 +483,7 @@ impl WastRunner {
})?;
Ok(())
});
- let res = res.map_err(|e| eyre!("test panicked: {}", try_downcast_panic(e))).and_then(|r| r);
+ let res = res.map_err(|e| anyhow!("test panicked: {}", try_downcast_panic(e))).and_then(|r| r);
test_group.add_result(&format!("Invoke({name}-{i})"), span.linecol_in(wast_raw), res);
}
AssertReturn { span, exec, results } => {
@@ -492,7 +492,7 @@ impl WastRunner {
test_group.add_result(
&format!("AssertReturn(unsupported-{i})"),
span.linecol_in(wast_raw),
- Err(eyre!("failed to convert expected results: {err:?}")),
+ Err(anyhow!("failed to convert expected results: {err:?}")),
);
continue;
}
@@ -500,13 +500,13 @@ impl WastRunner {
};
let invoke = match match exec {
- wast::WastExecute::Wat(_) => Err(eyre!("wat not supported")),
+ wast::WastExecute::Wat(_) => Err(anyhow!("wat not supported")),
wast::WastExecute::Get { module: module_id, global, .. } => {
let Some(module) = module_registry.get(module_id) else {
test_group.add_result(
&format!("AssertReturn(unsupported-{i})"),
span.linecol_in(wast_raw),
- Err(eyre!("no module to get global from")),
+ Err(anyhow!("no module to get global from")),
);
continue;
};
@@ -516,7 +516,7 @@ impl WastRunner {
test_group.add_result(
&format!("AssertReturn(unsupported-{i})"),
span.linecol_in(wast_raw),
- Err(eyre!("failed to get global: {err:?}")),
+ Err(anyhow!("failed to get global: {err:?}")),
);
continue;
}
@@ -529,7 +529,7 @@ impl WastRunner {
test_group.add_result(
&format!("AssertReturn(unsupported-{i})"),
span.linecol_in(wast_raw),
- Err(eyre!(
+ Err(anyhow!(
"global value did not match any expected alternative: {:?}",
module_global
)),
@@ -550,7 +550,7 @@ impl WastRunner {
test_group.add_result(
&format!("AssertReturn(unsupported-{i})"),
span.linecol_in(wast_raw),
- Err(eyre!("unsupported directive: {err:?}")),
+ Err(anyhow!("unsupported directive: {err:?}")),
);
continue;
}
@@ -565,7 +565,7 @@ impl WastRunner {
e
})?;
if !expected_alternatives.iter().any(|expected| expected.len() == outcomes.len()) {
- return Err(eyre!(
+ return Err(anyhow!(
"expected {} results, got {}",
expected_alternatives.first().map_or(0, |v| v.len()),
outcomes.len()
@@ -580,17 +580,17 @@ impl WastRunner {
}) {
Ok(())
} else {
- Err(eyre!("results did not match any expected alternative"))
+ Err(anyhow!("results did not match any expected alternative"))
}
});
- let res = res.map_err(|e| eyre!("test panicked: {}", try_downcast_panic(e))).and_then(|r| r);
+ let res = res.map_err(|e| anyhow!("test panicked: {}", try_downcast_panic(e))).and_then(|r| r);
test_group.add_result(&format!("AssertReturn({invoke_name}-{i})"), span.linecol_in(wast_raw), res);
}
_ => test_group.add_result(
&format!("Unknown({i})"),
span.linecol_in(wast_raw),
- Err(eyre!("unsupported directive")),
+ Err(anyhow!("unsupported directive")),
),
}
}
@@ -828,7 +828,7 @@ fn wastarg2tinywasmvalue(arg: wast::WastArg) -> Result<WasmValue> {
I32(i) => WasmValue::I32(i),
I64(i) => WasmValue::I64(i),
V128(i) => WasmValue::V128(i.to_le_bytes()),
- RefExtern(v) => ExternRef::try_new(v).ok_or_else(|| eyre!("external reference address is too large"))?.into(),
+ RefExtern(v) => ExternRef::try_new(v).ok_or_else(|| anyhow!("external reference address is too large"))?.into(),
RefNull(t) => match t {
wast::core::HeapType::Abstract { shared: false, ty: AbstractHeapType::Func } => RefValue::Null.into(),
wast::core::HeapType::Abstract { shared: false, ty: AbstractHeapType::Extern | AbstractHeapType::Any } => {
@@ -839,7 +839,8 @@ fn wastarg2tinywasmvalue(arg: wast::WastArg) -> Result<WasmValue> {
}
},
RefHost(value) => {
- RefValue::Any(AnyRef::from_host(value).ok_or_else(|| eyre!("host reference address is too large"))?).into()
+ RefValue::Any(AnyRef::from_host(value).ok_or_else(|| anyhow!("host reference address is too large"))?)
+ .into()
}
})
}
@@ -918,7 +919,7 @@ fn wastretcore2tinywasmvalue(ret: wast::core::WastRetCore) -> Result<ExpectedVal
V128(i) => ExpectedValue::Exact(WasmValue::V128(wast_v128_to_bytes(i))),
RefNull(_) => ExpectedValue::RefNull,
RefExtern(Some(v)) => ExpectedValue::Exact(
- ExternRef::try_new(v).ok_or_else(|| eyre!("external reference address is too large"))?.into(),
+ ExternRef::try_new(v).ok_or_else(|| anyhow!("external reference address is too large"))?.into(),
),
RefExtern(None) => ExpectedValue::RefExtern,
RefFunc(Some(wast::token::Index::Num(n, _))) => ExpectedValue::Exact(FuncRef::new(n).into()),
@@ -932,7 +933,8 @@ fn wastretcore2tinywasmvalue(ret: wast::core::WastRetCore) -> Result<ExpectedVal
RefStruct => ExpectedValue::RefStruct,
RefArray => ExpectedValue::RefArray,
RefHost(value) => ExpectedValue::Exact(
- RefValue::Any(AnyRef::from_host(value).ok_or_else(|| eyre!("host reference address is too large"))?).into(),
+ RefValue::Any(AnyRef::from_host(value).ok_or_else(|| anyhow!("host reference address is too large"))?)
+ .into(),
),
a => {
bail!("unsupported arg type {:?}", a);
diff --git a/crates/tinywasm/Cargo.toml b/crates/tinywasm/Cargo.toml
index 65ef7f8..eb5dd94 100644
--- a/crates/tinywasm/Cargo.toml
+++ b/crates/tinywasm/Cargo.toml
@@ -85,26 +85,6 @@ name = "test-wasm-simd"
harness = false
name = "test-wasm-wide-arithmetic"
-[[bench]]
-harness = false
-name = "argon2id"
-
-[[bench]]
-harness = false
-name = "fibonacci"
-
-[[bench]]
-harness = false
-name = "tinywasm"
-
-[[bench]]
-harness = false
-name = "tinywasm_modes"
-
-[[bench]]
-harness = false
-name = "memory_backends"
-
[dependencies]
libm = { version = "0.2", default-features = false }
log = { workspace = true, optional = true }
@@ -112,12 +92,7 @@ tinywasm-parser = { workspace = true, optional = true }
tinywasm-types = { workspace = true }
[dev-dependencies]
-criterion.workspace = true
-eyre.workspace = true
-owo-colors.workspace = true
-serde.workspace = true
-serde_json.workspace = true
-tinywasm-cli = { path = "../cli", features = ["wast", "wat"] }
+tinywasm-cli = { path = "../cli", features = ["tests", "wat"] }
wasm-testsuite.workspace = true
wat.workspace = true
diff --git a/crates/tinywasm/benches/argon2id.rs b/crates/tinywasm/benches/argon2id.rs
deleted file mode 100644
index d2845c5..0000000
--- a/crates/tinywasm/benches/argon2id.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-use criterion::{Criterion, criterion_group, criterion_main};
-use eyre::Result;
-use tinywasm::{ModuleInstance, Store, types};
-use types::Module;
-
-const WASM: &[u8] = include_bytes!("../../../examples/rust/out/argon2id.wasm");
-
-fn argon2id_parse() -> Result<Module> {
- let parser = tinywasm_parser::Parser::default();
- let data = parser.parse_module_bytes(WASM)?;
- Ok(data)
-}
-
-fn argon2id_to_twasm(module: &Module) -> Result<Vec<u8>> {
- let twasm = module.serialize_twasm()?;
- Ok(twasm)
-}
-
-fn argon2id_from_twasm(twasm: &[u8]) -> Result<Module> {
- let module = Module::try_from_twasm(twasm)?;
- Ok(module)
-}
-
-fn argon2id_run(module: Module) -> Result<()> {
- let mut store = Store::default();
- let instance = ModuleInstance::instantiate(&mut store, &module, None)?;
- let argon2 = instance.func::<(i32, i32, i32), i32>(&store, "argon2id")?;
- argon2.call(&mut store, (1000, 2, 1))?;
- Ok(())
-}
-
-fn criterion_benchmark(c: &mut Criterion) {
- let module = argon2id_parse().expect("argon2id_parse");
- let twasm = argon2id_to_twasm(&module).expect("argon2id_to_twasm");
- let mut group = c.benchmark_group("argon2id");
-
- group.measurement_time(std::time::Duration::from_secs(2));
- group.bench_function("argon2id_parse", |b| b.iter(argon2id_parse));
- group.bench_function("argon2id_to_twasm", |b| b.iter(|| argon2id_to_twasm(&module)));
- group.bench_function("argon2id_from_twasm", |b| b.iter(|| argon2id_from_twasm(&twasm)));
-
- group.measurement_time(std::time::Duration::from_secs(10));
- group.bench_function("argon2id", |b| b.iter(|| argon2id_run(module.clone())));
-}
-
-criterion_group!(benches, criterion_benchmark);
-criterion_main!(benches);
diff --git a/crates/tinywasm/benches/fibonacci.rs b/crates/tinywasm/benches/fibonacci.rs
deleted file mode 100644
index 1bf0791..0000000
--- a/crates/tinywasm/benches/fibonacci.rs
+++ /dev/null
@@ -1,53 +0,0 @@
-use criterion::{Criterion, criterion_group, criterion_main};
-use eyre::Result;
-use tinywasm::{ModuleInstance, Store, types};
-use types::Module;
-
-const WASM: &[u8] = include_bytes!("../../../examples/rust/out/fibonacci.wasm");
-
-fn fibonacci_parse() -> Result<Module> {
- let parser = tinywasm_parser::Parser::default();
- let data = parser.parse_module_bytes(WASM)?;
- Ok(data)
-}
-
-fn fibonacci_to_twasm(module: &Module) -> Result<Vec<u8>> {
- let twasm = module.serialize_twasm()?;
- Ok(twasm)
-}
-
-fn fibonacci_from_twasm(twasm: &[u8]) -> Result<Module> {
- Ok(Module::try_from_twasm(twasm)?)
-}
-
-fn fibonacci_run(module: Module, recursive: bool, n: i32) -> Result<()> {
- let mut store = Store::default();
- let instance = ModuleInstance::instantiate(&mut store, &module, None)?;
- let argon2 = instance.func::<i32, i32>(
- &store,
- match recursive {
- true => "fibonacci_recursive",
- false => "fibonacci",
- },
- )?;
- argon2.call(&mut store, n)?;
- Ok(())
-}
-
-fn criterion_benchmark(c: &mut Criterion) {
- let module = fibonacci_parse().expect("fibonacci_parse");
- let twasm = fibonacci_to_twasm(&module).expect("fibonacci_to_twasm");
- let mut group = c.benchmark_group("fibonacci");
-
- group.measurement_time(std::time::Duration::from_secs(2));
- group.bench_function("fibonacci_parse", |b| b.iter(fibonacci_parse));
- group.bench_function("fibonacci_to_twasm", |b| b.iter(|| fibonacci_to_twasm(&module)));
- group.bench_function("fibonacci_from_twasm", |b| b.iter(|| fibonacci_from_twasm(&twasm)));
-
- group.measurement_time(std::time::Duration::from_secs(10));
- group.bench_function("fibonacci_iterative_60", |b| b.iter(|| fibonacci_run(module.clone(), false, 60)));
- group.bench_function("fibonacci_recursive_26", |b| b.iter(|| fibonacci_run(module.clone(), true, 26)));
-}
-
-criterion_group!(benches, criterion_benchmark);
-criterion_main!(benches);
diff --git a/crates/tinywasm/benches/memory_backends.rs b/crates/tinywasm/benches/memory_backends.rs
deleted file mode 100644
index 3a59f8c..0000000
--- a/crates/tinywasm/benches/memory_backends.rs
+++ /dev/null
@@ -1,152 +0,0 @@
-use criterion::measurement::WallTime;
-use criterion::{BatchSize, BenchmarkGroup, BenchmarkId, Criterion, criterion_group, criterion_main};
-use std::hint::black_box;
-use tinywasm::{LinearMemory, PagedMemory, VecMemory};
-
-const PAGE_SIZE: usize = 64 * 1024;
-const CHUNK_SIZE: usize = 4 * 1024;
-const GROW_STEPS: usize = 32;
-const BENCH_MEASUREMENT_TIME: std::time::Duration = std::time::Duration::from_secs(10);
-
-const MEMORY_LEN: usize = PAGE_SIZE * 4;
-const CONTIGUOUS_OFFSET: usize = 1024;
-const CONTIGUOUS_LEN: usize = 2048;
-const CROSS_CHUNK_OFFSET: usize = CHUNK_SIZE - 512;
-const CROSS_CHUNK_LEN: usize = CHUNK_SIZE * 2;
-
-fn bench_grow<M, F>(group: &mut BenchmarkGroup<'_, WallTime>, backend: &str, make_memory: F)
-where
- M: LinearMemory,
- F: Fn() -> M + Copy,
-{
- group.bench_function(BenchmarkId::new("grow", backend), |b| {
- b.iter_batched(
- make_memory,
- |mut memory| {
- for page_count in 2..=GROW_STEPS + 1 {
- memory.grow_to(page_count * PAGE_SIZE).unwrap();
- }
- black_box(memory.len())
- },
- BatchSize::SmallInput,
- )
- });
-}
-
-fn bench_write_all<M: LinearMemory>(
- group: &mut BenchmarkGroup<'_, WallTime>,
- backend: &str,
- workload: &str,
- mut memory: M,
- offset: usize,
- len: usize,
-) {
- let src = vec![0xA5; len];
- group.bench_function(BenchmarkId::new(format!("write_all/{workload}"), backend), |b| {
- b.iter(|| {
- memory.write_all(offset, black_box(&src)).unwrap();
- black_box(memory.len())
- })
- });
-}
-
-fn bench_read_exact<M: LinearMemory>(
- group: &mut BenchmarkGroup<'_, WallTime>,
- backend: &str,
- workload: &str,
- mut memory: M,
- offset: usize,
- len: usize,
-) {
- let src = vec![0x5A; len];
- memory.write_all(offset, &src).unwrap();
-
- let mut dst = vec![0; len];
- group.bench_function(BenchmarkId::new(format!("read_exact/{workload}"), backend), |b| {
- b.iter(|| {
- memory.read_exact(offset, black_box(&mut dst)).unwrap();
- black_box(&dst);
- })
- });
-}
-
-fn criterion_benchmark(c: &mut Criterion) {
- let mut group = c.benchmark_group("memory_backends");
- group.measurement_time(BENCH_MEASUREMENT_TIME);
-
- bench_grow(&mut group, "vec", || VecMemory::try_new(PAGE_SIZE).expect("bench memory should be constructible"));
- bench_grow(&mut group, "paged", || {
- PagedMemory::try_new(PAGE_SIZE, CHUNK_SIZE).expect("bench memory should be constructible")
- });
-
- bench_write_all(
- &mut group,
- "vec",
- "contiguous",
- VecMemory::try_new(MEMORY_LEN).expect("bench memory should be constructible"),
- CONTIGUOUS_OFFSET,
- CONTIGUOUS_LEN,
- );
- bench_write_all(
- &mut group,
- "paged",
- "contiguous",
- PagedMemory::try_new(MEMORY_LEN, CHUNK_SIZE).expect("bench memory should be constructible"),
- CONTIGUOUS_OFFSET,
- CONTIGUOUS_LEN,
- );
- bench_read_exact(
- &mut group,
- "vec",
- "contiguous",
- VecMemory::try_new(MEMORY_LEN).expect("bench memory should be constructible"),
- CONTIGUOUS_OFFSET,
- CONTIGUOUS_LEN,
- );
- bench_read_exact(
- &mut group,
- "paged",
- "contiguous",
- PagedMemory::try_new(MEMORY_LEN, CHUNK_SIZE).expect("bench memory should be constructible"),
- CONTIGUOUS_OFFSET,
- CONTIGUOUS_LEN,
- );
-
- bench_write_all(
- &mut group,
- "vec",
- "cross_chunk",
- VecMemory::try_new(MEMORY_LEN).expect("bench memory should be constructible"),
- CROSS_CHUNK_OFFSET,
- CROSS_CHUNK_LEN,
- );
- bench_write_all(
- &mut group,
- "paged",
- "cross_chunk",
- PagedMemory::try_new(MEMORY_LEN, CHUNK_SIZE).expect("bench memory should be constructible"),
- CROSS_CHUNK_OFFSET,
- CROSS_CHUNK_LEN,
- );
- bench_read_exact(
- &mut group,
- "vec",
- "cross_chunk",
- VecMemory::try_new(MEMORY_LEN).expect("bench memory should be constructible"),
- CROSS_CHUNK_OFFSET,
- CROSS_CHUNK_LEN,
- );
- bench_read_exact(
- &mut group,
- "paged",
- "cross_chunk",
- PagedMemory::try_new(MEMORY_LEN, CHUNK_SIZE).expect("bench memory should be constructible"),
- CROSS_CHUNK_OFFSET,
- CROSS_CHUNK_LEN,
- );
-
- group.finish();
-}
-
-criterion_group!(benches, criterion_benchmark);
-criterion_main!(benches);
diff --git a/crates/tinywasm/benches/tinywasm.rs b/crates/tinywasm/benches/tinywasm.rs
deleted file mode 100644
index 3560d3c..0000000
--- a/crates/tinywasm/benches/tinywasm.rs
+++ /dev/null
@@ -1,50 +0,0 @@
-use criterion::{Criterion, criterion_group, criterion_main};
-use eyre::Result;
-use tinywasm::engine::Config;
-use tinywasm::{Engine, FuncContext, HostFunction, Imports, ModuleInstance, Store, types};
-use types::Module;
-
-const WASM: &[u8] = include_bytes!("../../../examples/rust/out/tinywasm.wasm");
-
-fn tinywasm_parse() -> Result<Module> {
- let parser = tinywasm_parser::Parser::default();
- let data = parser.parse_module_bytes(WASM)?;
- Ok(data)
-}
-
-fn tinywasm_to_twasm(module: &Module) -> Result<Vec<u8>> {
- let twasm = module.serialize_twasm()?;
- Ok(twasm)
-}
-
-fn tinywasm_from_twasm(twasm: &[u8]) -> Result<Module> {
- let module = Module::try_from_twasm(twasm)?;
- Ok(module)
-}
-
-fn tinywasm_run(module: &Module) -> Result<()> {
- let engine = Engine::new(Config::default());
- let mut store = Store::new(engine);
- let mut imports = Imports::default();
- imports.define("env", "printi32", HostFunction::from(|_: FuncContext<'_>, _: i32| Ok(())));
- let instance = ModuleInstance::instantiate(&mut store, module, Some(&imports)).expect("instantiate");
- let hello = instance.func::<(), ()>(&store, "hello").expect("func_typed");
- hello.call(&mut store, ()).expect("call");
- Ok(())
-}
-
-fn criterion_benchmark(c: &mut Criterion) {
- let module = tinywasm_parse().expect("tinywasm_parse");
- let twasm = tinywasm_to_twasm(&module).expect("tinywasm_to_twasm");
- let mut group = c.benchmark_group("tinywasm");
-
- group.measurement_time(std::time::Duration::from_secs(2));
- group.bench_function("tinywasm_parse", |b| b.iter(tinywasm_parse));
- group.bench_function("tinywasm_to_twasm", |b| b.iter(|| tinywasm_to_twasm(&module)));
- group.bench_function("tinywasm_from_twasm", |b| b.iter(|| tinywasm_from_twasm(&twasm)));
- group.measurement_time(std::time::Duration::from_secs(10));
- group.bench_function("tinywasm", |b| b.iter(|| tinywasm_run(&module)));
-}
-
-criterion_group!(benches, criterion_benchmark);
-criterion_main!(benches);
diff --git a/crates/tinywasm/benches/tinywasm_modes.rs b/crates/tinywasm/benches/tinywasm_modes.rs
deleted file mode 100644
index 6c1badf..0000000
--- a/crates/tinywasm/benches/tinywasm_modes.rs
+++ /dev/null
@@ -1,99 +0,0 @@
-use criterion::{BatchSize, Criterion, criterion_group, criterion_main};
-use eyre::Result;
-use tinywasm::engine::{Config, FuelPolicy};
-use tinywasm::types::Module;
-use tinywasm::{Engine, ExecProgress, FuncContext, FunctionTyped, HostFunction, Imports, ModuleInstance, Store};
-
-const WASM: &[u8] = include_bytes!("../../../examples/rust/out/tinywasm.wasm");
-const FUEL_PER_ROUND: u32 = 512;
-const TIME_BUDGET_PER_ROUND: core::time::Duration = core::time::Duration::from_micros(50);
-const BENCH_MEASUREMENT_TIME: core::time::Duration = core::time::Duration::from_secs(10);
-
-fn tinywasm_parse() -> Result<Module> {
- let parser = tinywasm_parser::Parser::default();
- Ok(parser.parse_module_bytes(WASM)?)
-}
-
-fn setup_typed_func(module: &Module, engine: Option<Engine>) -> Result<(Store, FunctionTyped<(), ()>)> {
- let mut store = match engine {
- Some(engine) => Store::new(engine),
- None => Store::default(),
- };
-
- let mut imports = Imports::default();
- imports.define("env", "printi32", HostFunction::from(|_: FuncContext<'_>, _: i32| Ok(())));
-
- let instance = ModuleInstance::instantiate(&mut store, module, Some(&imports))?;
- let func = instance.func::<(), ()>(&store, "hello")?;
- Ok((store, func))
-}
-
-fn run_call(store: &mut Store, func: &FunctionTyped<(), ()>) -> Result<()> {
- func.call(store, ())?;
- Ok(())
-}
-
-fn run_resume_with_fuel(store: &mut Store, func: &FunctionTyped<(), ()>) -> Result<()> {
- let mut execution = func.call_resumable(store, ())?;
- loop {
- match execution.resume_with_fuel(FUEL_PER_ROUND)? {
- ExecProgress::Completed(_) => return Ok(()),
- ExecProgress::Suspended => {}
- }
- }
-}
-
-fn run_resume_with_time_budget(store: &mut Store, func: &FunctionTyped<(), ()>) -> Result<()> {
- let mut execution = func.call_resumable(store, ())?;
- loop {
- match execution.resume_with_time_budget(TIME_BUDGET_PER_ROUND)? {
- ExecProgress::Completed(_) => return Ok(()),
- ExecProgress::Suspended => {}
- }
- }
-}
-
-fn criterion_benchmark(c: &mut Criterion) {
- let module = tinywasm_parse().expect("tinywasm_parse");
- let mut group = c.benchmark_group("tinywasm_modes");
- group.measurement_time(BENCH_MEASUREMENT_TIME);
-
- let per_instruction_engine = Engine::new(Config::new().with_fuel_policy(FuelPolicy::PerInstruction));
- group.bench_function("resume_fuel_per_instruction", |b| {
- b.iter_batched_ref(
- || setup_typed_func(&module, Some(per_instruction_engine.clone())).expect("setup fuel per-instruction"),
- |(store, func)| run_resume_with_fuel(store, func).expect("run fuel per-instruction"),
- BatchSize::LargeInput,
- )
- });
-
- let weighted_engine = Engine::new(Config::new().with_fuel_policy(FuelPolicy::Weighted));
- group.bench_function("resume_fuel_weighted", |b| {
- b.iter_batched_ref(
- || setup_typed_func(&module, Some(weighted_engine.clone())).expect("setup fuel weighted"),
- |(store, func)| run_resume_with_fuel(store, func).expect("run fuel weighted"),
- BatchSize::LargeInput,
- )
- });
-
- group.bench_function("resume_time_budget", |b| {
- b.iter_batched_ref(
- || setup_typed_func(&module, None).expect("setup time budget"),
- |(store, func)| run_resume_with_time_budget(store, func).expect("run time budget"),
- BatchSize::LargeInput,
- )
- });
-
- group.bench_function("call", |b| {
- b.iter_batched_ref(
- || setup_typed_func(&module, None).expect("setup call"),
- |(store, func)| run_call(store, func).expect("run call"),
- BatchSize::LargeInput,
- )
- });
-
- group.finish();
-}
-
-criterion_group!(benches, criterion_benchmark);
-criterion_main!(benches);
diff --git a/crates/tinywasm/tests/host_func_signature_check.rs b/crates/tinywasm/tests/host_func_signature_check.rs
index 35e0d9b..128f1ed 100644
--- a/crates/tinywasm/tests/host_func_signature_check.rs
+++ b/crates/tinywasm/tests/host_func_signature_check.rs
@@ -1,8 +1,6 @@
-use eyre::Result;
use std::fmt::Write;
-use tinywasm::types::{FuncType, RefType, RefValue, WasmType, WasmValue};
+use tinywasm::types::{ExternRef, FuncType, RefType, RefValue, WasmType, WasmValue};
use tinywasm::{FuncContext, HostFunction, Imports, Module, ModuleInstance, Store};
-use tinywasm_types::ExternRef;
const VAL_LISTS: &[&[WasmValue]] = &[
&[],
@@ -27,7 +25,7 @@ fn module_cases() -> Vec<(Module, FuncType, Vec<WasmValue>)> {
}
#[test]
-fn test_return_invalid_type() -> Result<()> {
+fn test_return_invalid_type() -> Result<(), Box<dyn core::error::Error>> {
let cases = module_cases();
for (module, ty, args) in cases {
@@ -51,7 +49,7 @@ fn test_return_invalid_type() -> Result<()> {
}
#[test]
-fn test_linking_invalid_untyped_func() -> Result<()> {
+fn test_linking_invalid_untyped_func() -> Result<(), Box<dyn core::error::Error>> {
let cases = module_cases();
for (module, expected_func_ty, _) in &cases {
for (_, ty, _) in &cases {
@@ -69,7 +67,7 @@ fn test_linking_invalid_untyped_func() -> Result<()> {
}
#[test]
-fn test_linking_invalid_typed_func() -> Result<()> {
+fn test_linking_invalid_typed_func() -> Result<(), Box<dyn core::error::Error>> {
type Existing = (i32, i32, f64);
type NonMatchingSingle = f64;
type NonMatchingTuple = (f64, i32, i32);
@@ -107,7 +105,7 @@ fn test_linking_invalid_typed_func() -> Result<()> {
}
#[test]
-fn concrete_host_references_use_canonical_types() -> Result<()> {
+fn concrete_host_references_use_canonical_types() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(
r#"
(module
@@ -145,7 +143,7 @@ fn concrete_host_references_use_canonical_types() -> Result<()> {
}
#[test]
-fn imported_host_functions_resolve_concrete_types() -> Result<()> {
+fn imported_host_functions_resolve_concrete_types() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(
r#"
(module
@@ -173,7 +171,7 @@ fn imported_host_functions_resolve_concrete_types() -> Result<()> {
}
#[test]
-fn host_tail_calls_return_from_the_current_frame() -> Result<()> {
+fn host_tail_calls_return_from_the_current_frame() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(
r#"
(module
@@ -210,7 +208,7 @@ fn host_tail_calls_return_from_the_current_frame() -> Result<()> {
}
#[test]
-fn host_calls_reject_unknown_function_references() -> Result<()> {
+fn host_calls_reject_unknown_function_references() -> Result<(), Box<dyn core::error::Error>> {
let mut store = Store::default();
let ty = FuncType::new(&[WasmType::Ref(tinywasm::types::RefType::FUNCREF)], &[]);
let host = HostFunction::from_untyped(&ty, |_, _| Ok(Vec::new())).instantiate(&mut store)?;
diff --git a/crates/tinywasm/tests/import_linking.rs b/crates/tinywasm/tests/import_linking.rs
index 1d5db1b..a65c8a4 100644
--- a/crates/tinywasm/tests/import_linking.rs
+++ b/crates/tinywasm/tests/import_linking.rs
@@ -1,4 +1,3 @@
-use eyre::Result;
use tinywasm::{Error, Imports, Module, ModuleInstance, Store, Trap};
const WASM_ADD: &str = r#"
@@ -19,14 +18,14 @@ const WASM_IMPORT: &str = r#"
call $add))
"#;
-fn parse_modules() -> Result<(Module, Module)> {
+fn parse_modules() -> Result<(Module, Module), Box<dyn core::error::Error>> {
let add = tinywasm::parse_bytes(&wat::parse_str(WASM_ADD)?)?;
let import = tinywasm::parse_bytes(&wat::parse_str(WASM_IMPORT)?)?;
Ok((add, import))
}
#[test]
-fn link_module_links_same_store_instance() -> Result<()> {
+fn link_module_links_same_store_instance() -> Result<(), Box<dyn core::error::Error>> {
let (add_module, import_module) = parse_modules()?;
let mut store = Store::default();
@@ -41,7 +40,7 @@ fn link_module_links_same_store_instance() -> Result<()> {
}
#[test]
-fn link_module_rejects_cross_store_instance() -> Result<()> {
+fn link_module_rejects_cross_store_instance() -> Result<(), Box<dyn core::error::Error>> {
let (add_module, import_module) = parse_modules()?;
let mut source_store = Store::default();
diff --git a/crates/tinywasm/tests/imported_table_init.rs b/crates/tinywasm/tests/imported_table_init.rs
index ca52e9e..aaa781b 100644
--- a/crates/tinywasm/tests/imported_table_init.rs
+++ b/crates/tinywasm/tests/imported_table_init.rs
@@ -1,9 +1,8 @@
-use eyre::Result;
use tinywasm::types::{FuncRef, RefType, TableType};
use tinywasm::{HostFunction, Imports, ModuleInstance, Store, Table};
#[test]
-fn imported_table_uses_provided_init_value() -> Result<()> {
+fn imported_table_uses_provided_init_value() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(
r#"
(module
diff --git a/crates/tinywasm/tests/internal_refs.rs b/crates/tinywasm/tests/internal_refs.rs
index 196ad0a..07cbde2 100644
--- a/crates/tinywasm/tests/internal_refs.rs
+++ b/crates/tinywasm/tests/internal_refs.rs
@@ -1,4 +1,3 @@
-use eyre::Result;
use tinywasm::types::WasmValue;
#[cfg(feature = "guest-debug")]
use tinywasm::types::{FuncRef, RefValue};
@@ -6,7 +5,7 @@ use tinywasm::{ExternItem, ModuleInstance, Store};
#[test]
#[cfg(feature = "guest-debug")]
-fn private_items_are_accessible_by_index() -> Result<()> {
+fn private_items_are_accessible_by_index() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(
r#"
(module
@@ -42,7 +41,7 @@ fn private_items_are_accessible_by_index() -> Result<()> {
}
#[test]
-fn exported_tables_and_globals_have_handle_and_helper_apis() -> Result<()> {
+fn exported_tables_and_globals_have_handle_and_helper_apis() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(
r#"
(module
@@ -73,7 +72,7 @@ fn exported_tables_and_globals_have_handle_and_helper_apis() -> Result<()> {
}
#[test]
-fn extern_item_lookup_returns_expected_kinds() -> Result<()> {
+fn extern_item_lookup_returns_expected_kinds() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(
r#"
(module
@@ -98,7 +97,7 @@ fn extern_item_lookup_returns_expected_kinds() -> Result<()> {
}
#[test]
-fn extern_item_and_exports_use_actual_function_type() -> Result<()> {
+fn extern_item_and_exports_use_actual_function_type() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(
r#"
(module
@@ -134,7 +133,7 @@ fn extern_item_and_exports_use_actual_function_type() -> Result<()> {
}
#[test]
-fn export_func_type_index_mismatch_fixture_would_break_old_lookup() -> Result<()> {
+fn export_func_type_index_mismatch_fixture_would_break_old_lookup() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(
r#"
(module
@@ -177,7 +176,7 @@ fn export_func_type_index_mismatch_fixture_would_break_old_lookup() -> Result<()
}
#[test]
-fn start_resolves_module_func_index_to_store_addr() -> Result<()> {
+fn start_resolves_module_func_index_to_store_addr() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(
r#"
(module
diff --git a/crates/tinywasm/tests/memory_backends.rs b/crates/tinywasm/tests/memory_backends.rs
index 0cf5707..b7f9438 100644
--- a/crates/tinywasm/tests/memory_backends.rs
+++ b/crates/tinywasm/tests/memory_backends.rs
@@ -6,13 +6,14 @@ use core::sync::atomic::{AtomicUsize, Ordering};
#[cfg(feature = "std")]
use std::io::{Read, Seek, SeekFrom, Write};
-use eyre::Result;
use tinywasm::engine::Config;
use tinywasm::types::{MemoryArch, MemoryType};
use tinywasm::{Engine, Memory, MemoryBackend, Module, ModuleInstance, PagedMemory, Store};
use tinywasm_parser::{Parser, ParserOptions};
-fn instantiate_module_with_counting_backend(module: Module) -> Result<usize> {
+type TestResult<T = ()> = Result<T, Box<dyn core::error::Error>>;
+
+fn instantiate_module_with_counting_backend(module: Module) -> TestResult<usize> {
let created = Arc::new(AtomicUsize::new(0));
let factory_calls = created.clone();
let backend = MemoryBackend::custom(move |ty| {
@@ -27,7 +28,7 @@ fn instantiate_module_with_counting_backend(module: Module) -> Result<usize> {
Ok(created.load(Ordering::Relaxed))
}
-fn instantiate_with_counting_backend(wat: &str) -> Result<usize> {
+fn instantiate_with_counting_backend(wat: &str) -> TestResult<usize> {
let wasm = wat::parse_str(wat)?;
let module = tinywasm::parse_bytes(&wasm)?;
instantiate_module_with_counting_backend(module)
@@ -35,7 +36,7 @@ fn instantiate_with_counting_backend(wat: &str) -> Result<usize> {
fn instantiate_exported_memory_with_counting_backend(
wat: &str,
-) -> Result<(Store, tinywasm::ModuleInstance, Arc<AtomicUsize>)> {
+) -> TestResult<(Store, tinywasm::ModuleInstance, Arc<AtomicUsize>)> {
let wasm = wat::parse_str(wat)?;
let module = tinywasm::parse_bytes(&wasm)?;
let created = Arc::new(AtomicUsize::new(0));
@@ -51,7 +52,7 @@ fn instantiate_exported_memory_with_counting_backend(
}
#[test]
-fn paged_backend_works_for_module_memories() -> Result<()> {
+fn paged_backend_works_for_module_memories() -> TestResult {
let wasm = wat::parse_str(
r#"
(module
@@ -73,7 +74,7 @@ fn paged_backend_works_for_module_memories() -> Result<()> {
}
#[test]
-fn custom_backend_factory_is_used_for_host_memories() -> Result<()> {
+fn custom_backend_factory_is_used_for_host_memories() -> TestResult {
let created = Arc::new(AtomicUsize::new(0));
let seen_page_size = Arc::new(AtomicUsize::new(0));
let factory_calls = created.clone();
@@ -100,7 +101,7 @@ fn custom_backend_factory_is_used_for_host_memories() -> Result<()> {
}
#[test]
-fn local_memory_without_observable_use_is_not_allocated() -> Result<()> {
+fn local_memory_without_observable_use_is_not_allocated() -> TestResult {
let created = instantiate_with_counting_backend(
r#"
(module
@@ -115,7 +116,7 @@ fn local_memory_without_observable_use_is_not_allocated() -> Result<()> {
}
#[test]
-fn exported_local_memory_is_not_eagerly_allocated() -> Result<()> {
+fn exported_local_memory_is_not_eagerly_allocated() -> TestResult {
let created = instantiate_with_counting_backend(
r#"
(module
@@ -129,7 +130,7 @@ fn exported_local_memory_is_not_eagerly_allocated() -> Result<()> {
}
#[test]
-fn exported_local_memory_reads_zeroes_without_materializing() -> Result<()> {
+fn exported_local_memory_reads_zeroes_without_materializing() -> TestResult {
let (mut store, instance, created) = instantiate_exported_memory_with_counting_backend(
r#"
(module
@@ -151,7 +152,7 @@ fn exported_local_memory_reads_zeroes_without_materializing() -> Result<()> {
}
#[test]
-fn active_data_segment_on_local_memory_is_allocated() -> Result<()> {
+fn active_data_segment_on_local_memory_is_allocated() -> TestResult {
let created = instantiate_with_counting_backend(
r#"
(module
@@ -166,7 +167,7 @@ fn active_data_segment_on_local_memory_is_allocated() -> Result<()> {
}
#[test]
-fn local_memory_instruction_is_allocated() -> Result<()> {
+fn local_memory_instruction_is_allocated() -> TestResult {
let created = instantiate_with_counting_backend(
r#"
(module
@@ -181,7 +182,7 @@ fn local_memory_instruction_is_allocated() -> Result<()> {
}
#[test]
-fn disabled_local_memory_allocation_optimization_keeps_old_behavior() -> Result<()> {
+fn disabled_local_memory_allocation_optimization_keeps_old_behavior() -> TestResult {
let wasm = wat::parse_str(
r#"
(module
@@ -200,7 +201,7 @@ fn disabled_local_memory_allocation_optimization_keeps_old_behavior() -> Result<
}
#[test]
-fn read_returns_short_count_at_end_of_memory() -> Result<()> {
+fn read_returns_short_count_at_end_of_memory() -> TestResult {
let mut store = Store::default();
let memory = Memory::new(&mut store, MemoryType::new(MemoryArch::I32, 1, Some(1), Some(4)))?;
memory.copy_from_slice(&mut store, 0, &[1, 2, 3, 4])?;
@@ -214,7 +215,7 @@ fn read_returns_short_count_at_end_of_memory() -> Result<()> {
}
#[test]
-fn paged_read_and_write_stop_at_chunk_boundaries() -> Result<()> {
+fn paged_read_and_write_stop_at_chunk_boundaries() -> TestResult {
let engine = Engine::new(Config::new().with_memory_backend(MemoryBackend::paged(4)));
let mut store = Store::new(engine);
let memory = Memory::new(&mut store, MemoryType::new(MemoryArch::I32, 1, Some(1), Some(16)))?;
@@ -241,7 +242,7 @@ fn paged_read_and_write_stop_at_chunk_boundaries() -> Result<()> {
#[cfg(feature = "std")]
#[test]
-fn memory_cursor_supports_read_write_and_seek() -> Result<()> {
+fn memory_cursor_supports_read_write_and_seek() -> TestResult {
let mut store = Store::default();
let memory = Memory::new(&mut store, MemoryType::new(MemoryArch::I32, 1, Some(1), Some(8)))?;
diff --git a/crates/tinywasm/tests/memory_ref_api.rs b/crates/tinywasm/tests/memory_ref_api.rs
index 6f72477..768c873 100644
--- a/crates/tinywasm/tests/memory_ref_api.rs
+++ b/crates/tinywasm/tests/memory_ref_api.rs
@@ -1,8 +1,7 @@
-use eyre::Result;
use tinywasm::{ModuleInstance, Store};
#[test]
-fn memory_ref_mut_copy_within_uses_src_then_dst_order() -> Result<()> {
+fn memory_ref_mut_copy_within_uses_src_then_dst_order() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(
r#"
(module
diff --git a/crates/tinywasm/tests/module_descriptors.rs b/crates/tinywasm/tests/module_descriptors.rs
index 81ab5ab..8bd73b6 100644
--- a/crates/tinywasm/tests/module_descriptors.rs
+++ b/crates/tinywasm/tests/module_descriptors.rs
@@ -1,9 +1,7 @@
-use eyre::Result;
-use tinywasm::types::WasmType;
-use tinywasm_types::{ExportType, ImportType};
+use tinywasm::types::{ExportType, ImportType, WasmType};
#[test]
-fn module_descriptors_resolve_imported_and_local_export_types() -> Result<()> {
+fn module_descriptors_resolve_imported_and_local_export_types() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(
r#"
(module
@@ -91,7 +89,7 @@ fn module_descriptors_resolve_imported_and_local_export_types() -> Result<()> {
}
#[test]
-fn module_descriptors_resolve_imported_and_local_table_and_memory_exports() -> Result<()> {
+fn module_descriptors_resolve_imported_and_local_table_and_memory_exports() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(
r#"
(module
diff --git a/crates/tinywasm/tests/resume_execution.rs b/crates/tinywasm/tests/resume_execution.rs
index 060cefb..2798e7b 100644
--- a/crates/tinywasm/tests/resume_execution.rs
+++ b/crates/tinywasm/tests/resume_execution.rs
@@ -1,6 +1,5 @@
-use eyre::Result;
use tinywasm::engine::{Config, FuelPolicy};
-use tinywasm::{ExecProgress, ModuleInstance, types::WasmValue};
+use tinywasm::{ExecProgress, ModuleInstance, Result, types::WasmValue};
#[cfg(feature = "std")]
use std::time::Duration;
diff --git a/crates/tinywasm/tests/start_function.rs b/crates/tinywasm/tests/start_function.rs
index 077c0fc..912b200 100644
--- a/crates/tinywasm/tests/start_function.rs
+++ b/crates/tinywasm/tests/start_function.rs
@@ -1,8 +1,7 @@
-use eyre::Result;
use tinywasm::{ModuleInstance, Store};
#[test]
-fn exported_wasi_start_is_not_run_during_instantiation() -> Result<()> {
+fn exported_wasi_start_is_not_run_during_instantiation() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(
r#"
(module
diff --git a/crates/tinywasm/tests/store_ownership.rs b/crates/tinywasm/tests/store_ownership.rs
index bcb8e07..a508817 100644
--- a/crates/tinywasm/tests/store_ownership.rs
+++ b/crates/tinywasm/tests/store_ownership.rs
@@ -1,4 +1,3 @@
-use eyre::Result;
use tinywasm::types::{GlobalType, WasmType};
use tinywasm::{Global, Imports, ModuleInstance, Store};
@@ -13,7 +12,7 @@ const MODULE_WAT: &str = r#"
"#;
#[test]
-fn func_handle_rejects_wrong_store() -> Result<()> {
+fn func_handle_rejects_wrong_store() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(MODULE_WAT)?;
let module = tinywasm::parse_bytes(&wasm)?;
@@ -29,7 +28,7 @@ fn func_handle_rejects_wrong_store() -> Result<()> {
}
#[test]
-fn memory_access_rejects_wrong_store() -> Result<()> {
+fn memory_access_rejects_wrong_store() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(MODULE_WAT)?;
let module = tinywasm::parse_bytes(&wasm)?;
@@ -45,7 +44,7 @@ fn memory_access_rejects_wrong_store() -> Result<()> {
}
#[test]
-fn global_access_rejects_wrong_store() -> Result<()> {
+fn global_access_rejects_wrong_store() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(
r#"
(module
@@ -67,7 +66,7 @@ fn global_access_rejects_wrong_store() -> Result<()> {
}
#[test]
-fn table_grow_rejects_wrong_store_with_invalid_store_error() -> Result<()> {
+fn table_grow_rejects_wrong_store_with_invalid_store_error() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(
r#"
(module
@@ -89,7 +88,7 @@ fn table_grow_rejects_wrong_store_with_invalid_store_error() -> Result<()> {
}
#[test]
-fn global_import_rejects_wrong_store() -> Result<()> {
+fn global_import_rejects_wrong_store() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(r#"(module (import "env" "g" (global i32)))"#)?;
let module = tinywasm::parse_bytes(&wasm)?;
let mut owner_store = Store::default();
diff --git a/crates/tinywasm/tests/test-wasm-1.rs b/crates/tinywasm/tests/test-wasm-1.rs
index be235ae..723f007 100644
--- a/crates/tinywasm/tests/test-wasm-1.rs
+++ b/crates/tinywasm/tests/test-wasm-1.rs
@@ -1,9 +1,7 @@
-mod testsuite;
-use eyre::Result;
-use testsuite::TestSuite;
+use tinywasm_cli::testsuite::TestSuite;
use wasm_testsuite::data::{SpecVersion, spec};
-fn main() -> Result<()> {
+fn main() -> Result<(), Box<dyn core::error::Error>> {
TestSuite::set_log_level(log::LevelFilter::Off);
let mut test_suite = TestSuite::new();
diff --git a/crates/tinywasm/tests/test-wasm-2.rs b/crates/tinywasm/tests/test-wasm-2.rs
index 0379ca6..c762eec 100644
--- a/crates/tinywasm/tests/test-wasm-2.rs
+++ b/crates/tinywasm/tests/test-wasm-2.rs
@@ -1,9 +1,7 @@
-mod testsuite;
-use eyre::Result;
-use testsuite::TestSuite;
+use tinywasm_cli::testsuite::TestSuite;
use wasm_testsuite::data::{SpecVersion, spec};
-fn main() -> Result<()> {
+fn main() -> Result<(), Box<dyn core::error::Error>> {
TestSuite::set_log_level(log::LevelFilter::Off);
let mut test_suite = TestSuite::new();
diff --git a/crates/tinywasm/tests/test-wasm-3.rs b/crates/tinywasm/tests/test-wasm-3.rs
index 11ebbc8..a843ae0 100644
--- a/crates/tinywasm/tests/test-wasm-3.rs
+++ b/crates/tinywasm/tests/test-wasm-3.rs
@@ -1,9 +1,7 @@
-mod testsuite;
-use eyre::Result;
-use testsuite::TestSuite;
+use tinywasm_cli::testsuite::TestSuite;
use wasm_testsuite::data::{SpecVersion, spec};
-fn main() -> Result<()> {
+fn main() -> Result<(), Box<dyn core::error::Error>> {
TestSuite::set_log_level(log::LevelFilter::Off);
let mut test_suite = TestSuite::new();
diff --git a/crates/tinywasm/tests/test-wasm-custom-page-sizes.rs b/crates/tinywasm/tests/test-wasm-custom-page-sizes.rs
index e4aacfc..a71266a 100644
--- a/crates/tinywasm/tests/test-wasm-custom-page-sizes.rs
+++ b/crates/tinywasm/tests/test-wasm-custom-page-sizes.rs
@@ -1,9 +1,7 @@
-mod testsuite;
-use eyre::Result;
-use testsuite::TestSuite;
+use tinywasm_cli::testsuite::TestSuite;
use wasm_testsuite::data::{Proposal, proposal};
-fn main() -> Result<()> {
+fn main() -> Result<(), Box<dyn core::error::Error>> {
TestSuite::set_log_level(log::LevelFilter::Off);
let mut test_suite = TestSuite::new();
diff --git a/crates/tinywasm/tests/test-wasm-custom.rs b/crates/tinywasm/tests/test-wasm-custom.rs
index ae08142..b516428 100644
--- a/crates/tinywasm/tests/test-wasm-custom.rs
+++ b/crates/tinywasm/tests/test-wasm-custom.rs
@@ -1,8 +1,6 @@
-mod testsuite;
-use eyre::Result;
-use testsuite::TestSuite;
+use tinywasm_cli::testsuite::TestSuite;
-fn main() -> Result<()> {
+fn main() -> Result<(), Box<dyn core::error::Error>> {
TestSuite::set_log_level(log::LevelFilter::Off);
let custom_dir = std::path::Path::new("./tests/wasm-custom");
diff --git a/crates/tinywasm/tests/test-wasm-gc.rs b/crates/tinywasm/tests/test-wasm-gc.rs
index a80d347..86496c4 100644
--- a/crates/tinywasm/tests/test-wasm-gc.rs
+++ b/crates/tinywasm/tests/test-wasm-gc.rs
@@ -1,9 +1,7 @@
-mod testsuite;
-use eyre::Result;
-use testsuite::TestSuite;
+use tinywasm_cli::testsuite::TestSuite;
use wasm_testsuite::data::{Proposal, proposal};
-fn main() -> Result<()> {
+fn main() -> Result<(), Box<dyn core::error::Error>> {
TestSuite::set_log_level(log::LevelFilter::Off);
let mut test_suite = TestSuite::new();
diff --git a/crates/tinywasm/tests/test-wasm-latest.rs b/crates/tinywasm/tests/test-wasm-latest.rs
index af83c2f..649c44c 100644
--- a/crates/tinywasm/tests/test-wasm-latest.rs
+++ b/crates/tinywasm/tests/test-wasm-latest.rs
@@ -1,9 +1,7 @@
-mod testsuite;
-use eyre::Result;
-use testsuite::TestSuite;
+use tinywasm_cli::testsuite::TestSuite;
use wasm_testsuite::data::{SpecVersion, spec};
-fn main() -> Result<()> {
+fn main() -> Result<(), Box<dyn core::error::Error>> {
TestSuite::set_log_level(log::LevelFilter::Off);
let mut test_suite = TestSuite::new();
diff --git a/crates/tinywasm/tests/test-wasm-memory64.rs b/crates/tinywasm/tests/test-wasm-memory64.rs
index 447bbfc..717ae03 100644
--- a/crates/tinywasm/tests/test-wasm-memory64.rs
+++ b/crates/tinywasm/tests/test-wasm-memory64.rs
@@ -1,9 +1,7 @@
-mod testsuite;
-use eyre::Result;
-use testsuite::TestSuite;
+use tinywasm_cli::testsuite::TestSuite;
use wasm_testsuite::data::{Proposal, proposal};
-fn main() -> Result<()> {
+fn main() -> Result<(), Box<dyn core::error::Error>> {
TestSuite::set_log_level(log::LevelFilter::Off);
let mut test_suite = TestSuite::new();
diff --git a/crates/tinywasm/tests/test-wasm-multi-memory.rs b/crates/tinywasm/tests/test-wasm-multi-memory.rs
index e4487f1..b0963b2 100644
--- a/crates/tinywasm/tests/test-wasm-multi-memory.rs
+++ b/crates/tinywasm/tests/test-wasm-multi-memory.rs
@@ -1,9 +1,7 @@
-mod testsuite;
-use eyre::Result;
-use testsuite::TestSuite;
+use tinywasm_cli::testsuite::TestSuite;
use wasm_testsuite::data::{Proposal, proposal};
-fn main() -> Result<()> {
+fn main() -> Result<(), Box<dyn core::error::Error>> {
TestSuite::set_log_level(log::LevelFilter::Off);
let mut test_suite = TestSuite::new();
diff --git a/crates/tinywasm/tests/test-wasm-relaxed-simd.rs b/crates/tinywasm/tests/test-wasm-relaxed-simd.rs
index 0851d18..92a5991 100644
--- a/crates/tinywasm/tests/test-wasm-relaxed-simd.rs
+++ b/crates/tinywasm/tests/test-wasm-relaxed-simd.rs
@@ -1,9 +1,7 @@
-mod testsuite;
-use eyre::Result;
-use testsuite::TestSuite;
+use tinywasm_cli::testsuite::TestSuite;
use wasm_testsuite::data::{Proposal, proposal};
-fn main() -> Result<()> {
+fn main() -> Result<(), Box<dyn core::error::Error>> {
TestSuite::set_log_level(log::LevelFilter::Off);
let mut test_suite = TestSuite::new();
diff --git a/crates/tinywasm/tests/test-wasm-simd.rs b/crates/tinywasm/tests/test-wasm-simd.rs
index d8f15ea..3d1932f 100644
--- a/crates/tinywasm/tests/test-wasm-simd.rs
+++ b/crates/tinywasm/tests/test-wasm-simd.rs
@@ -1,9 +1,7 @@
-mod testsuite;
-use eyre::Result;
-use testsuite::TestSuite;
+use tinywasm_cli::testsuite::TestSuite;
use wasm_testsuite::data::{Proposal, proposal};
-fn main() -> Result<()> {
+fn main() -> Result<(), Box<dyn core::error::Error>> {
TestSuite::set_log_level(log::LevelFilter::Off);
let mut test_suite = TestSuite::new();
diff --git a/crates/tinywasm/tests/test-wasm-threads.rs b/crates/tinywasm/tests/test-wasm-threads.rs
index 2fd5a9b..5cff235 100644
--- a/crates/tinywasm/tests/test-wasm-threads.rs
+++ b/crates/tinywasm/tests/test-wasm-threads.rs
@@ -1,9 +1,7 @@
-mod testsuite;
-use eyre::Result;
-use testsuite::TestSuite;
+use tinywasm_cli::testsuite::TestSuite;
use wasm_testsuite::data::{Proposal, proposal};
-fn main() -> Result<()> {
+fn main() -> Result<(), Box<dyn core::error::Error>> {
TestSuite::set_log_level(log::LevelFilter::Off);
let mut test_suite = TestSuite::new();
diff --git a/crates/tinywasm/tests/test-wasm-wide-arithmetic.rs b/crates/tinywasm/tests/test-wasm-wide-arithmetic.rs
index 2aa6b43..e4b5647 100644
--- a/crates/tinywasm/tests/test-wasm-wide-arithmetic.rs
+++ b/crates/tinywasm/tests/test-wasm-wide-arithmetic.rs
@@ -1,9 +1,7 @@
-mod testsuite;
-use eyre::Result;
-use testsuite::TestSuite;
+use tinywasm_cli::testsuite::TestSuite;
use wasm_testsuite::data::{Proposal, proposal};
-fn main() -> Result<()> {
+fn main() -> Result<(), Box<dyn core::error::Error>> {
TestSuite::set_log_level(log::LevelFilter::Off);
let mut test_suite = TestSuite::new();
diff --git a/crates/tinywasm/tests/test-wast.rs b/crates/tinywasm/tests/test-wast.rs
index 92fcbd2..004bafa 100644
--- a/crates/tinywasm/tests/test-wast.rs
+++ b/crates/tinywasm/tests/test-wast.rs
@@ -1,12 +1,9 @@
-use std::path::PathBuf;
-
-use eyre::{Result, bail};
use tinywasm_cli::wast_runner::WastRunner;
-fn main() -> Result<()> {
- let args = std::env::args().collect::<Vec<_>>();
- if args.len() < 2 {
- bail!("usage: cargo test-wast <wast-file>");
+fn main() -> Result<(), Box<dyn core::error::Error>> {
+ let Some(input) = std::env::args().nth(1) else {
+ eprintln!("usage: cargo test-wast <wast-file>");
+ std::process::exit(2);
};
let mut cwd = std::env::current_dir()?;
@@ -15,8 +12,7 @@ fn main() -> Result<()> {
cwd.pop();
}
- // if its a folder, run all the wast files in the folder
- let arg = PathBuf::from(cwd.clone()).join(&args[1]);
+ let arg = cwd.join(input);
println!("running tests in {:?}", arg);
let files = if arg.is_dir() {
@@ -26,5 +22,6 @@ fn main() -> Result<()> {
};
let mut test_suite = WastRunner::new();
- test_suite.run_paths(&files)
+ test_suite.run_paths(&files)?;
+ Ok(())
}
diff --git a/crates/tinywasm/tests/typed_globals.rs b/crates/tinywasm/tests/typed_globals.rs
index 9d88ec8..ac79f6a 100644
--- a/crates/tinywasm/tests/typed_globals.rs
+++ b/crates/tinywasm/tests/typed_globals.rs
@@ -1,9 +1,8 @@
-use eyre::Result;
use tinywasm::types::{GlobalType, Instruction, RefValue, WasmType, WasmValue};
use tinywasm::{Global, Imports, ModuleInstance, Store};
#[test]
-fn globals_use_typed_instructions_and_roundtrip_values() -> Result<()> {
+fn globals_use_typed_instructions_and_roundtrip_values() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(
r#"
(module
@@ -70,7 +69,7 @@ fn globals_use_typed_instructions_and_roundtrip_values() -> Result<()> {
}
#[test]
-fn imported_global_keeps_its_typed_store_address() -> Result<()> {
+fn imported_global_keeps_its_typed_store_address() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(
r#"
(module
diff --git a/crates/tinywasm/tests/typed_lookup.rs b/crates/tinywasm/tests/typed_lookup.rs
index 15b31b1..c5e052e 100644
--- a/crates/tinywasm/tests/typed_lookup.rs
+++ b/crates/tinywasm/tests/typed_lookup.rs
@@ -1,8 +1,7 @@
-use eyre::Result;
use tinywasm::ModuleInstance;
#[test]
-fn func_typed_rejects_wrong_param_or_result_types() -> Result<()> {
+fn func_typed_rejects_wrong_param_or_result_types() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(
r#"
(module
@@ -26,7 +25,7 @@ fn func_typed_rejects_wrong_param_or_result_types() -> Result<()> {
}
#[test]
-fn func_typed_rejects_partial_multi_value_results() -> Result<()> {
+fn func_typed_rejects_partial_multi_value_results() -> Result<(), Box<dyn core::error::Error>> {
let wasm = wat::parse_str(
r#"
(module