junit: don't start browser if corresponding test platforms disabled

This commit is contained in:
Alexey Andreev 2023-11-23 16:04:32 +01:00
parent ef359c3604
commit 997a31b683
7 changed files with 44 additions and 30 deletions

View File

@ -61,14 +61,17 @@ class CPlatformSupport extends TestPlatformSupport<CTarget> {
return ""; return "";
} }
@Override
boolean isEnabled() {
return Boolean.getBoolean(C_ENABLED);
}
@Override @Override
List<TeaVMTestConfiguration<CTarget>> getConfigurations() { List<TeaVMTestConfiguration<CTarget>> getConfigurations() {
List<TeaVMTestConfiguration<CTarget>> configurations = new ArrayList<>(); List<TeaVMTestConfiguration<CTarget>> configurations = new ArrayList<>();
if (Boolean.getBoolean(C_ENABLED)) { configurations.add(TeaVMTestConfiguration.C_DEFAULT);
configurations.add(TeaVMTestConfiguration.C_DEFAULT); if (Boolean.getBoolean(OPTIMIZED)) {
if (Boolean.getBoolean(OPTIMIZED)) { configurations.add(TeaVMTestConfiguration.C_OPTIMIZED);
configurations.add(TeaVMTestConfiguration.C_OPTIMIZED);
}
} }
return configurations; return configurations;
} }

View File

@ -79,17 +79,20 @@ class JSPlatformSupport extends TestPlatformSupport<JavaScriptTarget> {
return ".js"; return ".js";
} }
@Override
boolean isEnabled() {
return Boolean.parseBoolean(System.getProperty(JS_ENABLED, "true"));
}
@Override @Override
List<TeaVMTestConfiguration<JavaScriptTarget>> getConfigurations() { List<TeaVMTestConfiguration<JavaScriptTarget>> getConfigurations() {
List<TeaVMTestConfiguration<JavaScriptTarget>> configurations = new ArrayList<>(); List<TeaVMTestConfiguration<JavaScriptTarget>> configurations = new ArrayList<>();
if (Boolean.parseBoolean(System.getProperty(JS_ENABLED, "true"))) { configurations.add(TeaVMTestConfiguration.JS_DEFAULT);
configurations.add(TeaVMTestConfiguration.JS_DEFAULT); if (Boolean.getBoolean(MINIFIED)) {
if (Boolean.getBoolean(MINIFIED)) { configurations.add(TeaVMTestConfiguration.JS_MINIFIED);
configurations.add(TeaVMTestConfiguration.JS_MINIFIED); }
} if (Boolean.getBoolean(OPTIMIZED)) {
if (Boolean.getBoolean(OPTIMIZED)) { configurations.add(TeaVMTestConfiguration.JS_OPTIMIZED);
configurations.add(TeaVMTestConfiguration.JS_OPTIMIZED);
}
} }
return configurations; return configurations;
} }

View File

@ -19,7 +19,6 @@ final class PropertyNames {
static final String PATH_PARAM = "teavm.junit.target"; static final String PATH_PARAM = "teavm.junit.target";
static final String JS_RUNNER = "teavm.junit.js.runner"; static final String JS_RUNNER = "teavm.junit.js.runner";
static final String WASM_RUNNER = "teavm.junit.wasm.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_ENABLED = "teavm.junit.js";
static final String JS_DECODE_STACK = "teavm.junit.js.decodeStack"; static final String JS_DECODE_STACK = "teavm.junit.js.decodeStack";
static final String C_ENABLED = "teavm.junit.c"; static final String C_ENABLED = "teavm.junit.c";

View File

@ -110,9 +110,11 @@ public class TeaVMTestRunner extends Runner implements Filterable {
platforms.add(new CPlatformSupport(classSource, referenceCache)); platforms.add(new CPlatformSupport(classSource, referenceCache));
for (var platform : platforms) { for (var platform : platforms) {
var runStrategy = platform.createRunStrategy(outputDir); if (platform.isEnabled()) {
if (runStrategy != null) { var runStrategy = platform.createRunStrategy(outputDir);
runners.put(platform.getPlatform(), runStrategy); if (runStrategy != null) {
runners.put(platform.getPlatform(), runStrategy);
}
} }
} }
@ -734,15 +736,14 @@ public class TeaVMTestRunner extends Runner implements Filterable {
return new Failure(description, throwable); return new Failure(description, throwable);
} }
private boolean submitRun(TestRun run) throws IOException { private void submitRun(TestRun run) throws IOException {
runsInCurrentClass.add(run); runsInCurrentClass.add(run);
var strategy = runners.get(run.getKind()); var strategy = runners.get(run.getKind());
if (strategy == null) { if (strategy == null) {
return false; return;
} }
strategy.runTest(run); strategy.runTest(run);
return true;
} }
private File getOutputPath(Method method, TestPlatformSupport<?> platform) { private File getOutputPath(Method method, TestPlatformSupport<?> platform) {

View File

@ -45,6 +45,8 @@ abstract class TestPlatformSupport<T extends TeaVMTarget> {
this.referenceCache = referenceCache; this.referenceCache = referenceCache;
} }
abstract boolean isEnabled();
abstract TestRunStrategy createRunStrategy(File outputDir); abstract TestRunStrategy createRunStrategy(File outputDir);
abstract TestPlatform getPlatform(); abstract TestPlatform getPlatform();

View File

@ -55,14 +55,17 @@ class WasiPlatformSupport extends BaseWebAssemblyPlatformSupport {
return "wasi"; return "wasi";
} }
@Override
boolean isEnabled() {
return Boolean.getBoolean(WASI_ENABLED);
}
@Override @Override
List<TeaVMTestConfiguration<WasmTarget>> getConfigurations() { List<TeaVMTestConfiguration<WasmTarget>> getConfigurations() {
List<TeaVMTestConfiguration<WasmTarget>> configurations = new ArrayList<>(); List<TeaVMTestConfiguration<WasmTarget>> configurations = new ArrayList<>();
if (Boolean.getBoolean(WASI_ENABLED)) { configurations.add(TeaVMTestConfiguration.WASM_DEFAULT);
configurations.add(TeaVMTestConfiguration.WASM_DEFAULT); if (Boolean.getBoolean(OPTIMIZED)) {
if (Boolean.getBoolean(OPTIMIZED)) { configurations.add(TeaVMTestConfiguration.WASM_OPTIMIZED);
configurations.add(TeaVMTestConfiguration.WASM_OPTIMIZED);
}
} }
return configurations; return configurations;
} }

View File

@ -61,14 +61,17 @@ class WebAssemblyPlatformSupport extends BaseWebAssemblyPlatformSupport {
return "wasm"; return "wasm";
} }
@Override
boolean isEnabled() {
return Boolean.getBoolean(WASM_ENABLED);
}
@Override @Override
List<TeaVMTestConfiguration<WasmTarget>> getConfigurations() { List<TeaVMTestConfiguration<WasmTarget>> getConfigurations() {
List<TeaVMTestConfiguration<WasmTarget>> configurations = new ArrayList<>(); List<TeaVMTestConfiguration<WasmTarget>> configurations = new ArrayList<>();
if (Boolean.getBoolean(WASM_ENABLED)) { configurations.add(TeaVMTestConfiguration.WASM_DEFAULT);
configurations.add(TeaVMTestConfiguration.WASM_DEFAULT); if (Boolean.getBoolean(OPTIMIZED)) {
if (Boolean.getBoolean(OPTIMIZED)) { configurations.add(TeaVMTestConfiguration.WASM_OPTIMIZED);
configurations.add(TeaVMTestConfiguration.WASM_OPTIMIZED);
}
} }
return configurations; return configurations;
} }