From a955fe5389a6ee33c354d0d023fcc40e10fc46e4 Mon Sep 17 00:00:00 2001 From: Katarzyna Marek Date: Fri, 30 Jun 2023 15:53:03 +0100 Subject: [PATCH] get more info from mill test --- .../scala/tests/mill/MillServerSuite.scala | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/tests/slow/src/test/scala/tests/mill/MillServerSuite.scala b/tests/slow/src/test/scala/tests/mill/MillServerSuite.scala index 77932628391..aae4a50a465 100644 --- a/tests/slow/src/test/scala/tests/mill/MillServerSuite.scala +++ b/tests/slow/src/test/scala/tests/mill/MillServerSuite.scala @@ -1,6 +1,8 @@ package tests.mill import scala.concurrent.Promise +import scala.util.Failure +import scala.util.Success import scala.meta.internal.builds.MillBuildTool import scala.meta.internal.builds.MillDigest @@ -24,13 +26,43 @@ class MillServerSuite val supportedBspVersion = V.millVersion val scalaVersion = V.scala213 val buildTool: MillBuildTool = MillBuildTool(() => userConfig) + def bspTrace: AbsolutePath = + workspace.resolve(".metals").resolve("bsp.trace.json") override def currentDigest( workspace: AbsolutePath ): Option[String] = MillDigest.current(workspace) - test("too-old") { + override def beforeEach(context: BeforeEach): Unit = { + super.beforeEach(context) cleanWorkspace() + bspTrace.writeText("") + } + + private def logBspTraces(): Option[Unit] = + bspTrace.readTextOpt.map(trace => scribe.warn(s"""|BSP trace: + |$trace + |""".stripMargin)) + + override def munitTestTransforms: List[TestTransform] = + super.munitTestTransforms :+ + new TestTransform( + "Print BSP traces", + { test => + test.withBody(() => + test + .body() + .andThen { + case Failure(exception) => + logBspTraces() + exception + case Success(value) => value + }(munitExecutionContext) + ) + }, + ) + + test("too-old") { writeLayout(MillBuildLayout("", V.scala213, preBspVersion)) for { _ <- server.initialize() @@ -59,7 +91,6 @@ class MillServerSuite private def testGenerationAndConnection(version: String) = { test(s"generate-and-connect-$version") { def millBspConfig = workspace.resolve(".bsp/mill-bsp.json") - cleanWorkspace() writeLayout(MillBuildLayout("", V.scala213, version)) for { _ <- server.initialize()