Skip to content

Commit

Permalink
Update munit to 1.0.2 (#3176)
Browse files Browse the repository at this point in the history
* Update munit to 1.0.2

* Fix errors tied to `munit` 1.0.2 location paths changing from absolute to relative

---------

Co-authored-by: Piotr Chabelski <[email protected]>
  • Loading branch information
scala-steward and Gedochao authored Sep 18, 2024
1 parent 793f91c commit 0593e4c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ abstract class BuildTests(server: Boolean) extends TestUtil.ScalaCliBuildSuite {

test("cli dependency options shadowing using directives") {
val usingDependency = "org.scalameta::munit::1.0.0-M1"
val cliDependency = "org.scalameta::munit::1.0.1"
val cliDependency = "org.scalameta::munit::1.0.2"

val inputs = TestInputs(
os.rel / "foo.scala" ->
Expand Down
14 changes: 12 additions & 2 deletions modules/build/src/test/scala/scala/build/tests/TestUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,30 @@ import java.util.concurrent.TimeUnit
import scala.concurrent.duration.FiniteDuration

object TestUtil {

abstract class ScalaCliBuildSuite extends munit.FunSuite {
extension (munitContext: BeforeEach | AfterEach) {
def locationAbsolutePath: os.Path =
os.pwd / os.RelPath {
(munitContext match {
case beforeEach: BeforeEach => beforeEach.test
case afterEach: AfterEach => afterEach.test
}).location.path
}
}
override def munitTimeout = new FiniteDuration(120, TimeUnit.SECONDS)
val testStartEndLogger = new Fixture[Unit]("files") {
def apply(): Unit = ()

override def beforeEach(context: BeforeEach): Unit = {
val fileName = os.Path(context.test.location.path).baseName
val fileName = context.locationAbsolutePath.baseName
System.err.println(
s">==== ${Console.CYAN}Running '${context.test.name}' from $fileName${Console.RESET}"
)
}

override def afterEach(context: AfterEach): Unit = {
val fileName = os.Path(context.test.location.path).baseName
val fileName = context.locationAbsolutePath.baseName
System.err.println(
s"X==== ${Console.CYAN}Finishing '${context.test.name}' from $fileName${Console.RESET}"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,25 @@ import java.util.concurrent.TimeUnit
import scala.concurrent.duration.{Duration, FiniteDuration}

abstract class ScalaCliSuite extends munit.FunSuite {
val testStartEndLogger = new Fixture[Unit]("files") {
implicit class BeforeEachOpts(munitContext: BeforeEach) {
def locationAbsolutePath: os.Path = os.pwd / os.RelPath(munitContext.test.location.path)
}

implicit class AfterEachOpts(munitContext: AfterEach) {
def locationAbsolutePath: os.Path = os.pwd / os.RelPath(munitContext.test.location.path)
}
val testStartEndLogger: Fixture[Unit] = new Fixture[Unit]("files") {
def apply(): Unit = ()

override def beforeEach(context: BeforeEach): Unit = {
val fileName = os.Path(context.test.location.path).baseName
val fileName = context.locationAbsolutePath.baseName
System.err.println(
s">==== ${Console.CYAN}Running '${context.test.name}' from $fileName${Console.RESET}"
)
}

override def afterEach(context: AfterEach): Unit = {
val fileName = os.Path(context.test.location.path).baseName
val fileName = context.locationAbsolutePath.baseName
System.err.println(
s"X==== ${Console.CYAN}Finishing '${context.test.name}' from $fileName${Console.RESET}"
)
Expand Down
2 changes: 1 addition & 1 deletion project/deps.sc
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ object Deps {
def metaconfigTypesafe =
ivy"org.scalameta::metaconfig-typesafe-config:0.13.0"
.exclude(("org.scala-lang", "scala-compiler"))
def munit = ivy"org.scalameta::munit:1.0.1"
def munit = ivy"org.scalameta::munit:1.0.2"
def nativeTestRunner = ivy"org.scala-native::test-runner:${Versions.scalaNative}"
def nativeTools = ivy"org.scala-native::tools:${Versions.scalaNative}"
def osLib = ivy"com.lihaoyi::os-lib:0.10.6"
Expand Down

0 comments on commit 0593e4c

Please sign in to comment.