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,8 +60,6 @@ tasks.test {
systemProperty("teavm.junit.c.compiler", providers.gradleProperty("teavm.tests.c.compiler")
.orElse("compile-c-unix-fast.sh").get())
jvmArgumentProviders += object : CommandLineArgumentProvider {
override fun asArguments(): Iterable<String> {
val dependencies = configurations.testRuntimeClasspath.get()
.incoming.resolutionResult.allDependencies
.asSequence()
@ -76,12 +74,9 @@ tasks.test {
it.dir("src/test/java")
)
}
val result = dirs
systemProperty("teavm.junit.sourceDirs", dirs
.map { it.asFile.absolutePath }
.joinToString(File.pathSeparator)
return listOf("-Dteavm.junit.sourceDirs=$result")
}
}
.joinToString(File.pathSeparator))
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -78,7 +78,9 @@ import java.util.Arrays;
import java.util.List;
import org.junit.runner.RunWith;
import org.teavm.classlib.java.time.AbstractDateTimeTest;
import org.teavm.junit.SkipPlatform;
import org.teavm.junit.TeaVMTestRunner;
import org.teavm.junit.TestPlatform;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@ -708,6 +710,7 @@ public class TestYear extends AbstractDateTimeTest {
}
@Test(expectedExceptions = NullPointerException.class)
@SkipPlatform(TestPlatform.C)
public void test_compareTo_nullYear() {
Year doy = null;
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,
".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")));
return cTarget;
}
@Override
boolean usesFileName() {
return false;
}
}

View File

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