1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-10-10 20:23:47 +00:00

Added KickAss assembly to Test

This commit is contained in:
jespergravgaard 2018-02-12 23:41:46 +01:00
parent 5986b1d879
commit 0d6ce93e93
4 changed files with 26 additions and 5 deletions

View File

@ -2,5 +2,5 @@ image: maven:3-jdk-8
maven_build:
script:
-"mvn verify"
-"cat target/site/jacoco/index.html"
- "mvn verify"
- "cat target/site/jacoco/index.html"

View File

@ -7,6 +7,7 @@
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<argLine> -Xmx2048m</argLine>
</properties>
<repositories>
@ -68,7 +69,6 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<argLine>@{argLine} -Xmx2048m</argLine>
</configuration>
</plugin>
<plugin>

View File

@ -30,6 +30,10 @@ public class ReferenceHelper {
this.refPath = refPath;
}
public static Path getTempDir() {
return tempDir;
}
public boolean testOutput(
String fileName,
String extension,
@ -89,16 +93,20 @@ public class ReferenceHelper {
return Files.readAllLines(Paths.get(refURI), Charset.defaultCharset());
}
private void writeOutputFile(String fileName, String extension, String outputString) throws IOException {
public File writeOutputFile(String fileName, String extension, String outputString) throws IOException {
// Write output file
File file = new File(tempDir.toFile(), fileName + extension);
File file = getTmpFile(fileName, extension);
FileOutputStream outputStream = new FileOutputStream(file);
OutputStreamWriter writer = new OutputStreamWriter(outputStream);
writer.write(outputString);
writer.close();
outputStream.close();
System.out.println("Output written to " + file.getAbsolutePath());
return file;
}
public File getTmpFile(String fileName, String extension) {
return new File(tempDir.toFile(), fileName + extension);
}
}

View File

@ -7,10 +7,12 @@ import dk.camelot64.kickc.fragment.AsmFragmentTemplateSynthesizer;
import dk.camelot64.kickc.fragment.AsmFragmentTemplateUsages;
import dk.camelot64.kickc.model.CompileError;
import dk.camelot64.kickc.model.Program;
import kickass.KickAssembler;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
@ -551,6 +553,17 @@ public class TestPrograms {
Compiler compiler = new Compiler();
compiler.addImportPath(testPath);
Program program = compiler.compile(fileName);
helper.writeOutputFile(fileName, ".asm", program.getAsm().toString(false));
File asmFile = helper.getTmpFile(fileName, ".asm");
File asmPrgFile = helper.getTmpFile(fileName, ".prg");
File asmLogFile = helper.getTmpFile(fileName, ".klog");
int asmRes = KickAssembler.main2(new String[]{asmFile.getAbsolutePath(), "-log", asmLogFile.getAbsolutePath(), "-o", asmPrgFile.getAbsolutePath(), "-vicesymbols", "-showmem"});
if(asmRes!=0) {
fail("KickAssembling file failed!");
}
boolean success = true;
success &= helper.testOutput(fileName, ".asm", program.getAsm().toString(false));
success &= helper.testOutput(fileName, ".sym", program.getScope().getSymbolTableContents(program));