support unit testing wasm via wasmtime

This commit is contained in:
Mitchell Hashimoto
2022-11-30 15:04:45 -08:00
parent 3a4d881444
commit 6b101c2293

View File

@ -73,6 +73,9 @@ pub fn build(b: *std.build.Builder) !void {
"Build and install test executables with 'build'",
) orelse false;
// We can use wasmtime to test wasm
b.enable_wasmtime = true;
// Add our benchmarks
try benchSteps(b, target, mode);
@ -124,6 +127,15 @@ pub fn build(b: *std.build.Builder) !void {
const step = b.step("wasm", "Build the wasm library");
step.dependOn(&wasm.step);
// We support tests via wasmtime. wasmtime uses WASI so this
// isn't an exact match to our freestanding target above but
// it lets us test some basic functionality.
const test_step = b.step("test-wasm", "Run all tests for wasm");
const main_test = b.addTest("src/main_wasm.zig");
main_test.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .wasi });
main_test.addOptions("build_options", exe_options);
test_step.dependOn(&main_test.step);
}
// Run