diff --git a/modules/core-cats/shared/src/main/scala/weaver/BaseIOSuite.scala b/modules/core-cats/shared/src/main/scala/weaver/BaseIOSuite.scala index 7ae62609..56473933 100644 --- a/modules/core-cats/shared/src/main/scala/weaver/BaseIOSuite.scala +++ b/modules/core-cats/shared/src/main/scala/weaver/BaseIOSuite.scala @@ -4,5 +4,4 @@ import cats.effect.IO trait BaseIOSuite extends RunnableSuite[IO] with BaseCatsSuite { implicit protected def effectCompat: UnsafeRun[IO] = CatsUnsafeRun - def getSuite: EffectSuite[IO] = this } diff --git a/modules/core-cats/shared/src/main/scala/weaver/Suites.scala b/modules/core-cats/shared/src/main/scala/weaver/Suites.scala index 200e7b6c..0386ed05 100644 --- a/modules/core-cats/shared/src/main/scala/weaver/Suites.scala +++ b/modules/core-cats/shared/src/main/scala/weaver/Suites.scala @@ -2,7 +2,7 @@ package weaver import cats.effect.{ IO, Resource } -trait BaseCatsSuite extends EffectSuite.Provider[IO] +trait BaseCatsSuite extends EffectSuite[IO] abstract class MutableIOSuite extends MutableFSuite[IO] diff --git a/modules/core/shared/src/main/scala/weaver/Runner.scala b/modules/core/shared/src/main/scala/weaver/Runner.scala index a9acd41a..92a1be68 100644 --- a/modules/core/shared/src/main/scala/weaver/Runner.scala +++ b/modules/core/shared/src/main/scala/weaver/Runner.scala @@ -19,7 +19,7 @@ class Runner[F[_]: Async]( // Signaling option, because we need to detect completion private type Channel[A] = Queue[F, Option[A]] - def run(suites: fs2.Stream[F, Suite[F]]): F[Outcome] = + def run(suites: fs2.Stream[F, EffectSuite[F]]): F[Outcome] = for { buffer <- Ref[F].of(Chain.empty[SpecEvent]) channel <- Queue.unbounded[F, Option[SpecEvent]] diff --git a/modules/core/shared/src/main/scala/weaver/suites.scala b/modules/core/shared/src/main/scala/weaver/suites.scala index ec3bf3a6..40972196 100644 --- a/modules/core/shared/src/main/scala/weaver/suites.scala +++ b/modules/core/shared/src/main/scala/weaver/suites.scala @@ -4,7 +4,6 @@ import scala.concurrent.duration.FiniteDuration import cats.data.Chain import cats.effect.{ Async, Resource } -import cats.syntax.all._ import fs2.Stream import org.portablescala.reflect.annotation.EnableReflectiveInstantiation @@ -14,39 +13,25 @@ import org.junit.runner.RunWith @EnableReflectiveInstantiation trait BaseSuiteClass {} -trait Suite[F[_]] extends BaseSuiteClass { - def name: String - def spec(args: List[String]): Stream[F, TestOutcome] -} - // A version of EffectSuite that has a type member instead of a type parameter. protected[weaver] trait EffectSuiteAux { type EffectType[A] implicit protected def effect: Async[EffectType] } -trait EffectSuite[F[_]] extends Suite[F] with EffectSuiteAux +trait EffectSuite[F[_]] extends BaseSuiteClass with EffectSuiteAux with SourceLocation.Here { self => final type EffectType[A] = F[A] implicit protected def effectCompat: EffectCompat[F] implicit final protected def effect: Async[F] = effectCompat.effect - override def name: String = self.getClass.getName.replace("$", "") - - protected def adaptRunError: PartialFunction[Throwable, Throwable] = - PartialFunction.empty + def name: String = self.getClass.getName.replace("$", "") final def run(args: List[String])(report: TestOutcome => F[Unit]): F[Unit] = - spec(args).evalMap(report).compile.drain.adaptErr(adaptRunError) -} - -object EffectSuite { - - trait Provider[F[_]] { - def getSuite: EffectSuite[F] - } + spec(args).evalMap(report).compile.drain + def spec(args: List[String]): Stream[F, TestOutcome] } @RunWith(classOf[weaver.junit.WeaverRunner]) diff --git a/modules/docs/shared/src/main/scala/main/scala/weaver/Output.scala b/modules/docs/shared/src/main/scala/main/scala/weaver/Output.scala index 6209d6bb..4bed88e2 100644 --- a/modules/docs/shared/src/main/scala/main/scala/weaver/Output.scala +++ b/modules/docs/shared/src/main/scala/main/scala/weaver/Output.scala @@ -17,7 +17,7 @@ object Output { if (s.endsWith("\n")) s.substring(0, s.length - 2) else s } - def runSuites(s: Suite[IO]*): String = { + def runSuites(s: EffectSuite[IO]*): String = { import cats.effect.unsafe.implicits.global val header = "
"
     val footer = "
" diff --git a/modules/framework/shared/src/main/scala/weaver/framework/Fingerprints.scala b/modules/framework/shared/src/main/scala/weaver/framework/Fingerprints.scala index 89eddb28..aae14040 100644 --- a/modules/framework/shared/src/main/scala/weaver/framework/Fingerprints.scala +++ b/modules/framework/shared/src/main/scala/weaver/framework/Fingerprints.scala @@ -12,7 +12,7 @@ import sbt.testing.{ Fingerprint, SubclassFingerprint, TaskDef } object WeaverFingerprints { abstract class Mixin[ F[_], - SC <: EffectSuite.Provider[F], + SC <: EffectSuite[F], GRIC <: GlobalResourceF[F]]( implicit SC: ClassTag[SC], GRIC: ClassTag[GRIC], @@ -30,7 +30,7 @@ object WeaverFingerprints { */ abstract class WeaverFingerprints[F[_]](implicit F: Sync[F]) { - type SuiteClass <: EffectSuite.Provider[F] + type SuiteClass <: EffectSuite[F] implicit protected def SuiteClass: ClassTag[SuiteClass] type GlobalResourcesInitClass <: GlobalResourceF[F] implicit protected def GlobalResourcesInitClass: ClassTag[GlobalResourcesInitClass] @@ -43,19 +43,17 @@ abstract class WeaverFingerprints[F[_]](implicit F: Sync[F]) { case SuiteFingerprint.matches() => val mkSuite = F.delay { val module = loadModule(taskDef.fullyQualifiedName(), classLoader) - val provider = cast(module)(SuiteClass): EffectSuite.Provider[F] - provider.getSuite + cast(module)(SuiteClass): EffectSuite[F] } Some(SuiteRef(mkSuite)) case ResourceSharingSuiteFingerprint.matches() => - val cst: F[GlobalResourceF.Read[F] => EffectSuite.Provider[F]] = + val cst: F[GlobalResourceF.Read[F] => EffectSuite[F]] = // inherently unsafe, as it assumes the user doesn't F.delay(loadConstructor[GlobalResourceF.Read[F], SuiteClass]( taskDef.fullyQualifiedName(), - classLoader): GlobalResourceF.Read[F] => EffectSuite.Provider[ - F]) + classLoader): GlobalResourceF.Read[F] => EffectSuite[F]) Some(ResourcesSharingSuiteRef(read => - F.map(F.ap(cst)(F.pure(read)))(_.getSuite))) + F.ap(cst)(F.pure(read)))) case GlobalResourcesFingerprint.matches() => val module = loadModule(taskDef.fullyQualifiedName(), classLoader)