-
Notifications
You must be signed in to change notification settings - Fork 631
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tags defined in spec should be applied before listeners (#3189)
* Tags defined in spec should be applied before listeners * fixes * Potentially active will return Inconclusive if Spec is not explicitly included/excluded based on its tags --------- Co-authored-by: Emil Kantis <emil.kantis@protonmail.com>
- Loading branch information
Showing
31 changed files
with
268 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...ngine/src/commonMain/kotlin/io/kotest/engine/spec/interceptor/InlineTagSpecInterceptor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package io.kotest.engine.spec.interceptor | ||
|
||
import io.kotest.common.flatMap | ||
import io.kotest.core.config.ProjectConfiguration | ||
import io.kotest.core.spec.Spec | ||
import io.kotest.core.test.TestCase | ||
import io.kotest.core.test.TestResult | ||
import io.kotest.engine.listener.TestEngineListener | ||
import io.kotest.engine.spec.SpecExtensions | ||
import io.kotest.engine.tags.TagExpressionResult | ||
import io.kotest.engine.tags.isPotentiallyActive | ||
import io.kotest.engine.tags.parse | ||
import io.kotest.engine.tags.runtimeTagExpression | ||
|
||
/** | ||
* A [SpecInterceptor] that skips this [Spec] if it contains inline tags which don't satisfy | ||
* the current tag expression. | ||
*/ | ||
class InlineTagSpecInterceptor( | ||
private val listener: TestEngineListener, | ||
private val projectConfiguration: ProjectConfiguration, | ||
) : SpecInterceptor { | ||
|
||
private val extensions = SpecExtensions(projectConfiguration.registry) | ||
|
||
override suspend fun intercept( | ||
spec: Spec, | ||
fn: suspend (Spec) -> Result<Map<TestCase, TestResult>> | ||
): Result<Map<TestCase, TestResult>> { | ||
val allTags = spec.tags() + spec.appliedTags() | ||
val potentiallyActive = TagExpressionResult.Exclude != projectConfiguration | ||
.runtimeTagExpression() | ||
.parse() | ||
.isPotentiallyActive(allTags) | ||
|
||
return if (potentiallyActive) fn(spec) else { | ||
val reason = "Ignored due to tags in spec: ${allTags.joinToString(", ")}" | ||
runCatching { listener.specIgnored(spec::class, reason) } | ||
.flatMap { extensions.ignored(spec::class, reason) } | ||
.map { emptyMap() } | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
...ec/interceptor/FinalizeSpecInterceptor.kt → ...nterceptor/ref/FinalizeSpecInterceptor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
...pec/interceptor/PrepareSpecInterceptor.kt → ...interceptor/ref/PrepareSpecInterceptor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ec/interceptor/SpecFinishedInterceptor.kt → ...nterceptor/ref/SpecFinishedInterceptor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...nterceptor/SpecRefExtensionInterceptor.kt → ...ceptor/ref/SpecRefExtensionInterceptor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
...pec/interceptor/SpecStartedInterceptor.kt → ...interceptor/ref/SpecStartedInterceptor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.