2021-08-01 10:11:29 +02:00
|
|
|
package prog8tests
|
|
|
|
|
2021-11-08 00:16:58 +01:00
|
|
|
import io.kotest.core.spec.style.FunSpec
|
2022-03-07 21:41:12 +01:00
|
|
|
import io.kotest.matchers.shouldNotBe
|
2022-03-11 20:35:25 +01:00
|
|
|
import prog8.code.target.Cx16Target
|
2021-11-30 01:40:21 +01:00
|
|
|
import prog8.compiler.CompilationResult
|
|
|
|
import prog8.compiler.CompilerArguments
|
2021-10-11 00:22:04 +02:00
|
|
|
import prog8.compiler.compileProgram
|
2022-06-26 18:51:03 +02:00
|
|
|
import prog8tests.helpers.assumeReadableFile
|
|
|
|
import prog8tests.helpers.fixturesDir
|
|
|
|
import prog8tests.helpers.outputDir
|
|
|
|
import prog8tests.helpers.workingDir
|
2021-08-01 10:11:29 +02:00
|
|
|
import java.nio.file.Path
|
2021-10-11 00:22:04 +02:00
|
|
|
import kotlin.io.path.absolute
|
2021-08-01 10:11:29 +02: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-08 00:16:58 +01:00
|
|
|
class TestCompilerOptionSourcedirs: FunSpec({
|
2021-08-01 10:11:29 +02:00
|
|
|
|
2022-03-07 21:41:12 +01:00
|
|
|
fun compileFile(filePath: Path, sourceDirs: List<String>): CompilationResult? {
|
2021-11-30 01:40:21 +01:00
|
|
|
val args = CompilerArguments(
|
2021-08-01 10:11:29 +02:00
|
|
|
filepath = filePath,
|
|
|
|
optimize = false,
|
|
|
|
writeAssembly = true,
|
2023-07-30 17:10:54 +02:00
|
|
|
warnSymbolShadowing = false,
|
2021-10-30 15:26:40 +02:00
|
|
|
quietAssembler = true,
|
2021-12-30 14:38:40 +01:00
|
|
|
asmListfile = false,
|
2023-08-02 21:26:40 +02:00
|
|
|
includeSourcelines = false,
|
2022-02-05 21:25:19 +01:00
|
|
|
experimentalCodegen = false,
|
2024-02-10 18:42:31 +01:00
|
|
|
dumpVariables = false,
|
2023-06-27 00:27:34 +02:00
|
|
|
varsHighBank = null,
|
2023-12-23 20:11:50 +01:00
|
|
|
varsGolden = false,
|
2023-12-23 20:45:30 +01:00
|
|
|
slabsHighBank = null,
|
|
|
|
slabsGolden = false,
|
2022-02-06 21:29:06 +01:00
|
|
|
compilationTarget = Cx16Target.NAME,
|
2023-05-30 19:08:34 +02:00
|
|
|
splitWordArrays = false,
|
2024-01-22 21:07:51 +01:00
|
|
|
breakpointCpuInstruction = null,
|
2024-01-01 22:48:19 +01:00
|
|
|
printAst1 = false,
|
|
|
|
printAst2 = false,
|
2024-03-03 17:48:52 +01:00
|
|
|
strictBool = true,
|
2022-07-06 23:40:36 +02:00
|
|
|
symbolDefs = emptyMap(),
|
2021-10-13 18:16:51 +02:00
|
|
|
sourceDirs,
|
2022-06-26 18:51:03 +02:00
|
|
|
outputDir
|
2021-08-01 10:11:29 +02:00
|
|
|
)
|
2021-11-30 01:40:21 +01:00
|
|
|
return compileProgram(args)
|
|
|
|
}
|
2021-08-01 10:11:29 +02:00
|
|
|
|
2021-11-08 00:16:58 +01:00
|
|
|
test("testAbsoluteFilePathOutsideWorkingDir") {
|
2022-06-26 18:51:03 +02:00
|
|
|
val filepath = assumeReadableFile(fixturesDir, "ast_simple_main.p8")
|
2022-03-07 21:41:12 +01:00
|
|
|
compileFile(filepath.absolute(), listOf()) shouldNotBe null
|
2021-08-01 10:11:29 +02:00
|
|
|
}
|
|
|
|
|
2021-11-08 00:16:58 +01:00
|
|
|
test("testFilePathOutsideWorkingDirRelativeToWorkingDir") {
|
2022-06-26 18:51:03 +02:00
|
|
|
val filepath = workingDir.relativize(assumeReadableFile(fixturesDir, "ast_simple_main.p8").absolute())
|
2022-03-07 21:41:12 +01:00
|
|
|
compileFile(filepath, listOf()) shouldNotBe null
|
2021-08-01 10:11:29 +02:00
|
|
|
}
|
|
|
|
|
2021-11-08 00:16:58 +01:00
|
|
|
test("testFilePathOutsideWorkingDirRelativeTo1stInSourcedirs") {
|
2022-06-26 18:51:03 +02:00
|
|
|
val filepath = assumeReadableFile(fixturesDir, "ast_simple_main.p8")
|
2022-10-31 23:59:33 +01:00
|
|
|
val sourcedirs = listOf("$fixturesDir")
|
2022-03-07 21:41:12 +01:00
|
|
|
compileFile(filepath.fileName, sourcedirs) shouldNotBe null
|
2021-08-01 10:11:29 +02:00
|
|
|
}
|
|
|
|
|
2021-11-08 00:16:58 +01:00
|
|
|
})
|