Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support superclass annotations when deciding whether a class should be isolated. #3441

Merged
merged 4 commits into from
Apr 3, 2023

Conversation

kozlov-aa
Copy link
Contributor

This is a suggested change to improve behavior of @Isolate annotation.

Context

At the moment, the @Isolate annotation on the parent class does not affect the isolation of child classes in any way.

object ProjectConfig : AbstractProjectConfig() {
   override val parallelism = 4
}

@Isolate
abstract class ShouldBeIsolated(body: FreeSpec.() -> Unit = {}) : FreeSpec(body)

@Isolate
interface ShouldAlsoBeIsolated

class MyTestClass1 : ShouldBeIsolated({

  "... still work in parallel" {
  }

})

class MyTestClass2 : FreeSpec({

  "... also still work in parallel" {
  }

}) : ShouldAlsoBeIsolated

Changes

These changes will help make annotation search customizable as needed.

  • added sealed interface AnnotationSearchParameter
  • added two implementations IncludingAnnotations and IncludingSuperclasses
  • method Reflection#annotations now accept a set of AnnotationSearchParameter instead recursive flag
  • methods KClass<*>#annotations and KClass<*>#hasAnnotation by default still has just recursive behavior
  • method KClass<*>#isIsolate in addition to recursive check, checks the presence of @DoNotParallelize or @Isolate in superclasses
  • annotations caching still supported, but now cache key is Pair<KClass<*>, Set<AnnotationSearchParameter>

@sksamuel sksamuel self-requested a review April 2, 2023 08:26
@sksamuel
Copy link
Member

sksamuel commented Apr 2, 2023

This is great.

@sksamuel sksamuel enabled auto-merge (squash) April 2, 2023 08:28
@sksamuel sksamuel disabled auto-merge April 3, 2023 16:56
@sksamuel sksamuel enabled auto-merge (squash) April 3, 2023 16:56
@sksamuel sksamuel disabled auto-merge April 3, 2023 16:56
@sksamuel sksamuel merged commit 7eddcbc into kotest:master Apr 3, 2023
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants