prog8/compiler/test/TestCompilerOptionLibdirs.kt

69 lines
2.3 KiB
Kotlin
Raw Normal View History

package prog8tests
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
import java.nio.file.Path
2021-10-10 22:22:04 +00:00
import kotlin.io.path.absolute
/**
* 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.
*/
class TestCompilerOptionSourcedirs: FunSpec({
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(
filepath = filePath,
optimize = false,
writeAssembly = true,
warnSymbolShadowing = false,
quietAssembler = true,
asmListfile = false,
includeSourcelines = false,
experimentalCodegen = false,
dumpVariables = false,
dumpSymbols = false,
2023-06-26 22:27:34 +00:00
varsHighBank = null,
varsGolden = false,
slabsHighBank = null,
slabsGolden = false,
compilationTarget = Cx16Target.NAME,
2023-05-30 17:08:34 +00:00
splitWordArrays = false,
breakpointCpuInstruction = null,
printAst1 = false,
printAst2 = false,
2024-03-03 16:48:52 +00:00
strictBool = true,
symbolDefs = emptyMap(),
sourceDirs,
2022-06-26 16:51:03 +00:00
outputDir
)
2021-11-30 00:40:21 +00:00
return compileProgram(args)
}
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
}
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
}
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
}
})