From d7cae4af55808f96936eceddecaef38b487052a5 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Tue, 22 Aug 2023 17:02:33 +0200 Subject: [PATCH] Fix running tests in wasm --- tests/build.gradle.kts | 22 ++++++++++++++----- tests/run-wasi.sh | 2 +- .../java/org/teavm/junit/TeaVMTestRunner.java | 10 --------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/tests/build.gradle.kts b/tests/build.gradle.kts index e5abeaeb8..908ad2aaa 100644 --- a/tests/build.gradle.kts +++ b/tests/build.gradle.kts @@ -39,11 +39,23 @@ dependencies { } tasks.test { - systemProperty("teavm.junit.target", "${project.buildDir.absolutePath }/js-tests") - systemProperty("teavm.junit.js.runner", "browser-chrome") + systemProperty("teavm.junit.target", "${project.buildDir.absolutePath }/teavm-tests") systemProperty("teavm.junit.threads", "1") - systemProperty("teavm.junit.minified", providers.gradleProperty("teavm.tests.minified")) - systemProperty("teavm.junit.optimized", providers.gradleProperty("teavm.tests.optimized")) - systemProperty("teavm.junit.js.decodeStack", providers.gradleProperty("teavm.tests.decodeStack")) + val browser = providers.gradleProperty("teavm.tests.browser").orElse("browser-chrome").get() + + systemProperty("teavm.junit.js", providers.gradleProperty("teavm.tests.wasm").orElse("true").get()) + systemProperty("teavm.junit.js.runner", browser) + systemProperty("teavm.junit.minified", providers.gradleProperty("teavm.tests.minified").orElse("false").get()) + systemProperty("teavm.junit.optimized", providers.gradleProperty("teavm.tests.optimized").orElse("false").get()) + systemProperty("teavm.junit.js.decodeStack", providers.gradleProperty("teavm.tests.decodeStack") + .orElse("false").get()) + + systemProperty("teavm.junit.wasm", providers.gradleProperty("teavm.tests.wasm").orElse("false").get()) + systemProperty("teavm.junit.wasm.runner", browser) + + systemProperty("teavm.junit.wasi", providers.gradleProperty("teavm.tests.wasi").orElse("false").get()) + systemProperty("teavm.junit.wasi.runner", providers.gradleProperty("teavm.tests.wasi.runner") + .orElse("./run-wasi.sh").get()) + maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) } \ No newline at end of file diff --git a/tests/run-wasi.sh b/tests/run-wasi.sh index 63146a532..861388ff7 100755 --- a/tests/run-wasi.sh +++ b/tests/run-wasi.sh @@ -1 +1 @@ -~/.wasmtime/bin/wasmtime run --mapdir /::target/wasi-testdir $1 $2 \ No newline at end of file +~/.wasmtime/bin/wasmtime run --mapdir /::build/wasi-testdir $1 $2 \ No newline at end of file diff --git a/tools/junit/src/main/java/org/teavm/junit/TeaVMTestRunner.java b/tools/junit/src/main/java/org/teavm/junit/TeaVMTestRunner.java index ef991547a..9edb775bf 100644 --- a/tools/junit/src/main/java/org/teavm/junit/TeaVMTestRunner.java +++ b/tools/junit/src/main/java/org/teavm/junit/TeaVMTestRunner.java @@ -41,7 +41,6 @@ import java.util.Properties; import java.util.Set; import java.util.WeakHashMap; import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.function.BiConsumer; import java.util.function.Consumer; @@ -128,7 +127,6 @@ public class TeaVMTestRunner extends Runner implements Filterable { private File outputDir; private Map descriptions = new HashMap<>(); private static Map runners = new HashMap<>(); - private static ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1); private CountDownLatch latch; private List filteredChildren; private ReferenceCache referenceCache = new ReferenceCache(); @@ -1046,14 +1044,6 @@ public class TeaVMTestRunner extends Runner implements Filterable { } } - private static void cleanupRunner(RunKind kind) { - synchronized (TeaVMTestRunner.class) { - RunnerKindInfo info = runners.get(kind); - info.runner.stop(); - info.runner = null; - } - } - private File getOutputPath(Method method) { File path = outputDir; path = new File(path, testClass.getName().replace('.', '/'));