mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-12-18 08:30:18 +00:00
Added KickAss assembly to Test
This commit is contained in:
parent
5986b1d879
commit
0d6ce93e93
2
pom.xml
2
pom.xml
@ -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>
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user