diff options
author | nea <nea@nea.moe> | 2023-08-10 18:01:37 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-08-10 18:01:37 +0200 |
commit | 873864974127ec4f123c7db0560235e806c3faab (patch) | |
tree | c1d39786d89dd39f7843a73c2d69e75a12894b36 /src/TestFramework.kt | |
parent | 0ab6dab185e31fcf6f3e0cf98dc8496f02448ee8 (diff) | |
download | nealisp-873864974127ec4f123c7db0560235e806c3faab.tar.gz nealisp-873864974127ec4f123c7db0560235e806c3faab.tar.bz2 nealisp-873864974127ec4f123c7db0560235e806c3faab.zip |
Add test junit formatter
Diffstat (limited to 'src/TestFramework.kt')
-rw-r--r-- | src/TestFramework.kt | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/TestFramework.kt b/src/TestFramework.kt index 8406a79..b35020c 100644 --- a/src/TestFramework.kt +++ b/src/TestFramework.kt @@ -1,5 +1,7 @@ package moe.nea.lisp +import java.time.Instant + object TestFramework { data class TestFailure( val callsite: LispAst, @@ -14,6 +16,7 @@ object TestFramework { data class TestSuite( val name: String, + val startTime: Instant, var isTesting: Boolean, val allTests: MutableList<TestResult>, val testList: List<String>, @@ -30,14 +33,14 @@ object TestFramework { object TestSuiteMeta : StackFrame.MetaKey<TestSuite> object ActiveTestMeta : StackFrame.MetaKey<ActiveTest> - val testBinding = LispData.externalRawCall { context, callsite, stackFrame, args -> + val testBinding = LispData.externalRawCall("ntest.test") { context, callsite, stackFrame, args -> runTest(context, callsite, stackFrame, args) return@externalRawCall LispData.LispNil } - val failTestBinding = LispData.externalCall { args, reportError -> + val failTestBinding = LispData.externalCall("ntest.fail") { args, reportError -> val message = CoreBindings.stringify(args.singleOrNull() ?: return@externalCall reportError("Needs a message")) - LispData.externalRawCall { context, callsite, stackFrame, args -> + LispData.externalRawCall("ntest.fail.r") { context, callsite, stackFrame, args -> val activeTest = stackFrame.getMeta(ActiveTestMeta) ?: return@externalRawCall context.reportError("No active test", callsite) activeTest.currentFailures.add(TestFailure(callsite, message)) @@ -83,9 +86,8 @@ object TestFramework { } fun setup(stackFrame: StackFrame, name: String, testList: List<String>, isWhitelist: Boolean): TestSuite { - val ts = TestSuite(name, true, mutableListOf(), testList, isWhitelist) + val ts = TestSuite(name, Instant.now(), true, mutableListOf(), testList, isWhitelist) stackFrame.setMeta(TestSuiteMeta, ts) - ts.isTesting = false return ts } } |