From 997a31b683763cc641f965dc290dec17f05b9809 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Thu, 23 Nov 2023 16:04:32 +0100 Subject: [PATCH] junit: don't start browser if corresponding test platforms disabled --- .../org/teavm/junit/CPlatformSupport.java | 13 ++++++++----- .../org/teavm/junit/JSPlatformSupport.java | 19 +++++++++++-------- .../java/org/teavm/junit/PropertyNames.java | 1 - .../java/org/teavm/junit/TeaVMTestRunner.java | 13 +++++++------ .../org/teavm/junit/TestPlatformSupport.java | 2 ++ .../org/teavm/junit/WasiPlatformSupport.java | 13 ++++++++----- .../junit/WebAssemblyPlatformSupport.java | 13 ++++++++----- 7 files changed, 44 insertions(+), 30 deletions(-) diff --git a/tools/junit/src/main/java/org/teavm/junit/CPlatformSupport.java b/tools/junit/src/main/java/org/teavm/junit/CPlatformSupport.java index 6c4063e2a..9f18a5131 100644 --- a/tools/junit/src/main/java/org/teavm/junit/CPlatformSupport.java +++ b/tools/junit/src/main/java/org/teavm/junit/CPlatformSupport.java @@ -61,14 +61,17 @@ class CPlatformSupport extends TestPlatformSupport { return ""; } + @Override + boolean isEnabled() { + return Boolean.getBoolean(C_ENABLED); + } + @Override List> getConfigurations() { List> configurations = new ArrayList<>(); - if (Boolean.getBoolean(C_ENABLED)) { - configurations.add(TeaVMTestConfiguration.C_DEFAULT); - if (Boolean.getBoolean(OPTIMIZED)) { - configurations.add(TeaVMTestConfiguration.C_OPTIMIZED); - } + configurations.add(TeaVMTestConfiguration.C_DEFAULT); + if (Boolean.getBoolean(OPTIMIZED)) { + configurations.add(TeaVMTestConfiguration.C_OPTIMIZED); } return configurations; } diff --git a/tools/junit/src/main/java/org/teavm/junit/JSPlatformSupport.java b/tools/junit/src/main/java/org/teavm/junit/JSPlatformSupport.java index bb7797205..8479aa84f 100644 --- a/tools/junit/src/main/java/org/teavm/junit/JSPlatformSupport.java +++ b/tools/junit/src/main/java/org/teavm/junit/JSPlatformSupport.java @@ -79,17 +79,20 @@ class JSPlatformSupport extends TestPlatformSupport { return ".js"; } + @Override + boolean isEnabled() { + return Boolean.parseBoolean(System.getProperty(JS_ENABLED, "true")); + } + @Override List> getConfigurations() { List> configurations = new ArrayList<>(); - if (Boolean.parseBoolean(System.getProperty(JS_ENABLED, "true"))) { - configurations.add(TeaVMTestConfiguration.JS_DEFAULT); - if (Boolean.getBoolean(MINIFIED)) { - configurations.add(TeaVMTestConfiguration.JS_MINIFIED); - } - if (Boolean.getBoolean(OPTIMIZED)) { - configurations.add(TeaVMTestConfiguration.JS_OPTIMIZED); - } + configurations.add(TeaVMTestConfiguration.JS_DEFAULT); + if (Boolean.getBoolean(MINIFIED)) { + configurations.add(TeaVMTestConfiguration.JS_MINIFIED); + } + if (Boolean.getBoolean(OPTIMIZED)) { + configurations.add(TeaVMTestConfiguration.JS_OPTIMIZED); } return configurations; } diff --git a/tools/junit/src/main/java/org/teavm/junit/PropertyNames.java b/tools/junit/src/main/java/org/teavm/junit/PropertyNames.java index 8824743b4..890573caf 100644 --- a/tools/junit/src/main/java/org/teavm/junit/PropertyNames.java +++ b/tools/junit/src/main/java/org/teavm/junit/PropertyNames.java @@ -19,7 +19,6 @@ final class PropertyNames { static final String PATH_PARAM = "teavm.junit.target"; static final String JS_RUNNER = "teavm.junit.js.runner"; static final String WASM_RUNNER = "teavm.junit.wasm.runner"; - static final String THREAD_COUNT = "teavm.junit.threads"; static final String JS_ENABLED = "teavm.junit.js"; static final String JS_DECODE_STACK = "teavm.junit.js.decodeStack"; static final String C_ENABLED = "teavm.junit.c"; 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 8f653f1d1..c354290f9 100644 --- a/tools/junit/src/main/java/org/teavm/junit/TeaVMTestRunner.java +++ b/tools/junit/src/main/java/org/teavm/junit/TeaVMTestRunner.java @@ -110,9 +110,11 @@ public class TeaVMTestRunner extends Runner implements Filterable { platforms.add(new CPlatformSupport(classSource, referenceCache)); for (var platform : platforms) { - var runStrategy = platform.createRunStrategy(outputDir); - if (runStrategy != null) { - runners.put(platform.getPlatform(), runStrategy); + if (platform.isEnabled()) { + var runStrategy = platform.createRunStrategy(outputDir); + if (runStrategy != null) { + runners.put(platform.getPlatform(), runStrategy); + } } } @@ -734,15 +736,14 @@ public class TeaVMTestRunner extends Runner implements Filterable { return new Failure(description, throwable); } - private boolean submitRun(TestRun run) throws IOException { + private void submitRun(TestRun run) throws IOException { runsInCurrentClass.add(run); var strategy = runners.get(run.getKind()); if (strategy == null) { - return false; + return; } strategy.runTest(run); - return true; } private File getOutputPath(Method method, TestPlatformSupport platform) { diff --git a/tools/junit/src/main/java/org/teavm/junit/TestPlatformSupport.java b/tools/junit/src/main/java/org/teavm/junit/TestPlatformSupport.java index 536432a18..132f00156 100644 --- a/tools/junit/src/main/java/org/teavm/junit/TestPlatformSupport.java +++ b/tools/junit/src/main/java/org/teavm/junit/TestPlatformSupport.java @@ -45,6 +45,8 @@ abstract class TestPlatformSupport { this.referenceCache = referenceCache; } + abstract boolean isEnabled(); + abstract TestRunStrategy createRunStrategy(File outputDir); abstract TestPlatform getPlatform(); diff --git a/tools/junit/src/main/java/org/teavm/junit/WasiPlatformSupport.java b/tools/junit/src/main/java/org/teavm/junit/WasiPlatformSupport.java index f52b3a1fd..582a431c5 100644 --- a/tools/junit/src/main/java/org/teavm/junit/WasiPlatformSupport.java +++ b/tools/junit/src/main/java/org/teavm/junit/WasiPlatformSupport.java @@ -55,14 +55,17 @@ class WasiPlatformSupport extends BaseWebAssemblyPlatformSupport { return "wasi"; } + @Override + boolean isEnabled() { + return Boolean.getBoolean(WASI_ENABLED); + } + @Override List> getConfigurations() { List> configurations = new ArrayList<>(); - if (Boolean.getBoolean(WASI_ENABLED)) { - configurations.add(TeaVMTestConfiguration.WASM_DEFAULT); - if (Boolean.getBoolean(OPTIMIZED)) { - configurations.add(TeaVMTestConfiguration.WASM_OPTIMIZED); - } + configurations.add(TeaVMTestConfiguration.WASM_DEFAULT); + if (Boolean.getBoolean(OPTIMIZED)) { + configurations.add(TeaVMTestConfiguration.WASM_OPTIMIZED); } return configurations; } diff --git a/tools/junit/src/main/java/org/teavm/junit/WebAssemblyPlatformSupport.java b/tools/junit/src/main/java/org/teavm/junit/WebAssemblyPlatformSupport.java index c042234fa..bca1b51d5 100644 --- a/tools/junit/src/main/java/org/teavm/junit/WebAssemblyPlatformSupport.java +++ b/tools/junit/src/main/java/org/teavm/junit/WebAssemblyPlatformSupport.java @@ -61,14 +61,17 @@ class WebAssemblyPlatformSupport extends BaseWebAssemblyPlatformSupport { return "wasm"; } + @Override + boolean isEnabled() { + return Boolean.getBoolean(WASM_ENABLED); + } + @Override List> getConfigurations() { List> configurations = new ArrayList<>(); - if (Boolean.getBoolean(WASM_ENABLED)) { - configurations.add(TeaVMTestConfiguration.WASM_DEFAULT); - if (Boolean.getBoolean(OPTIMIZED)) { - configurations.add(TeaVMTestConfiguration.WASM_OPTIMIZED); - } + configurations.add(TeaVMTestConfiguration.WASM_DEFAULT); + if (Boolean.getBoolean(OPTIMIZED)) { + configurations.add(TeaVMTestConfiguration.WASM_OPTIMIZED); } return configurations; }