diff --git a/scalafmt-tests/shared/src/test/scala/org/scalafmt/FormatTests.scala b/scalafmt-tests/shared/src/test/scala/org/scalafmt/FormatTests.scala index b6cb1a914..4af4c4658 100644 --- a/scalafmt-tests/shared/src/test/scala/org/scalafmt/FormatTests.scala +++ b/scalafmt-tests/shared/src/test/scala/org/scalafmt/FormatTests.scala @@ -42,7 +42,7 @@ class FormatTests extends FunSuite with CanRunTests with FormatAssertions { val runner = t.style.runner val result = Scalafmt.formatCode( t.original, - t.style.copy(runner = scalafmtRunner(runner, debug)), + t.style.copy(runner = HasTests.scalafmtRunner(runner, debug)), filename = t.filename, ) debug.printTest() @@ -90,7 +90,7 @@ class FormatTests extends FunSuite with CanRunTests with FormatAssertions { debug2Opt = Some(debug2) val result2 = Scalafmt.formatCode( obtained, - t.style.copy(runner = scalafmtRunner(runner, debug2)), + t.style.copy(runner = HasTests.scalafmtRunner(runner, debug2)), filename = t.filename, ) debug2.printTest() diff --git a/scalafmt-tests/shared/src/test/scala/org/scalafmt/util/HasTests.scala b/scalafmt-tests/shared/src/test/scala/org/scalafmt/util/HasTests.scala index 6855be2da..26a416695 100644 --- a/scalafmt-tests/shared/src/test/scala/org/scalafmt/util/HasTests.scala +++ b/scalafmt-tests/shared/src/test/scala/org/scalafmt/util/HasTests.scala @@ -27,22 +27,6 @@ import munit.Location trait HasTests extends FormatAssertions { import HasTests._ - import LoggerOps._ - - def scalafmtRunner(sr: ScalafmtRunner, dg: Debug): ScalafmtRunner = sr.copy( - debug = true, - maxStateVisits = sr.maxStateVisits.orElse(Some(150000)), - completeCallback = dg.completed, - eventCallback = { - case CreateFormatOps(ops) => dg.formatOps = ops - case Routes(routes) => dg.routes = routes - case explored: Explored if explored.n % 10000 == 0 => - logger.elem(explored) - case Enqueue(split) => dg.enqueued(split) - case x: Written => dg.locations = x.formatLocations - case _ => - }, - ) lazy val debugResults = mutable.ArrayBuilder.make[Result] val testDir = BuildInfo.resourceDirectory.toPath @@ -275,4 +259,19 @@ object HasTests { if (isPrefix(name, prefix)) Some(name.substring(prefix.length).trim) else None + def scalafmtRunner(sr: ScalafmtRunner, dg: Debug): ScalafmtRunner = sr.copy( + debug = true, + maxStateVisits = sr.maxStateVisits.orElse(Some(150000)), + completeCallback = dg.completed, + eventCallback = { + case CreateFormatOps(ops) => dg.formatOps = ops + case Routes(routes) => dg.routes = routes + case explored: Explored if explored.n % 10000 == 0 => + org.scalafmt.util.LoggerOps.logger.elem(explored) + case Enqueue(split) => dg.enqueued(split) + case x: Written => dg.locations = x.formatLocations + case _ => + }, + ) + }