2024-09-08 14:03:57 +00:00
|
|
|
package prog8tests.compiler
|
2021-08-01 08:11:29 +00:00
|
|
|
|
2021-11-07 23:16:58 +00:00
|
|
|
import io.kotest.core.spec.style.FunSpec
|
2022-03-07 20:41:12 +00:00
|
|
|
import io.kotest.matchers.shouldNotBe
|
2022-03-11 19:35:25 +00:00
|
|
|
import prog8.code.target.Cx16Target
|
2021-11-30 00:40:21 +00:00
|
|
|
import prog8.compiler.CompilationResult
|
|
|
|
import prog8.compiler.CompilerArguments
|
2021-10-10 22:22:04 +00:00
|
|
|
import prog8.compiler.compileProgram
|
2022-06-26 16:51:03 +00:00
|
|
|
import prog8tests.helpers.assumeReadableFile
|
|
|
|
import prog8tests.helpers.fixturesDir
|
|
|
|
import prog8tests.helpers.outputDir
|
|
|
|
import prog8tests.helpers.workingDir
|
2021-08-01 08:11:29 +00:00
|
|
|
import java.nio.file.Path
|
2021-10-10 22:22:04 +00:00
|
|
|
import kotlin.io.path.absolute
|
2021-08-01 08:11:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ATTENTION: this is just kludge!
|
|
|
|
* They are not really unit tests, but rather tests of the whole process,
|
|
|
|
* from source file loading all the way through to running 64tass.
|
|
|
|
*/
|
2021-11-07 23:16:58 +00:00
|
|
|
class TestCompilerOptionSourcedirs: FunSpec({
|
2021-08-01 08:11:29 +00:00
|
|
|
|
2022-03-07 20:41:12 +00:00
|
|
|
fun compileFile(filePath: Path, sourceDirs: List<String>): CompilationResult? {
|
2021-11-30 00:40:21 +00:00
|
|
|
val args = CompilerArguments(
|
2021-08-01 08:11:29 +00:00
|
|
|
filepath = filePath,
|
|
|
|
optimize = false,
|
|
|
|
writeAssembly = true,
|
2023-07-30 15:10:54 +00:00
|
|
|
warnSymbolShadowing = false,
|
2021-10-30 13:26:40 +00:00
|
|
|
quietAssembler = true,
|
2021-12-30 13:38:40 +00:00
|
|
|
asmListfile = false,
|
2023-08-02 19:26:40 +00:00
|
|
|
includeSourcelines = false,
|
2022-02-05 20:25:19 +00:00
|
|
|
experimentalCodegen = false,
|
2024-02-10 17:42:31 +00:00
|
|
|
dumpVariables = false,
|
2024-04-09 16:30:56 +00:00
|
|
|
dumpSymbols = false,
|
2023-06-26 22:27:34 +00:00
|
|
|
varsHighBank = null,
|
2023-12-23 19:11:50 +00:00
|
|
|
varsGolden = false,
|
2023-12-23 19:45:30 +00:00
|
|
|
slabsHighBank = null,
|
|
|
|
slabsGolden = false,
|
2022-02-06 20:29:06 +00:00
|
|
|
compilationTarget = Cx16Target.NAME,
|
2023-05-30 17:08:34 +00:00
|
|
|
splitWordArrays = false,
|
2024-01-22 20:07:51 +00:00
|
|
|
breakpointCpuInstruction = null,
|
2024-01-01 21:48:19 +00:00
|
|
|
printAst1 = false,
|
|
|
|
printAst2 = false,
|
2022-07-06 21:40:36 +00:00
|
|
|
symbolDefs = emptyMap(),
|
2021-10-13 16:16:51 +00:00
|
|
|
sourceDirs,
|
2022-06-26 16:51:03 +00:00
|
|
|
outputDir
|
2021-08-01 08:11:29 +00:00
|
|
|
)
|
2021-11-30 00:40:21 +00:00
|
|
|
return compileProgram(args)
|
|
|
|
}
|
2021-08-01 08:11:29 +00:00
|
|
|
|
2021-11-07 23:16:58 +00:00
|
|
|
test("testAbsoluteFilePathOutsideWorkingDir") {
|
2022-06-26 16:51:03 +00:00
|
|
|
val filepath = assumeReadableFile(fixturesDir, "ast_simple_main.p8")
|
2022-03-07 20:41:12 +00:00
|
|
|
compileFile(filepath.absolute(), listOf()) shouldNotBe null
|
2021-08-01 08:11:29 +00:00
|
|
|
}
|
|
|
|
|
2021-11-07 23:16:58 +00:00
|
|
|
test("testFilePathOutsideWorkingDirRelativeToWorkingDir") {
|
2022-06-26 16:51:03 +00:00
|
|
|
val filepath = workingDir.relativize(assumeReadableFile(fixturesDir, "ast_simple_main.p8").absolute())
|
2022-03-07 20:41:12 +00:00
|
|
|
compileFile(filepath, listOf()) shouldNotBe null
|
2021-08-01 08:11:29 +00:00
|
|
|
}
|
|
|
|
|
2021-11-07 23:16:58 +00:00
|
|
|
test("testFilePathOutsideWorkingDirRelativeTo1stInSourcedirs") {
|
2022-06-26 16:51:03 +00:00
|
|
|
val filepath = assumeReadableFile(fixturesDir, "ast_simple_main.p8")
|
2022-10-31 22:59:33 +00:00
|
|
|
val sourcedirs = listOf("$fixturesDir")
|
2022-03-07 20:41:12 +00:00
|
|
|
compileFile(filepath.fileName, sourcedirs) shouldNotBe null
|
2021-08-01 08:11:29 +00:00
|
|
|
}
|
|
|
|
|
2021-11-07 23:16:58 +00:00
|
|
|
})
|