From df34422bcac351989ef8cc7d8f98fb205ff42788 Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Sat, 18 Nov 2023 11:59:37 +0100 Subject: [PATCH 1/4] Simplified test helper code This also avoids defining a `T.command` inside of a class which does not extend `mill.define.Module`. --- build.sc | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/build.sc b/build.sc index 54f7eda..4a52a95 100644 --- a/build.sc +++ b/build.sc @@ -175,42 +175,42 @@ object `native-mostly-static` extends ScalaJsCliMostlyStaticNativeImage object tests extends ScalaModule { def scalaVersion = scala213 - object test extends ScalaTests { + object test extends ScalaTests with TestModule.Munit { def ivyDeps = super.ivyDeps() ++ Seq( ivy"org.scalameta::munit:0.7.29", ivy"com.lihaoyi::os-lib:0.9.1", ivy"com.lihaoyi::pprint:0.8.1" ) - def testFramework = "munit.Framework" - - private final class TestHelper( - launcherTask: T[PathRef] - ) { - def test(args: String*) = { - val argsTask = T.task { - val launcher = launcherTask().path - val extraArgs = Seq( - s"-Dtest.scala-js-cli.path=$launcher", - s"-Dtest.scala-js-cli.scala-js-version=$scalaJsVersion" - ) - args ++ extraArgs - } - T.command { - testTask(argsTask, T.task(Seq.empty[String]))() - } + + def testHelper( + launcherTask: Task[PathRef], + args: Seq[String] + ): Task[(String, Seq[mill.testrunner.TestResult])] = { + val argsTask = T.task { + val launcher = launcherTask().path + val extraArgs = Seq( + s"-Dtest.scala-js-cli.path=$launcher", + s"-Dtest.scala-js-cli.scala-js-version=$scalaJsVersion" + ) + args ++ extraArgs } + testTask(argsTask, T.task(Seq.empty[String])) } - def test(args: String*) = - jvm(args: _*) - def jvm(args: String*) = - new TestHelper(cli.standaloneLauncher).test(args: _*) - def native(args: String*) = - new TestHelper(native0.nativeImage).test(args: _*) - def nativeStatic(args: String*) = - new TestHelper(`native-static`.nativeImage).test(args: _*) - def nativeMostlyStatic(args: String*) = - new TestHelper(`native-mostly-static`.nativeImage).test(args: _*) + override def test(args: String*) = jvm(args: _*) + + def jvm(args: String*): Command[(String, Seq[mill.testrunner.TestResult])] = T.command { + testHelper(cli.standaloneLauncher, args) + } + def native(args: String*) = T.command { + testHelper(native0.nativeImage, args) + } + def nativeStatic(args: String*) = T.command { + testHelper(`native-static`.nativeImage, args) + } + def nativeMostlyStatic(args: String*) = T.command { + testHelper(`native-mostly-static`.nativeImage, args) + } } } From 1cc90c1d541e4748dc3829a05910a86d5f7796ad Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Sat, 18 Nov 2023 13:33:43 +0100 Subject: [PATCH 2/4] Reuse upstream transitiveModuleDpes --- build.sc | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/build.sc b/build.sc index 4a52a95..9df587f 100644 --- a/build.sc +++ b/build.sc @@ -29,19 +29,8 @@ trait Cli extends ScalaModule with ScalaJsCliPublishModule { ) def mainClass = Some("org.scalajs.cli.Scalajsld") - def transitiveJars: T[Agg[PathRef]] = { - - def allModuleDeps(todo: List[JavaModule]): List[JavaModule] = { - todo match { - case Nil => Nil - case h :: t => - h :: allModuleDeps(h.moduleDeps.toList ::: t) - } - } - - T { - mill.define.Target.traverse(allModuleDeps(this :: Nil).distinct)(m => T.task(m.jar()))() - } + def transitiveJars: T[Seq[PathRef]] = T { + T.traverse(transitiveModuleDeps)(_.jar)() } def jarClassPath = T { @@ -112,7 +101,7 @@ trait ScalaJsCliNativeImage extends ScalaModule with NativeImage { def graalVmVersion = "22.3.3" def nativeImageGraalVmJvmId = s"graalvm-java17:$graalVmVersion" def nativeImageName = "scala-js-ld" - def moduleDeps() = Seq( + def moduleDeps = Seq( cli ) def compileIvyDeps = super.compileIvyDeps() ++ Seq( From ba312598b121d91ff0a22c51870108e10f7a892d Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Sat, 18 Nov 2023 20:42:22 +0100 Subject: [PATCH 3/4] Made some targets non-private This not only makes them accessible from the CLI, it also fixes an issue with Mill 0.11.{2-5}. See https://github.com/com-lihaoyi/mill/issues/2844 --- build.sc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sc b/build.sc index 9df587f..23d5d90 100644 --- a/build.sc +++ b/build.sc @@ -224,7 +224,7 @@ trait ScalaJsCliPublishModule extends PublishModule { finalPublishVersion() } -private def computePublishVersion(state: VcsState, simple: Boolean): String = +def computePublishVersion(state: VcsState, simple: Boolean): String = if (state.commitsSinceLastTag > 0) if (simple) { val versionOrEmpty = state.lastTag @@ -268,7 +268,7 @@ private def computePublishVersion(state: VcsState, simple: Boolean): String = .getOrElse(state.format()) .stripPrefix("v") -private def finalPublishVersion = { +def finalPublishVersion = { val isCI = System.getenv("CI") != null if (isCI) T.persistent { From 902f10920fffec38161fdd9591305ee48ef3b7c0 Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Sat, 18 Nov 2023 20:44:09 +0100 Subject: [PATCH 4/4] Update Mill to 0.11.5 --- .mill-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mill-version b/.mill-version index 027934e..62d5dbd 100644 --- a/.mill-version +++ b/.mill-version @@ -1 +1 @@ -0.11.1 \ No newline at end of file +0.11.5