Fix running C tests

This commit is contained in:
Alexey Andreev 2023-10-06 10:55:08 +02:00
parent 360e218c0c
commit 0c0fb1a02b
11 changed files with 56 additions and 23 deletions

View File

@ -60,28 +60,23 @@ tasks.test {
systemProperty("teavm.junit.c.compiler", providers.gradleProperty("teavm.tests.c.compiler") systemProperty("teavm.junit.c.compiler", providers.gradleProperty("teavm.tests.c.compiler")
.orElse("compile-c-unix-fast.sh").get()) .orElse("compile-c-unix-fast.sh").get())
jvmArgumentProviders += object : CommandLineArgumentProvider { val dependencies = configurations.testRuntimeClasspath.get()
override fun asArguments(): Iterable<String> { .incoming.resolutionResult.allDependencies
val dependencies = configurations.testRuntimeClasspath.get() .asSequence()
.incoming.resolutionResult.allDependencies .filterIsInstance<ResolvedDependencyResult>()
.asSequence() .map { it.requested }
.filterIsInstance<ResolvedDependencyResult>() .filterIsInstance<ProjectComponentSelector>()
.map { it.requested } .map { project.rootProject.project(it.projectPath) }
.filterIsInstance<ProjectComponentSelector>() val projects = dependencies + project
.map { project.rootProject.project(it.projectPath) } val dirs = projects.map { it.layout.projectDirectory }.flatMap {
val projects = dependencies + project sequenceOf(
val dirs = projects.map { it.layout.projectDirectory }.flatMap { it.dir("src/main/java"),
sequenceOf( it.dir("src/test/java")
it.dir("src/main/java"), )
it.dir("src/test/java")
)
}
val result = dirs
.map { it.asFile.absolutePath }
.joinToString(File.pathSeparator)
return listOf("-Dteavm.junit.sourceDirs=$result")
}
} }
systemProperty("teavm.junit.sourceDirs", dirs
.map { it.asFile.absolutePath }
.joinToString(File.pathSeparator))
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
} }

View File

@ -375,6 +375,7 @@ public class PipedInputStreamTest {
} }
@Test @Test
@SkipPlatform(TestPlatform.C)
public void read_after_write_close() throws Exception { public void read_after_write_close() throws Exception {
PipedInputStream in = new PipedInputStream(); PipedInputStream in = new PipedInputStream();
PipedOutputStream out = new PipedOutputStream(); PipedOutputStream out = new PipedOutputStream();

View File

@ -99,7 +99,9 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.teavm.classlib.java.time.temporal.MockFieldNoValue; import org.teavm.classlib.java.time.temporal.MockFieldNoValue;
import org.teavm.junit.SkipPlatform;
import org.teavm.junit.TeaVMTestRunner; import org.teavm.junit.TeaVMTestRunner;
import org.teavm.junit.TestPlatform;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -942,6 +944,7 @@ public class TestLocalDate extends AbstractDateTimeTest {
} }
@Test(expectedExceptions = NullPointerException.class) @Test(expectedExceptions = NullPointerException.class)
@SkipPlatform(TestPlatform.C)
public void test_plus_longPeriodUnit_null() { public void test_plus_longPeriodUnit_null() {
test2007x07x15.plus(1, (TemporalUnit) null); test2007x07x15.plus(1, (TemporalUnit) null);
} }
@ -1302,6 +1305,7 @@ public class TestLocalDate extends AbstractDateTimeTest {
} }
@Test(expectedExceptions = NullPointerException.class) @Test(expectedExceptions = NullPointerException.class)
@SkipPlatform(TestPlatform.C)
public void test_minus_longPeriodUnit_null() { public void test_minus_longPeriodUnit_null() {
test2007x07x15.minus(1, (TemporalUnit) null); test2007x07x15.minus(1, (TemporalUnit) null);
} }

View File

@ -1261,6 +1261,7 @@ public class TestLocalDateTime extends AbstractDateTimeTest {
} }
@Test(expectedExceptions = NullPointerException.class) @Test(expectedExceptions = NullPointerException.class)
@SkipPlatform(TestPlatform.C)
public void test_plus_longPeriodUnit_null() { public void test_plus_longPeriodUnit_null() {
test2007x07x15x12x30x40x987654321.plus(1, null); test2007x07x15x12x30x40x987654321.plus(1, null);
} }
@ -1971,6 +1972,7 @@ public class TestLocalDateTime extends AbstractDateTimeTest {
} }
@Test(expectedExceptions = NullPointerException.class) @Test(expectedExceptions = NullPointerException.class)
@SkipPlatform(TestPlatform.C)
public void test_minus_longPeriodUnit_null() { public void test_minus_longPeriodUnit_null() {
test2007x07x15x12x30x40x987654321.minus(1, null); test2007x07x15x12x30x40x987654321.minus(1, null);
} }

View File

@ -95,7 +95,9 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.teavm.junit.SkipPlatform;
import org.teavm.junit.TeaVMTestRunner; import org.teavm.junit.TeaVMTestRunner;
import org.teavm.junit.TestPlatform;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -666,6 +668,7 @@ public class TestOffsetTime extends AbstractDateTimeTest {
} }
@Test(expectedExceptions = NullPointerException.class) @Test(expectedExceptions = NullPointerException.class)
@SkipPlatform(TestPlatform.C)
public void test_with_TemporalField_null() { public void test_with_TemporalField_null() {
test11x30x59x500pone.with((TemporalField) null, 0); test11x30x59x500pone.with((TemporalField) null, 0);
} }

View File

@ -112,7 +112,9 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.teavm.classlib.java.time.temporal.MockFieldNoValue; import org.teavm.classlib.java.time.temporal.MockFieldNoValue;
import org.teavm.junit.SkipPlatform;
import org.teavm.junit.TeaVMTestRunner; import org.teavm.junit.TeaVMTestRunner;
import org.teavm.junit.TestPlatform;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -1454,6 +1456,7 @@ public class TestZonedDateTime extends AbstractDateTimeTest {
} }
@Test(expectedExceptions = NullPointerException.class) @Test(expectedExceptions = NullPointerException.class)
@SkipPlatform(TestPlatform.C)
public void test_plus_longUnit_null() { public void test_plus_longUnit_null() {
testDateTimeParis.plus(0, null); testDateTimeParis.plus(0, null);
} }

View File

@ -78,7 +78,9 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.teavm.classlib.java.time.AbstractDateTimeTest; import org.teavm.classlib.java.time.AbstractDateTimeTest;
import org.teavm.junit.SkipPlatform;
import org.teavm.junit.TeaVMTestRunner; import org.teavm.junit.TeaVMTestRunner;
import org.teavm.junit.TestPlatform;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -708,6 +710,7 @@ public class TestYear extends AbstractDateTimeTest {
} }
@Test(expectedExceptions = NullPointerException.class) @Test(expectedExceptions = NullPointerException.class)
@SkipPlatform(TestPlatform.C)
public void test_compareTo_nullYear() { public void test_compareTo_nullYear() {
Year doy = null; Year doy = null;
Year test = Year.of(1); Year test = Year.of(1);

View File

@ -65,4 +65,9 @@ abstract class BaseWebAssemblyPlatformSupport extends TestPlatformSupport<WasmTa
return compile(configuration, targetSupplier, TestNativeEntryPoint.class.getName(), path, return compile(configuration, targetSupplier, TestNativeEntryPoint.class.getName(), path,
".wasm", null, additionalProcessing, baseName); ".wasm", null, additionalProcessing, baseName);
} }
@Override
boolean usesFileName() {
return true;
}
} }

View File

@ -93,4 +93,9 @@ class CPlatformSupport extends TestPlatformSupport<CTarget> {
cTarget.setLineNumbersGenerated(Boolean.parseBoolean(System.getProperty(C_LINE_NUMBERS, "false"))); cTarget.setLineNumbersGenerated(Boolean.parseBoolean(System.getProperty(C_LINE_NUMBERS, "false")));
return cTarget; return cTarget;
} }
@Override
boolean usesFileName() {
return false;
}
} }

View File

@ -147,4 +147,9 @@ class JSPlatformSupport extends TestPlatformSupport<JavaScriptTarget> {
MethodReference reference) { MethodReference reference) {
htmlSingleTestOutput(outputPathForMethod, configuration, "teavm-run-test.html"); htmlSingleTestOutput(outputPathForMethod, configuration, "teavm-run-test.html");
} }
@Override
boolean usesFileName() {
return true;
}
} }

View File

@ -58,6 +58,8 @@ abstract class TestPlatformSupport<T extends TeaVMTarget> {
abstract CompileResult compile(Consumer<TeaVM> additionalProcessing, String baseName, abstract CompileResult compile(Consumer<TeaVM> additionalProcessing, String baseName,
TeaVMTestConfiguration<T> configuration, File path); TeaVMTestConfiguration<T> configuration, File path);
abstract boolean usesFileName();
CompileResult compile(TeaVMTestConfiguration<T> configuration, CompileResult compile(TeaVMTestConfiguration<T> configuration,
Supplier<T> targetSupplier, String entryPoint, File path, String extension, Supplier<T> targetSupplier, String entryPoint, File path, String extension,
CompilePostProcessor postBuild, Consumer<TeaVM> additionalProcessing, String baseName) { CompilePostProcessor postBuild, Consumer<TeaVM> additionalProcessing, String baseName) {
@ -89,10 +91,15 @@ abstract class TestPlatformSupport<T extends TeaVMTarget> {
vm.entryPoint(entryPoint); vm.entryPoint(entryPoint);
if (!outputFile.getParentFile().exists()) { if (usesFileName()) {
if (!outputFile.getParentFile().exists()) {
outputFile.getParentFile().mkdirs();
}
vm.build(new DirectoryBuildTarget(outputFile.getParentFile()), outputFile.getName());
} else {
outputFile.getParentFile().mkdirs(); outputFile.getParentFile().mkdirs();
vm.build(new DirectoryBuildTarget(outputFile), "");
} }
vm.build(new DirectoryBuildTarget(outputFile.getParentFile()), outputFile.getName());
if (!vm.getProblemProvider().getProblems().isEmpty()) { if (!vm.getProblemProvider().getProblems().isEmpty()) {
result.success = false; result.success = false;
result.errorMessage = buildErrorMessage(vm); result.errorMessage = buildErrorMessage(vm);