@@ -3,6 +3,7 @@ package io.github.jadarma.aockt.test.internal
33import io.github.jadarma.aockt.core.Solution
44import io.github.jadarma.aockt.test.AdventPartScope
55import io.github.jadarma.aockt.test.AdventSpec
6+ import io.github.jadarma.aockt.test.AocKtExtension
67import io.github.jadarma.aockt.test.ExecMode
78import io.github.jadarma.aockt.test.Expensive
89import io.kotest.assertions.AssertionErrorBuilder
@@ -13,6 +14,7 @@ import io.kotest.common.reflection.ReflectionInstantiations.newInstanceNoArgCons
1314import io.kotest.core.spec.style.scopes.FunSpecContainerScope
1415import io.kotest.matchers.comparables.shouldBeLessThanOrEqualTo
1516import io.kotest.matchers.shouldBe
17+ import kotlinx.coroutines.currentCoroutineContext
1618import kotlin.reflect.KClass
1719import kotlin.reflect.full.isSubtypeOf
1820import kotlin.reflect.full.starProjectedType
@@ -38,6 +40,21 @@ internal fun AdventSpec<*>.injectSolution(): Solution = this::class
3840 .getOrElse { throw MissingNoArgConstructorException (this ) }
3941 }
4042
43+ /* *
44+ * Retrieves the [AdventSpecConfig] for this spec from the test runner coroutine.
45+ * If an [AocKtExtension] has been registered, use the user-provided configuration.
46+ * Otherwise, returns the sane defaults.
47+ * Additionally, any non-null config parameters passed will be overridden in the final result.
48+ */
49+ @Suppress(" UnusedReceiverParameter" )
50+ internal suspend fun AdventSpec <* >.configuration (
51+ efficiencyBenchmark : Duration ? ,
52+ executionMode : ExecMode ? ,
53+ ): AdventSpecConfig =
54+ currentCoroutineContext()[AdventSpecConfig .Key ]
55+ .run { this ? : AdventSpecConfig .Default }
56+ .override (efficiencyBenchmark, executionMode)
57+
4158/* *
4259 * Defines the rootContext to test the implementation of one [part] of a [Solution].
4360 *
0 commit comments