From 0bcd3fbadef087b2b3ed6e4f398f6e6c36f11209 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 3 Dec 2023 13:15:56 +0000 Subject: Use node instead of wasmtime to run Wasm binaries --- .../compiler/backends/wasm/WasmPatioCodeGenTests.java | 14 ++++++-------- .../compiler/backends/wasm/WasmPatioExampleTests.java | 2 +- .../shedlang/compiler/backends/wasm/WasmTesting.java | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 src/test/java/org/shedlang/compiler/backends/wasm/WasmTesting.java (limited to 'src/test/java') diff --git a/src/test/java/org/shedlang/compiler/backends/wasm/WasmPatioCodeGenTests.java b/src/test/java/org/shedlang/compiler/backends/wasm/WasmPatioCodeGenTests.java index 1ede4222..f7f8b47a 100644 --- a/src/test/java/org/shedlang/compiler/backends/wasm/WasmPatioCodeGenTests.java +++ b/src/test/java/org/shedlang/compiler/backends/wasm/WasmPatioCodeGenTests.java @@ -10,11 +10,11 @@ import org.shedlang.compiler.backends.wasm.structure.ast.modules.WasmImportDescr import org.shedlang.compiler.backends.wasm.structure.ast.types.WasmFuncType; import org.shedlang.compiler.backends.wasm.structure.ast.types.WasmValueType; import org.shedlang.compiler.backends.wasm.structure.binary.WasmBinaryFormatTesting; -import org.shedlang.compiler.filesystem.ShedCompilerFiles; import org.shedlang.compiler.patio.PatioExampleTests; import org.shedlang.compiler.patio.ast.PatioCompilationUnit; import org.shedlang.compiler.testing.ExecutionResult; import org.shedlang.compiler.testing.TestProcessRunner; +import org.shedlang.compiler.util.Lists; import java.io.FileOutputStream; import java.io.IOException; @@ -65,13 +65,11 @@ public class WasmPatioCodeGenTests extends PatioExampleTests { WasmBinaryFormatTesting.validate(executablePath); - return TestProcessRunner.runCaptureOutput(List.of( - "node", - "--experimental-wasi-unstable-preview1", - "--no-warnings=ExperimentalWarning", - "--experimental-wasm-eh", - ShedCompilerFiles.getRoot().resolve("run-wasm.js").toString(), - executablePath.toString() + return TestProcessRunner.runCaptureOutput(Lists.concat( + WasmTesting.BINARY_RUNNER, + List.of( + executablePath.toString() + ) )); } } diff --git a/src/test/java/org/shedlang/compiler/backends/wasm/WasmPatioExampleTests.java b/src/test/java/org/shedlang/compiler/backends/wasm/WasmPatioExampleTests.java index 82aaef2d..95585ee4 100644 --- a/src/test/java/org/shedlang/compiler/backends/wasm/WasmPatioExampleTests.java +++ b/src/test/java/org/shedlang/compiler/backends/wasm/WasmPatioExampleTests.java @@ -13,7 +13,7 @@ public class WasmPatioExampleTests extends ExampleTests { @Override protected List binaryRunner() { - return List.of("wasmtime"); + return WasmTesting.BINARY_RUNNER; } @Override diff --git a/src/test/java/org/shedlang/compiler/backends/wasm/WasmTesting.java b/src/test/java/org/shedlang/compiler/backends/wasm/WasmTesting.java new file mode 100644 index 00000000..5de7e949 --- /dev/null +++ b/src/test/java/org/shedlang/compiler/backends/wasm/WasmTesting.java @@ -0,0 +1,18 @@ +package org.shedlang.compiler.backends.wasm; + +import org.shedlang.compiler.filesystem.ShedCompilerFiles; + +import java.util.List; + +public class WasmTesting { + private WasmTesting() { + } + + public static final List BINARY_RUNNER = List.of( + "node", + "--experimental-wasi-unstable-preview1", + "--experimental-wasm-eh", + "--no-warnings=ExperimentalWarning", + ShedCompilerFiles.getRoot().resolve("run-wasm.js").toString() + ); +} -- cgit v1.2.3