2021-06-28 16:42:05 +00:00
|
|
|
package prog8tests
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.TestInstance
|
2021-07-17 08:37:58 +00:00
|
|
|
import org.junit.jupiter.api.TestFactory
|
|
|
|
import org.junit.jupiter.api.Disabled
|
|
|
|
import org.junit.jupiter.api.BeforeAll
|
|
|
|
import org.junit.jupiter.api.DynamicTest
|
|
|
|
import org.junit.jupiter.api.DynamicTest.dynamicTest
|
|
|
|
import prog8tests.helpers.*
|
|
|
|
import kotlin.io.path.*
|
|
|
|
|
2021-06-28 16:42:05 +00:00
|
|
|
import prog8.compiler.compileProgram
|
2021-07-17 08:37:58 +00:00
|
|
|
import prog8.compiler.target.C64Target
|
2021-07-01 22:11:21 +00:00
|
|
|
import prog8.compiler.target.Cx16Target
|
2021-06-28 16:42:05 +00:00
|
|
|
import prog8.compiler.target.ICompilationTarget
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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-07-17 08:37:58 +00:00
|
|
|
//@Disabled("to save some time")
|
2021-06-28 16:42:05 +00:00
|
|
|
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
|
|
|
class TestCompilerOnExamples {
|
2021-07-31 12:44:02 +00:00
|
|
|
private val examplesDir = assumeDirectory(workingDir, "../examples")
|
2021-06-28 16:42:05 +00:00
|
|
|
|
|
|
|
// TODO: make assembly stage testable - in case of failure (eg of 64tass) it Process.exit s
|
|
|
|
|
2021-07-17 08:37:58 +00:00
|
|
|
private fun makeDynamicCompilerTest(name: String, platform: ICompilationTarget, optimize: Boolean) : DynamicTest {
|
|
|
|
val searchIn = mutableListOf(examplesDir)
|
|
|
|
if (platform == Cx16Target) {
|
2021-07-31 12:44:02 +00:00
|
|
|
searchIn.add(0, assumeDirectory(examplesDir, "cx16"))
|
2021-07-17 08:37:58 +00:00
|
|
|
}
|
2021-08-01 08:11:29 +00:00
|
|
|
val filepath = searchIn
|
|
|
|
.map { it.resolve("$name.p8") }
|
|
|
|
.map { it.normalize().absolute() }
|
|
|
|
.map { workingDir.relativize(it) }
|
|
|
|
.first { it.exists() }
|
|
|
|
val displayName = "${examplesDir.relativize(filepath.absolute())}: ${platform.name}, optimize=$optimize"
|
2021-07-17 08:37:58 +00:00
|
|
|
return dynamicTest(displayName) {
|
|
|
|
compileProgram(
|
|
|
|
filepath,
|
|
|
|
optimize,
|
|
|
|
writeAssembly = true,
|
|
|
|
slowCodegenWarnings = false,
|
|
|
|
compilationTarget = platform.name,
|
|
|
|
libdirs = listOf(),
|
|
|
|
outputDir
|
|
|
|
).assertSuccess("; $displayName")
|
|
|
|
}
|
2021-06-28 16:42:05 +00:00
|
|
|
}
|
|
|
|
|
2021-07-17 08:37:58 +00:00
|
|
|
@TestFactory
|
2021-07-13 07:51:34 +00:00
|
|
|
// @Disabled
|
2021-07-17 08:37:58 +00:00
|
|
|
fun bothCx16AndC64() = mapCombinations(
|
|
|
|
dim1 = listOf(
|
|
|
|
"animals",
|
|
|
|
"balls",
|
|
|
|
"cube3d",
|
|
|
|
"cube3d-float",
|
|
|
|
"cube3d-gfx",
|
|
|
|
"cxlogo",
|
|
|
|
"dirlist",
|
|
|
|
"fibonacci",
|
|
|
|
"line-circle-gfx",
|
|
|
|
"line-circle-txt",
|
|
|
|
"mandelbrot",
|
|
|
|
"mandelbrot-gfx",
|
|
|
|
"numbergame",
|
|
|
|
"primes",
|
|
|
|
"rasterbars",
|
|
|
|
"screencodes",
|
|
|
|
"sorting",
|
|
|
|
"swirl",
|
|
|
|
"swirl-float",
|
|
|
|
"tehtriz",
|
|
|
|
"textelite",
|
|
|
|
),
|
|
|
|
dim2 = listOf(Cx16Target, C64Target),
|
|
|
|
dim3 = listOf(false, true),
|
|
|
|
combine3 = ::makeDynamicCompilerTest
|
|
|
|
)
|
2021-06-28 16:42:05 +00:00
|
|
|
|
2021-07-17 08:37:58 +00:00
|
|
|
@TestFactory
|
|
|
|
// @Disabled
|
|
|
|
fun onlyC64() = mapCombinations(
|
|
|
|
dim1 = listOf(
|
|
|
|
"balloonflight",
|
|
|
|
"bdmusic",
|
|
|
|
"bdmusic-irq",
|
|
|
|
"charset",
|
|
|
|
"cube3d-sprites",
|
|
|
|
"plasma",
|
|
|
|
"sprites",
|
|
|
|
"turtle-gfx",
|
|
|
|
"wizzine",
|
|
|
|
),
|
|
|
|
dim2 = listOf(C64Target),
|
|
|
|
dim3 = listOf(false, true),
|
|
|
|
combine3 = ::makeDynamicCompilerTest
|
|
|
|
)
|
2021-06-28 16:42:05 +00:00
|
|
|
|
2021-07-17 08:37:58 +00:00
|
|
|
@TestFactory
|
|
|
|
// @Disabled
|
|
|
|
fun onlyCx16() = mapCombinations(
|
|
|
|
dim1 = listOf(
|
|
|
|
"vtui/testvtui",
|
|
|
|
"amiga",
|
|
|
|
"bobs",
|
|
|
|
"cobramk3-gfx",
|
|
|
|
"colorbars",
|
|
|
|
"datetime",
|
|
|
|
"highresbitmap",
|
|
|
|
"kefrenbars",
|
|
|
|
"mandelbrot-gfx-colors",
|
|
|
|
"multipalette",
|
|
|
|
"testgfx2",
|
|
|
|
),
|
|
|
|
dim2 = listOf(Cx16Target),
|
|
|
|
dim3 = listOf(false, true),
|
|
|
|
combine3 = ::makeDynamicCompilerTest
|
|
|
|
)
|
2021-07-01 22:11:21 +00:00
|
|
|
}
|