diff --git a/bin/test-release.sh b/bin/test-release.sh index f0435114..5acc340b 100755 --- a/bin/test-release.sh +++ b/bin/test-release.sh @@ -9,7 +9,8 @@ coursier resolve \ org.scalameta:munit_2.11:$version \ org.scalameta:munit_2.12:$version \ org.scalameta:munit_2.13:$version \ - org.scalameta:munit_3.0.0-M1:$version \ + org.scalameta:munit_3.0.0-M2:$version \ + org.scalameta:munit_3.0.0-M3:$version \ org.scalameta:munit_0.27:$version \ org.scalameta:munit_native0.4.0-M2_2.11:$version \ org.scalameta:munit_sjs1_2.11:$version \ @@ -19,7 +20,8 @@ coursier resolve \ org.scalameta:munit-scalacheck_2.12:$version \ org.scalameta:munit-scalacheck_2.13:$version \ org.scalameta:munit-scalacheck_0.27:$version \ - org.scalameta:munit-scalacheck_3.0.0-M1:$version \ + org.scalameta:munit-scalacheck_3.0.0-M2:$version \ + org.scalameta:munit-scalacheck_3.0.0-M3:$version \ org.scalameta:munit-scalacheck_native0.4.0-M2_2.11:$version \ org.scalameta:munit-scalacheck_sjs1_2.11:$version \ org.scalameta:munit-scalacheck_sjs1_2.12:$version \ diff --git a/build.sbt b/build.sbt index a95ad4d2..c7e0665f 100644 --- a/build.sbt +++ b/build.sbt @@ -10,8 +10,8 @@ def previousVersion = "0.7.0" def scala213 = "2.13.2" def scala212 = "2.12.11" def scala211 = "2.11.12" -def scala3Stable = "3.0.0-M2" -def scala3Previous = List("3.0.0-M1", "0.27.0-RC1") +def scala3Stable = "3.0.0-M3" +def scala3Previous = List("3.0.0-M2") def junitVersion = "4.13" def gcp = "com.google.cloud" % "google-cloud-storage" % "1.113.6" inThisBuild( @@ -251,7 +251,7 @@ lazy val munitScalacheck = crossProject(JSPlatform, JVMPlatform, NativePlatform) .settings( moduleName := "munit-scalacheck", sharedSettings, - libraryDependencies += "org.scalacheck" %%% "scalacheck" % "1.15.1" + libraryDependencies += "org.scalacheck" %%% "scalacheck" % "1.15.2" ) .jvmSettings( sharedJVMSettings diff --git a/munit/shared/src/main/scala-3.0.0-M1/munit/internal/MacroCompat.scala b/munit/shared/src/main/scala-3.0.0-M1/munit/internal/MacroCompat.scala deleted file mode 100644 index 83d49a45..00000000 --- a/munit/shared/src/main/scala-3.0.0-M1/munit/internal/MacroCompat.scala +++ /dev/null @@ -1,46 +0,0 @@ -package munit.internal - -import munit.Clue -import munit.Location -import scala.quoted._ - -object MacroCompat { - - trait LocationMacro { - inline implicit def generate: Location = ${ locationImpl() } - } - - def locationImpl()(using qctx: QuoteContext): Expr[Location] = { - import qctx.reflect.{_, given} - val path = rootPosition.sourceFile.jpath.toString - val startLine = rootPosition.startLine + 1 - '{ new Location(${Expr(path)}, ${Expr(startLine)}) } - } - - trait ClueMacro { - inline implicit def generate[T](value: T): Clue[T] = ${ clueImpl('value) } - } - - def clueImpl[T:Type](value: Expr[T])(using qctx: QuoteContext): Expr[Clue[T]] = { - import qctx.reflect.{_, given} - val source = value.unseal.pos.sourceCode - val valueType = implicitly[scala.quoted.Type[T]].show - '{ new Clue(${Expr(source)}, $value, ${Expr(valueType)}) } - } - - trait CompileErrorMacro { - inline def compileErrors(inline code: String): String = { - val errors = scala.compiletime.testing.typeCheckErrors(code) - errors.map { error => - val indent = " " * (error.column - 1) - val trimMessage = error.message.linesIterator.map { line => - if (line.matches(" +")) "" - else line - }.mkString("\n") - val separator = if (error.message.contains('\n')) "\n" else " " - s"error:${separator}${trimMessage}\n${error.lineContent}\n${indent}^" - }.mkString("\n") - } - } - -} diff --git a/munit/shared/src/main/scala-0.27/munit/internal/MacroCompat.scala b/munit/shared/src/main/scala-3.0.0-M3/munit/internal/MacroCompat.scala similarity index 69% rename from munit/shared/src/main/scala-0.27/munit/internal/MacroCompat.scala rename to munit/shared/src/main/scala-3.0.0-M3/munit/internal/MacroCompat.scala index 9f108422..263bec9e 100644 --- a/munit/shared/src/main/scala-0.27/munit/internal/MacroCompat.scala +++ b/munit/shared/src/main/scala-3.0.0-M3/munit/internal/MacroCompat.scala @@ -10,10 +10,11 @@ object MacroCompat { inline implicit def generate: Location = ${ locationImpl() } } - def locationImpl()(using qctx: QuoteContext): Expr[Location] = { - import qctx.tasty.{_, given _} - val path = rootPosition.sourceFile.jpath.toString - val startLine = rootPosition.startLine + 1 + def locationImpl()(using Quotes): Expr[Location] = { + import quotes.reflect._ + val pos = Position.ofMacroExpansion + val path = pos.sourceFile.jpath.toString + val startLine = pos.startLine + 1 '{ new Location(${Expr(path)}, ${Expr(startLine)}) } } @@ -21,10 +22,10 @@ object MacroCompat { inline implicit def generate[T](value: T): Clue[T] = ${ clueImpl('value) } } - def clueImpl[T:Type](value: Expr[T])(using qctx: QuoteContext): Expr[Clue[T]] = { - import qctx.tasty.{_, given _} - val source = value.unseal.pos.sourceCode - val valueType = implicitly[scala.quoted.Type[T]].show + def clueImpl[T: Type](value: Expr[T])(using Quotes): Expr[Clue[T]] = { + import quotes.reflect._ + val source = Term.of(value).pos.sourceCode.getOrElse("") + val valueType = TypeTree.of[T].show(using Printer.TreeShortCode) '{ new Clue(${Expr(source)}, $value, ${Expr(valueType)}) } } diff --git a/tests/shared/src/main/scala/munit/Tags.scala b/tests/shared/src/main/scala/munit/Tags.scala index b7ed879f..1fa0c82d 100644 --- a/tests/shared/src/main/scala/munit/Tags.scala +++ b/tests/shared/src/main/scala/munit/Tags.scala @@ -2,4 +2,5 @@ package munit object OnlyJVM extends Tag("OnlyJVm") {} object NoDotty extends Tag("NoDotty") {} +object OnlyFromM3 extends Tag("OnlyFromM3") {} object Only213 extends Tag("Only213") {} diff --git a/tests/shared/src/test/scala/munit/AssertionsSuite.scala b/tests/shared/src/test/scala/munit/AssertionsSuite.scala index 57f98f38..83148fbf 100644 --- a/tests/shared/src/test/scala/munit/AssertionsSuite.scala +++ b/tests/shared/src/test/scala/munit/AssertionsSuite.scala @@ -8,7 +8,7 @@ class AssertionsSuite extends BaseSuite { cond: => Boolean, expected: String )(implicit loc: Location): Unit = - test(name.tag(NoDotty)) { + test(name.tag(OnlyFromM3)) { val (_, clues) = munitCaptureClues(cond) assertNoDiff(Printers.print(clues), expected) } diff --git a/tests/shared/src/test/scala/munit/BaseSuite.scala b/tests/shared/src/test/scala/munit/BaseSuite.scala index ba35cedf..a72b4134 100644 --- a/tests/shared/src/test/scala/munit/BaseSuite.scala +++ b/tests/shared/src/test/scala/munit/BaseSuite.scala @@ -15,6 +15,10 @@ class BaseSuite extends FunSuite { BuildInfo.scalaVersion.startsWith("2.13") || isDotty if (test.tags(NoDotty) && isDotty) { test.tag(Ignore) + } else if ( + test.tags(OnlyFromM3) && "3.0.0-M2" == BuildInfo.scalaVersion + ) { + test.tag(Ignore) } else if (test.tags(Only213) && !is213) { test.tag(Ignore) } else if (test.tags(OnlyJVM) && !PlatformCompat.isJVM) {