Skip to content

Commit

Permalink
wasm gc: support running tests in gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
konsoletyper committed Oct 22, 2024
1 parent ce862b9 commit 5c743bc
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 4 deletions.
20 changes: 19 additions & 1 deletion tools/gradle/src/main/java/org/teavm/gradle/TeaVMTestsImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
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
Expand Down Expand Up @@ -61,8 +63,24 @@ public void wasm(Closure<?> config) {
config.rehydrate(getWasm(), config.getOwner(), config.getThisObject()).call();
}

@Override
public TeaVMWasmTests getWasmGC() {
return wasmGC;
}

@Override
public void wasmGC(Action<TeaVMWasmTests> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
class TeaVMWasmTestsImpl implements TeaVMWasmTests {
private Property<Boolean> enabled;
private Property<TeaVMWebTestRunner> 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
Expand All @@ -40,8 +42,9 @@ public Property<TeaVMWebTestRunner> getRunner() {
}

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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,10 @@ public interface TeaVMTests {
void wasm(Action<TeaVMWasmTests> config);

void wasm(@DelegatesTo(TeaVMWasmTests.class) Closure<?> config);

TeaVMWasmTests getWasmGC();

void wasmGC(Action<TeaVMWasmTests> config);

void wasmGC(@DelegatesTo(TeaVMWasmTests.class) Closure<?> config);
}
Original file line number Diff line number Diff line change
@@ -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<Boolean> getEnabled();

Property<TeaVMWebTestRunner> getRunner();
}

0 comments on commit 5c743bc

Please sign in to comment.