Fix running tests for C backend

This commit is contained in:
Alexey Andreev 2023-10-02 08:30:24 +02:00
parent f6a858520b
commit 8fb6087bf0
5 changed files with 17 additions and 23 deletions

View File

@ -63,6 +63,6 @@ abstract class BaseWebAssemblyPlatformSupport extends TestPlatformSupport<WasmTa
return target;
};
return compile(configuration, targetSupplier, TestNativeEntryPoint.class.getName(), path,
".wasm", null, false, additionalProcessing, baseName);
".wasm", null, additionalProcessing, baseName);
}
}

View File

@ -84,8 +84,8 @@ class CPlatformSupport extends TestPlatformSupport<CTarget> {
throw new RuntimeException(e);
}
};
return compile(configuration, this::createCTarget, TestNativeEntryPoint.class.getName(), path, ".c",
postBuild, true, additionalProcessing, baseName);
return compile(configuration, this::createCTarget, TestNativeEntryPoint.class.getName(), path, "",
postBuild, additionalProcessing, baseName);
}
private CTarget createCTarget() {

View File

@ -41,8 +41,9 @@ class CRunStrategy implements TestRunStrategy {
exeName += ".exe";
}
File outputFile = new File(run.getBaseDirectory(), exeName);
boolean compilerSuccess = compile(run.getBaseDirectory());
var sourcesDir = new File(run.getBaseDirectory(), run.getFileName());
var outputFile = new File(sourcesDir, exeName);
var compilerSuccess = compile(sourcesDir);
if (!compilerSuccess) {
throw new RuntimeException("C compiler error");
}

View File

@ -133,7 +133,7 @@ class JSPlatformSupport extends TestPlatformSupport<JavaScriptTarget> {
};
}
return compile(configuration, targetSupplier, TestJsEntryPoint.class.getName(), path, ".js",
postBuild, false, additionalProcessing, baseName);
postBuild, additionalProcessing, baseName);
}
@Override

View File

@ -60,11 +60,10 @@ abstract class TestPlatformSupport<T extends TeaVMTarget> {
CompileResult compile(TeaVMTestConfiguration<T> configuration,
Supplier<T> targetSupplier, String entryPoint, File path, String extension,
CompilePostProcessor postBuild, boolean separateDir,
Consumer<TeaVM> additionalProcessing, String baseName) {
CompilePostProcessor postBuild, Consumer<TeaVM> additionalProcessing, String baseName) {
CompileResult result = new CompileResult();
File outputFile = getOutputFile(path, baseName, configuration.getSuffix(), separateDir, extension);
File outputFile = getOutputFile(path, baseName, configuration.getSuffix(), extension);
result.file = outputFile;
ClassLoader classLoader = TeaVMTestRunner.class.getClassLoader();
@ -112,21 +111,15 @@ abstract class TestPlatformSupport<T extends TeaVMTarget> {
}
}
private File getOutputFile(File path, String baseName, String suffix, boolean separateDir, String extension) {
private File getOutputFile(File path, String baseName, String suffix, String extension) {
StringBuilder simpleName = new StringBuilder();
simpleName.append(baseName);
if (!suffix.isEmpty()) {
if (!separateDir) {
simpleName.append('-').append(suffix);
}
}
File outputFile;
if (separateDir) {
outputFile = new File(new File(path, simpleName.toString()), "test" + extension);
} else {
simpleName.append(extension);
outputFile = new File(path, simpleName.toString());
}
return outputFile;
}
@ -155,8 +148,8 @@ abstract class TestPlatformSupport<T extends TeaVMTarget> {
protected final void htmlOutput(File outputPath, File outputPathForMethod, TeaVMTestConfiguration<?> configuration,
MethodReference reference, String template) {
var testPath = getOutputFile(outputPath, "classTest", configuration.getSuffix(), false, getExtension());
var htmlPath = getOutputFile(outputPathForMethod, "test", configuration.getSuffix(), false, ".html");
var testPath = getOutputFile(outputPath, "classTest", configuration.getSuffix(), getExtension());
var htmlPath = getOutputFile(outputPathForMethod, "test", configuration.getSuffix(), ".html");
var properties = Map.of(
"SCRIPT", "../" + testPath.getName(),
"IDENTIFIER", reference.toString()
@ -170,8 +163,8 @@ abstract class TestPlatformSupport<T extends TeaVMTarget> {
protected final void htmlSingleTestOutput(File outputPathForMethod, TeaVMTestConfiguration<?> configuration,
String template) {
File testPath = getOutputFile(outputPathForMethod, "test", configuration.getSuffix(), false, ".wasm");
File htmlPath = getOutputFile(outputPathForMethod, "test", configuration.getSuffix(), false, ".html");
File testPath = getOutputFile(outputPathForMethod, "test", configuration.getSuffix(), ".wasm");
File htmlPath = getOutputFile(outputPathForMethod, "test", configuration.getSuffix(), ".html");
var properties = Map.of(
"SCRIPT", testPath.getName(),
"IDENTIFIER", ""