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 target;
}; };
return compile(configuration, targetSupplier, TestNativeEntryPoint.class.getName(), path, 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); throw new RuntimeException(e);
} }
}; };
return compile(configuration, this::createCTarget, TestNativeEntryPoint.class.getName(), path, ".c", return compile(configuration, this::createCTarget, TestNativeEntryPoint.class.getName(), path, "",
postBuild, true, additionalProcessing, baseName); postBuild, additionalProcessing, baseName);
} }
private CTarget createCTarget() { private CTarget createCTarget() {

View File

@ -41,8 +41,9 @@ class CRunStrategy implements TestRunStrategy {
exeName += ".exe"; exeName += ".exe";
} }
File outputFile = new File(run.getBaseDirectory(), exeName); var sourcesDir = new File(run.getBaseDirectory(), run.getFileName());
boolean compilerSuccess = compile(run.getBaseDirectory()); var outputFile = new File(sourcesDir, exeName);
var compilerSuccess = compile(sourcesDir);
if (!compilerSuccess) { if (!compilerSuccess) {
throw new RuntimeException("C compiler error"); 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", return compile(configuration, targetSupplier, TestJsEntryPoint.class.getName(), path, ".js",
postBuild, false, additionalProcessing, baseName); postBuild, additionalProcessing, baseName);
} }
@Override @Override

View File

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