From 5c743bc9a412e110024415550cc9a8271da36e31 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Tue, 22 Oct 2024 18:01:30 +0200 Subject: [PATCH] wasm gc: support running tests in gradle --- .../java/org/teavm/gradle/TeaVMTestsImpl.java | 20 +++++++++++++++- .../org/teavm/gradle/TeaVMWasmTestsImpl.java | 9 ++++--- .../java/org/teavm/gradle/api/TeaVMTests.java | 6 +++++ .../teavm/gradle/api/TeaVMWasmGCTests.java | 24 +++++++++++++++++++ 4 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWasmGCTests.java diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMTestsImpl.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMTestsImpl.java index 7bd3ea6d1..361409501 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMTestsImpl.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMTestsImpl.java @@ -25,10 +25,12 @@ import org.teavm.gradle.api.TeaVMWasmTests; class TeaVMTestsImpl implements TeaVMTests { private TeaVMJSTestsImpl js; private TeaVMWasmTestsImpl wasm; + private TeaVMWasmTestsImpl wasmGC; TeaVMTestsImpl(ObjectFactory objectFactory) { js = new TeaVMJSTestsImpl(objectFactory); - wasm = new TeaVMWasmTestsImpl(objectFactory); + wasm = new TeaVMWasmTestsImpl(objectFactory, "wasm"); + wasmGC = new TeaVMWasmTestsImpl(objectFactory, "wasm-gc"); } @Override @@ -61,8 +63,24 @@ class TeaVMTestsImpl implements TeaVMTests { config.rehydrate(getWasm(), config.getOwner(), config.getThisObject()).call(); } + @Override + public TeaVMWasmTests getWasmGC() { + return wasmGC; + } + + @Override + public void wasmGC(Action config) { + config.execute(wasmGC); + } + + @Override + public void wasmGC(Closure config) { + config.rehydrate(getWasmGC(), config.getOwner(), config.getThisObject()).call(); + } + void configure(TeaVMBaseExtensionImpl extension) { js.configure(extension); wasm.configure(extension); + wasmGC.configure(extension); } } diff --git a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasmTestsImpl.java b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasmTestsImpl.java index a8134bff3..7b57c2693 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasmTestsImpl.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/TeaVMWasmTestsImpl.java @@ -23,10 +23,12 @@ import org.teavm.gradle.api.TeaVMWebTestRunner; class TeaVMWasmTestsImpl implements TeaVMWasmTests { private Property enabled; private Property runner; + private String name; - TeaVMWasmTestsImpl(ObjectFactory objectFactory) { + TeaVMWasmTestsImpl(ObjectFactory objectFactory, String name) { enabled = objectFactory.property(Boolean.class); runner = objectFactory.property(TeaVMWebTestRunner.class); + this.name = name; } @Override @@ -40,8 +42,9 @@ class TeaVMWasmTestsImpl implements TeaVMWasmTests { } void configure(TeaVMBaseExtensionImpl extension) { - enabled.convention(extension.property("tests.wasm.enabled").map(Boolean::parseBoolean).orElse(false)); - runner.convention(extension.property("tests.wasm.runner").map(s -> TeaVMWebTestRunner.valueOf(s.toUpperCase())) + enabled.convention(extension.property("tests." + name + ".enabled").map(Boolean::parseBoolean).orElse(false)); + runner.convention(extension.property("tests." + name + ".runner") + .map(s -> TeaVMWebTestRunner.valueOf(s.toUpperCase())) .orElse(TeaVMWebTestRunner.CHROME)); } } diff --git a/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMTests.java b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMTests.java index 003c160b8..bc3e3b02f 100644 --- a/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMTests.java +++ b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMTests.java @@ -31,4 +31,10 @@ public interface TeaVMTests { void wasm(Action config); void wasm(@DelegatesTo(TeaVMWasmTests.class) Closure config); + + TeaVMWasmTests getWasmGC(); + + void wasmGC(Action config); + + void wasmGC(@DelegatesTo(TeaVMWasmTests.class) Closure config); } diff --git a/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWasmGCTests.java b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWasmGCTests.java new file mode 100644 index 000000000..ac950d402 --- /dev/null +++ b/tools/gradle/src/main/java/org/teavm/gradle/api/TeaVMWasmGCTests.java @@ -0,0 +1,24 @@ +/* + * Copyright 2023 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.teavm.gradle.api; + +import org.gradle.api.provider.Property; + +public interface TeaVMWasmGCTests { + Property getEnabled(); + + Property getRunner(); +}