mirror of
https://github.com/irmen/prog8.git
synced 2024-11-03 13:07:54 +00:00
db76c8d7f4
For good measure we also turn on *all* compiler tests with examples (they do take some time). Note that the total *mentions* of IStringEncoding in the entire project went down from ~50 to 6, only 3 of which are *actual uses* (the others are 2 imports and 1 supertype ref in ICompilationTarget : IStringEncoding)!
128 lines
3.6 KiB
Kotlin
128 lines
3.6 KiB
Kotlin
package prog8tests
|
|
|
|
import org.junit.jupiter.api.TestInstance
|
|
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.*
|
|
|
|
import prog8.compiler.compileProgram
|
|
import prog8.compiler.target.C64Target
|
|
import prog8.compiler.target.Cx16Target
|
|
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.
|
|
*/
|
|
//@Disabled("to save some time")
|
|
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
|
class TestCompilerOnExamples {
|
|
private val examplesDir = workingDir.resolve("../examples")
|
|
|
|
@BeforeAll
|
|
fun setUp() {
|
|
sanityCheckDirectories("compiler")
|
|
assumeDirectory(examplesDir)
|
|
}
|
|
|
|
// TODO: make assembly stage testable - in case of failure (eg of 64tass) it Process.exit s
|
|
|
|
private fun makeDynamicCompilerTest(name: String, platform: ICompilationTarget, optimize: Boolean) : DynamicTest {
|
|
val searchIn = mutableListOf(examplesDir)
|
|
if (platform == Cx16Target) {
|
|
searchIn.add(0, examplesDir.resolve("cx16"))
|
|
}
|
|
val filepath = searchIn.map { it.resolve("$name.p8") }.first { it.exists() }
|
|
val displayName = "${examplesDir.relativize(filepath)}: ${platform.name}, optimize=$optimize"
|
|
return dynamicTest(displayName) {
|
|
compileProgram(
|
|
filepath,
|
|
optimize,
|
|
writeAssembly = true,
|
|
slowCodegenWarnings = false,
|
|
compilationTarget = platform.name,
|
|
libdirs = listOf(),
|
|
outputDir
|
|
).assertSuccess("; $displayName")
|
|
}
|
|
}
|
|
|
|
@TestFactory
|
|
// @Disabled
|
|
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",
|
|
"test",
|
|
"textelite",
|
|
),
|
|
dim2 = listOf(Cx16Target, C64Target),
|
|
dim3 = listOf(false, true),
|
|
combine3 = ::makeDynamicCompilerTest
|
|
)
|
|
|
|
@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
|
|
)
|
|
|
|
@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
|
|
)
|
|
}
|