summaryrefslogtreecommitdiff
path: root/test/src/TestMain.kt
blob: fc95780fa0f9f546e59a5c4e907158d3235cdef9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import moe.nea.lisp.LispExecutionContext
import moe.nea.lisp.LispParser
import moe.nea.lisp.TestResultFormatter
import java.io.File
import javax.xml.stream.XMLOutputFactory

object TestMain {
    @JvmStatic
    fun main(args: Array<String>) {
        val reportFile = System.getProperty("test.report")
        val modulesToTest = System.getProperty("test.suites").split(":")
        val modulePath = System.getProperty("test.imports").split(":")
        val executionContext = LispExecutionContext()
        executionContext.setupStandardBindings()
        modulePath.forEach {
            executionContext.registerModule(it, LispParser.parse(File(T::class.java.getResource("/$it.lisp")!!.file)))
        }
        val allResults = modulesToTest.map {
            executionContext.runTests(
                LispParser.parse(File(T::class.java.getResource("/$it.lisp")!!.file)),
                it,
            )
        }
        val w = XMLOutputFactory.newFactory()
            .createXMLStreamWriter(File(reportFile).bufferedWriter())
        TestResultFormatter.write(w, allResults)
        w.close()

    }
}