From bb1759abaf370e370f9715f13a22fd104ba8e207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93lafur=20P=C3=A1ll=20Geirsson?= Date: Sat, 16 Oct 2021 10:45:51 +0200 Subject: [PATCH] Introduce `BaseFunSuite` trait and make `FunSuite` an empty class (#433) --- build.sbt | 12 ++++++++++++ munit/shared/src/main/scala/munit/FunFixtures.scala | 2 +- munit/shared/src/main/scala/munit/FunSuite.scala | 4 +++- .../src/main/scala/munit/SuiteTransforms.scala | 2 +- .../shared/src/main/scala/munit/TestTransforms.scala | 2 +- .../src/main/scala/munit/ValueTransforms.scala | 2 +- 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index 10aa3213..30538aa5 100644 --- a/build.sbt +++ b/build.sbt @@ -103,6 +103,18 @@ lazy val mimaEnable: List[Def.Setting[_]] = List( ProblemFilters.exclude[MissingClassProblem]("munit.Suite$Fixture"), ProblemFilters.exclude[IncompatibleMethTypeProblem]( "munit.TestTransforms#TestTransform.apply" + ), + ProblemFilters.exclude[IncompatibleMethTypeProblem]( + "munit.FunFixtures#FunFixture.this" + ), + ProblemFilters.exclude[IncompatibleMethTypeProblem]( + "munit.SuiteTransforms#SuiteTransform.this" + ), + ProblemFilters.exclude[IncompatibleMethTypeProblem]( + "munit.TestTransforms#TestTransform.this" + ), + ProblemFilters.exclude[IncompatibleMethTypeProblem]( + "munit.ValueTransforms#ValueTransform.this" ) ), mimaPreviousArtifacts := { diff --git a/munit/shared/src/main/scala/munit/FunFixtures.scala b/munit/shared/src/main/scala/munit/FunFixtures.scala index 13c0ac98..7e0f5821 100644 --- a/munit/shared/src/main/scala/munit/FunFixtures.scala +++ b/munit/shared/src/main/scala/munit/FunFixtures.scala @@ -6,7 +6,7 @@ import scala.concurrent.Future import scala.util.Success import scala.util.Failure -trait FunFixtures { self: FunSuite => +trait FunFixtures { self: BaseFunSuite => class FunFixture[T] private ( val setup: TestOptions => Future[T], diff --git a/munit/shared/src/main/scala/munit/FunSuite.scala b/munit/shared/src/main/scala/munit/FunSuite.scala index b9bdd6b7..efe80e62 100644 --- a/munit/shared/src/main/scala/munit/FunSuite.scala +++ b/munit/shared/src/main/scala/munit/FunSuite.scala @@ -8,7 +8,9 @@ import scala.concurrent.duration.Duration import scala.concurrent.duration.FiniteDuration import java.util.concurrent.TimeUnit -abstract class FunSuite +abstract class FunSuite extends BaseFunSuite + +trait BaseFunSuite extends Suite with Assertions with FunFixtures diff --git a/munit/shared/src/main/scala/munit/SuiteTransforms.scala b/munit/shared/src/main/scala/munit/SuiteTransforms.scala index 26fa13db..ca47b1f9 100644 --- a/munit/shared/src/main/scala/munit/SuiteTransforms.scala +++ b/munit/shared/src/main/scala/munit/SuiteTransforms.scala @@ -3,7 +3,7 @@ package munit import scala.concurrent.Future import scala.util.control.NonFatal -trait SuiteTransforms { this: FunSuite => +trait SuiteTransforms { this: BaseFunSuite => final class SuiteTransform(val name: String, fn: List[Test] => List[Test]) extends Function1[List[Test], List[Test]] { diff --git a/munit/shared/src/main/scala/munit/TestTransforms.scala b/munit/shared/src/main/scala/munit/TestTransforms.scala index 5e17fcde..880b5c41 100644 --- a/munit/shared/src/main/scala/munit/TestTransforms.scala +++ b/munit/shared/src/main/scala/munit/TestTransforms.scala @@ -6,7 +6,7 @@ import scala.util.Failure import scala.concurrent.Future import scala.util.control.NonFatal -trait TestTransforms { this: FunSuite => +trait TestTransforms { this: BaseFunSuite => final class TestTransform(val name: String, fn: Test => Test) extends Function1[Test, Test] { diff --git a/munit/shared/src/main/scala/munit/ValueTransforms.scala b/munit/shared/src/main/scala/munit/ValueTransforms.scala index ea924187..d6a3bea2 100644 --- a/munit/shared/src/main/scala/munit/ValueTransforms.scala +++ b/munit/shared/src/main/scala/munit/ValueTransforms.scala @@ -5,7 +5,7 @@ import munit.internal.FutureCompat._ import scala.util.Try import munit.internal.console.StackTraces -trait ValueTransforms { this: FunSuite => +trait ValueTransforms { this: BaseFunSuite => final class ValueTransform( val name: String,