-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Given the following example test:
internal class InterpreterTest : FunSpec({
context("program execution and output") {
listOf(
"""print "Hello, World!"""",
"out 100",
)
.also { programs ->
withData(programs) { it.shouldExecuteAndOutput() }
}
}
})Running the test (with Kotest 6 patch) throws:
An operation is not implemented: Handle SourceRef.None
kotlin.NotImplementedError: An operation is not implemented: Handle SourceRef.None
at com.diffplug.selfie.kotest.SelfieExtension.snapshotFileFor(SelfieExtension.kt:66)
at com.diffplug.selfie.kotest.SelfieExtension.intercept(SelfieExtension.kt:76)
at io.kotest.engine.test.TestExtensions$intercept$execute$1$1.invoke(TestExtensions.kt:143)
at io.kotest.engine.test.TestExtensions.intercept(TestExtensions.kt:151)
at io.kotest.engine.test.interceptors.TestCaseExtensionInterceptor.intercept(TestCaseExtensionInterceptor.kt:21)
at io.kotest.engine.test.TestCaseExecutor$execute$3$1.invoke(TestCaseExecutor.kt:120)
at io.kotest.engine.test.interceptors.TestEnabledCheckInterceptor.intercept(TestEnabledCheckInterceptor.kt:41)
at io.kotest.engine.test.TestCaseExecutor$execute$3$1.invoke(TestCaseExecutor.kt:120)
This happens because TestCase.sourceRef is (unexpectedly) None.
I've patched it locally like this:
patch
Index: jvm/selfie-runner-kotest/src/commonMain/kotlin/com/diffplug/selfie/kotest/SelfieExtension.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/jvm/selfie-runner-kotest/src/commonMain/kotlin/com/diffplug/selfie/kotest/SelfieExtension.kt b/jvm/selfie-runner-kotest/src/commonMain/kotlin/com/diffplug/selfie/kotest/SelfieExtension.kt
--- a/jvm/selfie-runner-kotest/src/commonMain/kotlin/com/diffplug/selfie/kotest/SelfieExtension.kt (revision 5ee91c50b7b814b88596b67470c68ab8a273c6c9)
+++ b/jvm/selfie-runner-kotest/src/commonMain/kotlin/com/diffplug/selfie/kotest/SelfieExtension.kt (date 1770190650932)
@@ -23,7 +23,6 @@
import io.kotest.core.extensions.TestCaseExtension
import io.kotest.core.listeners.AfterProjectListener
import io.kotest.core.listeners.FinalizeSpecListener
-import io.kotest.core.source.SourceRef
import io.kotest.core.spec.Spec
import io.kotest.core.test.TestCase
import io.kotest.engine.test.TestResult
@@ -59,12 +58,7 @@
}
}
private fun snapshotFileFor(testCase: TestCase): SnapshotFileProgress {
- val classOrFilename: String =
- when (val source = testCase.source) {
- is SourceRef.ClassSource -> source.fqn
- is SourceRef.ClassLineSource -> source.fqn
- is SourceRef.None -> TODO("Handle SourceRef.None")
- }
+ val classOrFilename: String = testCase.descriptor.root().id.value
return system.forClassOrFilename(classOrFilename)
}which uses the context value as the file name. But I think it would be nicer if it was matching the test class name instead.
Potentially even for such tests the name could be something like <context>/<test name> (though / currently is not allowed in the name).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working