From f60c6e032c8312a5b9a330db879ce4f58d996c33 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 4 Sep 2024 20:06:20 +0800 Subject: [PATCH 01/60] . --- build.mill | 2 +- main/client/src/mill/main/client/CodeGenConstants.java | 6 +++--- .../linenumbers/src/mill/linenumbers/LineNumberPlugin.scala | 2 +- scalalib/src/mill/scalalib/Lib.scala | 2 +- scalalib/src/mill/scalalib/scalafmt/ScalafmtModule.scala | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build.mill b/build.mill index ca4043efb91..1a02d6470eb 100644 --- a/build.mill +++ b/build.mill @@ -151,7 +151,7 @@ object Deps { val log4j2Core = ivy"org.apache.logging.log4j:log4j-core:2.23.1" val osLib = ivy"com.lihaoyi::os-lib:0.10.5" val pprint = ivy"com.lihaoyi::pprint:0.9.0" - val mainargs = ivy"com.lihaoyi::mainargs:0.7.2" + val mainargs = ivy"com.lihaoyi::mainargs:0.7.4" val millModuledefsVersion = "0.11.0-M2" val millModuledefsString = s"com.lihaoyi::mill-moduledefs:${millModuledefsVersion}" val millModuledefs = ivy"${millModuledefsString}" diff --git a/main/client/src/mill/main/client/CodeGenConstants.java b/main/client/src/mill/main/client/CodeGenConstants.java index 1245cfc75ff..19b347a69a9 100644 --- a/main/client/src/mill/main/client/CodeGenConstants.java +++ b/main/client/src/mill/main/client/CodeGenConstants.java @@ -21,17 +21,17 @@ public class CodeGenConstants { /** * The name of the root build file */ - final public static String[] rootBuildFileNames = {"build.mill", "build.sc"}; + final public static String[] rootBuildFileNames = {"build.mill.sc", "build.sc"}; /** * The name of any sub-folder build files */ - final public static String[] nestedBuildFileNames = {"package.mill", "package.sc"}; + final public static String[] nestedBuildFileNames = {"package.mill.sc", "package.sc"}; /** * The extensions used by build files */ - final public static String[] buildFileExtensions = {"mill", "sc"}; + final public static String[] buildFileExtensions = {"mill.sc", "sc"}; /** * The user-facing name for the root of the module tree. diff --git a/runner/linenumbers/src/mill/linenumbers/LineNumberPlugin.scala b/runner/linenumbers/src/mill/linenumbers/LineNumberPlugin.scala index 591023f796c..b8f0aeee877 100644 --- a/runner/linenumbers/src/mill/linenumbers/LineNumberPlugin.scala +++ b/runner/linenumbers/src/mill/linenumbers/LineNumberPlugin.scala @@ -30,7 +30,7 @@ class LineNumberPlugin(val global: Global) extends Plugin { object LineNumberPlugin { def apply(g: Global)(unit: g.CompilationUnit): Unit = { - if (buildFileExtensions.exists(g.currentSource.file.hasExtension(_))) { + if (buildFileExtensions.exists(ex => g.currentSource.file.name.endsWith(s".$ex"))) { val str = new String(g.currentSource.content) val lines = str.linesWithSeparators.toVector diff --git a/scalalib/src/mill/scalalib/Lib.scala b/scalalib/src/mill/scalalib/Lib.scala index 556f138a01d..830f3397ee7 100644 --- a/scalalib/src/mill/scalalib/Lib.scala +++ b/scalalib/src/mill/scalalib/Lib.scala @@ -132,7 +132,7 @@ object Lib { root <- sources if os.exists(root.path) path <- (if (os.isDir(root.path)) os.walk(root.path) else Seq(root.path)) - if os.isFile(path) && (extensions.exists(path.ext == _) && !isHiddenFile(path)) + if os.isFile(path) && (extensions.exists(ex => path.last.endsWith(s".$ex")) && !isHiddenFile(path)) } yield path } diff --git a/scalalib/src/mill/scalalib/scalafmt/ScalafmtModule.scala b/scalalib/src/mill/scalalib/scalafmt/ScalafmtModule.scala index f10a0595bc6..5733057c0bb 100644 --- a/scalalib/src/mill/scalalib/scalafmt/ScalafmtModule.scala +++ b/scalalib/src/mill/scalalib/scalafmt/ScalafmtModule.scala @@ -57,7 +57,7 @@ trait ScalafmtModule extends JavaModule { file <- { if (os.isDir(pathRef.path)) { os.walk(pathRef.path).filter(file => - os.isFile(file) && (file.ext == "scala" || buildFileExtensions.contains(file.ext)) + os.isFile(file) && (file.ext == "scala" || buildFileExtensions.exists(ex => file.last.endsWith(s".$ex"))) ) } else { Seq(pathRef.path) From 46a7fbf83dfc9e36c2bfa92f913b9bc2167bd5ff Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 4 Sep 2024 20:07:11 +0800 Subject: [PATCH 02/60] . --- main/client/src/mill/main/client/CodeGenConstants.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main/client/src/mill/main/client/CodeGenConstants.java b/main/client/src/mill/main/client/CodeGenConstants.java index 19b347a69a9..71136e2d1dd 100644 --- a/main/client/src/mill/main/client/CodeGenConstants.java +++ b/main/client/src/mill/main/client/CodeGenConstants.java @@ -21,17 +21,17 @@ public class CodeGenConstants { /** * The name of the root build file */ - final public static String[] rootBuildFileNames = {"build.mill.sc", "build.sc"}; + final public static String[] rootBuildFileNames = {"build.mill", "build.mill.sc", "build.sc"}; /** * The name of any sub-folder build files */ - final public static String[] nestedBuildFileNames = {"package.mill.sc", "package.sc"}; + final public static String[] nestedBuildFileNames = {"package.mill", "package.mill.sc", "package.sc"}; /** * The extensions used by build files */ - final public static String[] buildFileExtensions = {"mill.sc", "sc"}; + final public static String[] buildFileExtensions = {"mill", "mill.sc", "sc"}; /** * The user-facing name for the root of the module tree. From d2995500376728a71ef56ccf10a28ca28580fdef Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 4 Sep 2024 20:21:21 +0800 Subject: [PATCH 03/60] . --- .../depth/large/11-helper-files/build.mill | 4 +- .../13-helper-files-mill-sc/build.mill.sc | 39 +++++++++++++++++++ .../foo/package.mill.sc | 10 +++++ .../13-helper-files-mill-sc/foo/src/Foo.scala | 8 ++++ .../foo/versions.mill.sc | 3 ++ .../13-helper-files-mill-sc/src/Main.scala | 6 +++ .../13-helper-files-mill-sc/util.mill.sc | 9 +++++ mill-build/src/ExampleParser.scala | 2 +- runner/src/mill/runner/CodeGen.scala | 7 ++-- runner/src/mill/runner/FileImportGraph.scala | 11 ++++-- .../src/mill/runner/MillBuildRootModule.scala | 2 + 11 files changed, 91 insertions(+), 10 deletions(-) create mode 100644 example/depth/large/13-helper-files-mill-sc/build.mill.sc create mode 100644 example/depth/large/13-helper-files-mill-sc/foo/package.mill.sc create mode 100644 example/depth/large/13-helper-files-mill-sc/foo/src/Foo.scala create mode 100644 example/depth/large/13-helper-files-mill-sc/foo/versions.mill.sc create mode 100644 example/depth/large/13-helper-files-mill-sc/src/Main.scala create mode 100644 example/depth/large/13-helper-files-mill-sc/util.mill.sc diff --git a/example/depth/large/11-helper-files/build.mill b/example/depth/large/11-helper-files/build.mill index 870877156a6..9692e3f74c6 100644 --- a/example/depth/large/11-helper-files/build.mill +++ b/example/depth/large/11-helper-files/build.mill @@ -8,8 +8,8 @@ object `package` extends RootModule with MyModule{ "MY_PROJECT_VERSION" -> versions.myProjectVersion, ) } -///** See Also: util.sc */ -///** See Also: foo/package */ +///** See Also: util.mill */ +///** See Also: foo/package.mill */ ///** See Also: foo/versions.mill */ diff --git a/example/depth/large/13-helper-files-mill-sc/build.mill.sc b/example/depth/large/13-helper-files-mill-sc/build.mill.sc new file mode 100644 index 00000000000..7a757d7b0ba --- /dev/null +++ b/example/depth/large/13-helper-files-mill-sc/build.mill.sc @@ -0,0 +1,39 @@ +package build +import mill._, scalalib._ +import $file.foo.versions +import $file.util.MyModule +object `package` extends RootModule with MyModule{ + def forkEnv = Map( + "MY_SCALA_VERSION" -> build.scalaVersion(), + "MY_PROJECT_VERSION" -> versions.myProjectVersion, + ) +} +///** See Also: util.mill.sc */ +///** See Also: foo/package.mill.sc */ +///** See Also: foo/versions.mill.sc */ + + +// Apart from having `package` files in subfolders to define modules, Mill +// also allows you to have helper code in any `*.mill` file in the same folder +// as your `build.mill` or a `package.mill`. +// +// Different helper scripts and ``build.mill``/``package`` files can all refer to +// each other using the `build` object, which marks the root object of your build. +// In this example: +// +// * `build.mill` can be referred to as simple `build` +// * `util.mill` can be referred to as simple `$file.util` +// * `foo/package` can be referred to as simple `build.foo` +// * `foo/versions.mill` can be referred to as simple `$file.foo.versions` + +/** Usage + +> ./mill run +Main Env build.util.myScalaVersion: 2.13.14 +Main Env build.foo.versions.myProjectVersion: 0.0.1 + +> ./mill foo.run +Foo Env build.util.myScalaVersion: 2.13.14 +Foo Env build.foo.versions.myProjectVersion: 0.0.1 + +*/ diff --git a/example/depth/large/13-helper-files-mill-sc/foo/package.mill.sc b/example/depth/large/13-helper-files-mill-sc/foo/package.mill.sc new file mode 100644 index 00000000000..a28fe0a29ce --- /dev/null +++ b/example/depth/large/13-helper-files-mill-sc/foo/package.mill.sc @@ -0,0 +1,10 @@ +package build.foo +import mill._, scalalib._ +import $file.util +import $file.foo.versions.myProjectVersion +object `package` extends RootModule with build_.util.MyModule { + def forkEnv = Map( + "MY_SCALA_VERSION" -> util.myScalaVersion, + "MY_PROJECT_VERSION" -> myProjectVersion + ) +} diff --git a/example/depth/large/13-helper-files-mill-sc/foo/src/Foo.scala b/example/depth/large/13-helper-files-mill-sc/foo/src/Foo.scala new file mode 100644 index 00000000000..08fe8028aac --- /dev/null +++ b/example/depth/large/13-helper-files-mill-sc/foo/src/Foo.scala @@ -0,0 +1,8 @@ +package foo + +object Foo { + def main(args: Array[String]): Unit = { + println("Foo Env build.util.myScalaVersion: " + sys.env("MY_SCALA_VERSION")) + println("Foo Env build.foo.versions.myProjectVersion: " + sys.env("MY_PROJECT_VERSION")) + } +} diff --git a/example/depth/large/13-helper-files-mill-sc/foo/versions.mill.sc b/example/depth/large/13-helper-files-mill-sc/foo/versions.mill.sc new file mode 100644 index 00000000000..d2d0681b67c --- /dev/null +++ b/example/depth/large/13-helper-files-mill-sc/foo/versions.mill.sc @@ -0,0 +1,3 @@ +package build.foo + +def myProjectVersion = "0.0.1" \ No newline at end of file diff --git a/example/depth/large/13-helper-files-mill-sc/src/Main.scala b/example/depth/large/13-helper-files-mill-sc/src/Main.scala new file mode 100644 index 00000000000..f8e6fdfa68f --- /dev/null +++ b/example/depth/large/13-helper-files-mill-sc/src/Main.scala @@ -0,0 +1,6 @@ +object Main { + def main(args: Array[String]): Unit = { + println("Main Env build.util.myScalaVersion: " + sys.env("MY_SCALA_VERSION")) + println("Main Env build.foo.versions.myProjectVersion: " + sys.env("MY_PROJECT_VERSION")) + } +} diff --git a/example/depth/large/13-helper-files-mill-sc/util.mill.sc b/example/depth/large/13-helper-files-mill-sc/util.mill.sc new file mode 100644 index 00000000000..0e4b102796e --- /dev/null +++ b/example/depth/large/13-helper-files-mill-sc/util.mill.sc @@ -0,0 +1,9 @@ +package build + +import mill._, scalalib._ + +def myScalaVersion = "2.13.14" + +trait MyModule extends ScalaModule { + def scalaVersion = myScalaVersion +} diff --git a/mill-build/src/ExampleParser.scala b/mill-build/src/ExampleParser.scala index 55db14aa90a..39988ee2a86 100644 --- a/mill-build/src/ExampleParser.scala +++ b/mill-build/src/ExampleParser.scala @@ -6,7 +6,7 @@ object ExampleParser { val states = collection.mutable.Buffer("scala") val chunks = collection.mutable.Buffer(collection.mutable.Buffer.empty[String]) - val rootBuildFileNames = Seq("build.sc", "build.mill") + val rootBuildFileNames = Seq("build.sc", "build.mill", "build.mill.sc") val buildFile = rootBuildFileNames.map(testRepoRoot / _).find(os.exists) for (line <- os.read.lines(buildFile.get)) { val (newState, restOpt) = line match { diff --git a/runner/src/mill/runner/CodeGen.scala b/runner/src/mill/runner/CodeGen.scala index 3e8c64c4fe5..afb4a6e3395 100644 --- a/runner/src/mill/runner/CodeGen.scala +++ b/runner/src/mill/runner/CodeGen.scala @@ -17,6 +17,7 @@ object CodeGen { enclosingClasspath: Seq[os.Path], millTopLevelProjectRoot: os.Path ): Unit = { + println("generateScriptSources C") for (scriptSource <- scriptSources) { // pprint.log(scriptSource) val scriptPath = scriptSource.path @@ -25,11 +26,11 @@ object CodeGen { val isBuildScript = specialNames(scriptPath.last) val scriptFolderPath = scriptPath / os.up - if (scriptFolderPath == projectRoot && scriptPath.baseName == "package") { + if (scriptFolderPath == projectRoot && scriptPath.last.split('.').head == "package") { throw Result.Failure(s"Mill ${scriptPath.last} files can only be in subfolders") } - if (scriptFolderPath != projectRoot && scriptPath.baseName == "build") { + if (scriptFolderPath != projectRoot && scriptPath.last.split('.').head == "build") { throw Result.Failure(s"Mill ${scriptPath.last} files can only be in the project root") } @@ -86,7 +87,7 @@ object CodeGen { if (!isBuildScript) { s"""$pkgLine |$aliasImports - |object ${backtickWrap(scriptPath.baseName)} { + |object ${backtickWrap(scriptPath.last.split('.').head)} { |$markerComment |$scriptCode |}""".stripMargin diff --git a/runner/src/mill/runner/FileImportGraph.scala b/runner/src/mill/runner/FileImportGraph.scala index 89199a69f3b..045359f7337 100644 --- a/runner/src/mill/runner/FileImportGraph.scala +++ b/runner/src/mill/runner/FileImportGraph.scala @@ -52,6 +52,7 @@ object FileImportGraph { def processScript(s: os.Path, useDummy: Boolean = false): Unit = { + pprint.log(s) val readFileEither = scala.util.Try { val content = if (useDummy) "" else os.read(s) val fileName = s.relativeTo(topLevelProjectRoot).toString @@ -67,7 +68,7 @@ object FileImportGraph { val expectedImportSegments = expectedImportSegments0.map(backtickWrap).mkString(".") if ( // Legacy `.sc` files have their package build be optional - s.ext == "mill" && + s.last.endsWith(".mill") || s.last.endsWith(".mill.sc") && expectedImportSegments != importSegments && // Root build.mill file has its `package build` be optional !(importSegments == "" && rootBuildFileNames.contains(s.last)) @@ -137,7 +138,7 @@ object FileImportGraph { case ImportTree(Seq(("$file", end0), rest @ _*), mapping, start, end) => // Only recursively explore imports from legacy `.sc` files, as new `.mill` files // do file discovery via scanning folders containing `package.mill` files - if (s.ext == "sc") { + if (s.last.endsWith(".sc") && !s.last.endsWith(".mill.sc")) { val nextPaths = mapping.map { case (lhs, rhs) => nextPathFor(s, rest.map(_._1) :+ lhs) } @@ -167,7 +168,7 @@ object FileImportGraph { val useDummy = rootBuildFiles.isEmpty val foundRootBuildFileName: String = rootBuildFiles.getOrElse(rootBuildFileNames.head) - val buildFileExtension = buildFileExtensions.find(foundRootBuildFileName.endsWith).get + val buildFileExtension = buildFileExtensions.find(ex => foundRootBuildFileName.endsWith(s".$ex")).get val nestedBuildFileName = nestedBuildFileNames.find(_.endsWith(buildFileExtension)).get processScript(projectRoot / foundRootBuildFileName, useDummy) @@ -184,8 +185,10 @@ object FileImportGraph { val adjacentScripts = (projectRoot +: buildFiles.map(_ / os.up)) .flatMap(os.list(_)) - .filter(_.ext == buildFileExtension) + .filter(_.last.endsWith(s".$buildFileExtension")) + pprint.log(buildFiles) + pprint.log(adjacentScripts) (buildFiles ++ adjacentScripts).foreach(processScript(_)) new FileImportGraph( diff --git a/runner/src/mill/runner/MillBuildRootModule.scala b/runner/src/mill/runner/MillBuildRootModule.scala index f09a50583df..40a230814b5 100644 --- a/runner/src/mill/runner/MillBuildRootModule.scala +++ b/runner/src/mill/runner/MillBuildRootModule.scala @@ -111,7 +111,9 @@ class MillBuildRootModule()(implicit } def generateScriptSources: T[Seq[PathRef]] = T { + println("generateScriptSources A") val parsed = parseBuildFiles() + println("generateScriptSources B") if (parsed.errors.nonEmpty) Result.Failure(parsed.errors.mkString("\n")) else { CodeGen.generateWrappedSources( From 90f5d61c7edd14a21d1ecaf8d67ae47711aae9cb Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 4 Sep 2024 21:13:53 +0800 Subject: [PATCH 04/60] . --- runner/src/mill/runner/CodeGen.scala | 2 -- runner/src/mill/runner/FileImportGraph.scala | 6 +----- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/runner/src/mill/runner/CodeGen.scala b/runner/src/mill/runner/CodeGen.scala index afb4a6e3395..714f337862b 100644 --- a/runner/src/mill/runner/CodeGen.scala +++ b/runner/src/mill/runner/CodeGen.scala @@ -17,9 +17,7 @@ object CodeGen { enclosingClasspath: Seq[os.Path], millTopLevelProjectRoot: os.Path ): Unit = { - println("generateScriptSources C") for (scriptSource <- scriptSources) { - // pprint.log(scriptSource) val scriptPath = scriptSource.path val specialNames = (nestedBuildFileNames ++ rootBuildFileNames).toSet diff --git a/runner/src/mill/runner/FileImportGraph.scala b/runner/src/mill/runner/FileImportGraph.scala index 045359f7337..035f53be4e7 100644 --- a/runner/src/mill/runner/FileImportGraph.scala +++ b/runner/src/mill/runner/FileImportGraph.scala @@ -51,8 +51,6 @@ object FileImportGraph { var millImport = false def processScript(s: os.Path, useDummy: Boolean = false): Unit = { - - pprint.log(s) val readFileEither = scala.util.Try { val content = if (useDummy) "" else os.read(s) val fileName = s.relativeTo(topLevelProjectRoot).toString @@ -68,7 +66,7 @@ object FileImportGraph { val expectedImportSegments = expectedImportSegments0.map(backtickWrap).mkString(".") if ( // Legacy `.sc` files have their package build be optional - s.last.endsWith(".mill") || s.last.endsWith(".mill.sc") && + (s.last.endsWith(".mill") || s.last.endsWith(".mill.sc")) && expectedImportSegments != importSegments && // Root build.mill file has its `package build` be optional !(importSegments == "" && rootBuildFileNames.contains(s.last)) @@ -187,8 +185,6 @@ object FileImportGraph { .flatMap(os.list(_)) .filter(_.last.endsWith(s".$buildFileExtension")) - pprint.log(buildFiles) - pprint.log(adjacentScripts) (buildFiles ++ adjacentScripts).foreach(processScript(_)) new FileImportGraph( From d4d2ebd4799f6413cc353843e756eb3fd2e9aeed Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 4 Sep 2024 21:33:35 +0800 Subject: [PATCH 05/60] . --- runner/src/mill/runner/FileImportGraph.scala | 3 ++- scalalib/src/mill/scalalib/Lib.scala | 4 +++- scalalib/src/mill/scalalib/scalafmt/ScalafmtModule.scala | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/runner/src/mill/runner/FileImportGraph.scala b/runner/src/mill/runner/FileImportGraph.scala index 035f53be4e7..a0358caaae0 100644 --- a/runner/src/mill/runner/FileImportGraph.scala +++ b/runner/src/mill/runner/FileImportGraph.scala @@ -166,7 +166,8 @@ object FileImportGraph { val useDummy = rootBuildFiles.isEmpty val foundRootBuildFileName: String = rootBuildFiles.getOrElse(rootBuildFileNames.head) - val buildFileExtension = buildFileExtensions.find(ex => foundRootBuildFileName.endsWith(s".$ex")).get + val buildFileExtension = + buildFileExtensions.find(ex => foundRootBuildFileName.endsWith(s".$ex")).get val nestedBuildFileName = nestedBuildFileNames.find(_.endsWith(buildFileExtension)).get processScript(projectRoot / foundRootBuildFileName, useDummy) diff --git a/scalalib/src/mill/scalalib/Lib.scala b/scalalib/src/mill/scalalib/Lib.scala index 830f3397ee7..664cf7f52be 100644 --- a/scalalib/src/mill/scalalib/Lib.scala +++ b/scalalib/src/mill/scalalib/Lib.scala @@ -132,7 +132,9 @@ object Lib { root <- sources if os.exists(root.path) path <- (if (os.isDir(root.path)) os.walk(root.path) else Seq(root.path)) - if os.isFile(path) && (extensions.exists(ex => path.last.endsWith(s".$ex")) && !isHiddenFile(path)) + if os.isFile(path) && (extensions.exists(ex => path.last.endsWith(s".$ex")) && !isHiddenFile( + path + )) } yield path } diff --git a/scalalib/src/mill/scalalib/scalafmt/ScalafmtModule.scala b/scalalib/src/mill/scalalib/scalafmt/ScalafmtModule.scala index 5733057c0bb..f28a17624ea 100644 --- a/scalalib/src/mill/scalalib/scalafmt/ScalafmtModule.scala +++ b/scalalib/src/mill/scalalib/scalafmt/ScalafmtModule.scala @@ -57,7 +57,9 @@ trait ScalafmtModule extends JavaModule { file <- { if (os.isDir(pathRef.path)) { os.walk(pathRef.path).filter(file => - os.isFile(file) && (file.ext == "scala" || buildFileExtensions.exists(ex => file.last.endsWith(s".$ex"))) + os.isFile(file) && (file.ext == "scala" || buildFileExtensions.exists(ex => + file.last.endsWith(s".$ex") + )) ) } else { Seq(pathRef.path) From 8d4c7814c473b7faaff91829c7600acdf04353dd Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 4 Sep 2024 22:39:08 +0800 Subject: [PATCH 06/60] . --- runner/src/mill/runner/FileImportGraph.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runner/src/mill/runner/FileImportGraph.scala b/runner/src/mill/runner/FileImportGraph.scala index a0358caaae0..fae30b35174 100644 --- a/runner/src/mill/runner/FileImportGraph.scala +++ b/runner/src/mill/runner/FileImportGraph.scala @@ -168,7 +168,8 @@ object FileImportGraph { val buildFileExtension = buildFileExtensions.find(ex => foundRootBuildFileName.endsWith(s".$ex")).get - val nestedBuildFileName = nestedBuildFileNames.find(_.endsWith(buildFileExtension)).get + + val nestedBuildFileName = s"package.$buildFileExtension" processScript(projectRoot / foundRootBuildFileName, useDummy) val buildFiles = os From fd98b5f13a623b030f354d2290618fc2cd716c5b Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Wed, 4 Sep 2024 22:41:20 +0800 Subject: [PATCH 07/60] . --- runner/src/mill/runner/MillBuildRootModule.scala | 2 -- 1 file changed, 2 deletions(-) diff --git a/runner/src/mill/runner/MillBuildRootModule.scala b/runner/src/mill/runner/MillBuildRootModule.scala index 40a230814b5..f09a50583df 100644 --- a/runner/src/mill/runner/MillBuildRootModule.scala +++ b/runner/src/mill/runner/MillBuildRootModule.scala @@ -111,9 +111,7 @@ class MillBuildRootModule()(implicit } def generateScriptSources: T[Seq[PathRef]] = T { - println("generateScriptSources A") val parsed = parseBuildFiles() - println("generateScriptSources B") if (parsed.errors.nonEmpty) Result.Failure(parsed.errors.mkString("\n")) else { CodeGen.generateWrappedSources( From 5ce35397b6824292cc3aa27586d5ddc80a0366b6 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 13:00:04 +0800 Subject: [PATCH 08/60] . --- example/javalib/web/4-hello-micronaut/build.mill | 2 +- example/javalib/web/5-todo-micronaut/build.mill | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/example/javalib/web/4-hello-micronaut/build.mill b/example/javalib/web/4-hello-micronaut/build.mill index 3dba9169676..ff6ffb67a54 100644 --- a/example/javalib/web/4-hello-micronaut/build.mill +++ b/example/javalib/web/4-hello-micronaut/build.mill @@ -69,7 +69,7 @@ trait MicronautModule extends MavenModule{ > mill test ...example.micronaut.HelloControllerTest#testHello()... -> mill runBackground; sleep 2 # give time for server to start +> mill runBackground; sleep 5 # give time for server to start > curl http://localhost:8088/hello ...Hello World... diff --git a/example/javalib/web/5-todo-micronaut/build.mill b/example/javalib/web/5-todo-micronaut/build.mill index d2b4c180ffe..a81c48a5b88 100644 --- a/example/javalib/web/5-todo-micronaut/build.mill +++ b/example/javalib/web/5-todo-micronaut/build.mill @@ -90,7 +90,7 @@ trait MicronautModule extends MavenModule{ ...example.micronaut.TodoItemControllerTest... ...example.micronaut.HtmxWebJarsTest... -> mill runBackground; sleep 2 # give time for server to start +> mill runBackground; sleep 5 # give time for server to start > curl http://localhost:8088 ...

todos

... From dde2b8f5d03c09bb0f62df15e9d631cc9cbcf462 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 13:02:12 +0800 Subject: [PATCH 09/60] . --- .../invalidation/src/ScriptsInvalidationTests.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala b/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala index ee3d42890d0..23a772beb07 100644 --- a/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala +++ b/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala @@ -80,16 +80,17 @@ object ScriptsInvalidationTests extends IntegrationTestSuite { } } test("should handle ammonite ^ imports") { - test("first run") { + retry(3) { + // first run initWorkspace() val result = runTask("taskE") val expected = Set("a", "e", "taskE") assert(result == expected) - } - test("second run modifying script") { + + // second run modifying script modifyFile( workspacePath / "build.mill", _.replace("""println("taskE")""", """System.out.println("taskE2")""") From 4f271ad2d758cfcf50debfc9b9c2d1ce3d605ee6 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 13:28:43 +0800 Subject: [PATCH 10/60] . --- .github/workflows/run-mill-action.yml | 2 +- .../invalidation/src/ScriptsInvalidationTests.scala | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index 9fef5b49d4e..1e847c6df2d 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -60,5 +60,5 @@ jobs: if: inputs.millargs != '' && !startsWith(inputs.os, 'windows') - name: Run Mill (on Windows) '${{ inputs.millargs }}' - run: cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -i -d -k ${{ inputs.millargs }} + run: cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -ij1 __.resolvedIvyDeps; cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -i -d -k ${{ inputs.millargs }} if: inputs.millargs != '' && startsWith(inputs.os, 'windows') \ No newline at end of file diff --git a/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala b/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala index 23a772beb07..9d6b3afbd82 100644 --- a/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala +++ b/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala @@ -89,17 +89,16 @@ object ScriptsInvalidationTests extends IntegrationTestSuite { assert(result == expected) - // second run modifying script modifyFile( workspacePath / "build.mill", _.replace("""println("taskE")""", """System.out.println("taskE2")""") ) - val result = runTask("taskE") - val expected = Set("taskE2") + val result2 = runTask("taskE") + val expected2 = Set("taskE2") - assert(result == expected) + assert(result2 == expected2) } } test("should handle ammonite paths with symbols") { From 680f48247eb2c2fb2866c2202aea320a2abd95a5 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 13:37:44 +0800 Subject: [PATCH 11/60] . --- .github/workflows/actions.yml | 14 +++++++++++++- .github/workflows/run-mill-action.yml | 15 +++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 162cc87bed7..2ac0675ec62 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -28,7 +28,19 @@ concurrency: cancel-in-progress: true jobs: - + build-linux: + uses: ./.github/workflows/run-mill-action.yml + with: + java-version: 11 + millargs: __.compile + populate_cache: true + build-windows: + uses: ./.github/workflows/run-mill-action.yml + with: + os: windows-latest + java-version: 11 + millargs: __.compile + populate_cache: true itest: strategy: fail-fast: false diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index 1e847c6df2d..ca1319697cd 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -18,6 +18,9 @@ on: continue-on-error: default: false type: boolean + populate_cache: + default: false + type: boolean timeout-minutes: default: 60 type: number @@ -35,9 +38,8 @@ jobs: MILL_COMPILER_BRIDGE_VERSIONS: ${{ inputs.env-bridge-versions }} steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 + - uses: actions/download-artifact@v4 + if: ${{ !inputs.populate_cache }} - uses: coursier/cache-action@v6 @@ -61,4 +63,9 @@ jobs: - name: Run Mill (on Windows) '${{ inputs.millargs }}' run: cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -ij1 __.resolvedIvyDeps; cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -i -d -k ${{ inputs.millargs }} - if: inputs.millargs != '' && startsWith(inputs.os, 'windows') \ No newline at end of file + if: inputs.millargs != '' && startsWith(inputs.os, 'windows') + + - uses: actions/upload-artifact@v4 + with: + path: . + if: ${{ inputs.populate_cache }} \ No newline at end of file From f86a8c0e5dbccb229e4d1c05841eb841672242a4 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 13:43:15 +0800 Subject: [PATCH 12/60] . --- .github/workflows/run-mill-action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index ca1319697cd..33acb52f2e9 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -38,6 +38,11 @@ jobs: MILL_COMPILER_BRIDGE_VERSIONS: ${{ inputs.env-bridge-versions }} steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + if: ${{ inputs.populate_cache }} + - uses: actions/download-artifact@v4 if: ${{ !inputs.populate_cache }} From 6c2e3dad43e7aaf891555407cb2000950b08ad09 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 13:44:39 +0800 Subject: [PATCH 13/60] . --- .github/workflows/actions.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 2ac0675ec62..a86bd65dd75 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -42,6 +42,7 @@ jobs: millargs: __.compile populate_cache: true itest: + needs: build-linux strategy: fail-fast: false matrix: @@ -65,6 +66,7 @@ jobs: buildcmd: ${{ matrix.buildcmd }} linux: + needs: build-linux strategy: fail-fast: false matrix: @@ -123,6 +125,7 @@ jobs: millargs: ${{ matrix.millargs }} compiler-bridge: + needs: build-linux uses: ./.github/workflows/run-mill-action.yml with: java-version: '8' @@ -130,18 +133,21 @@ jobs: env-bridge-versions: 'essential' format-check: + needs: build-linux uses: ./.github/workflows/run-mill-action.yml with: java-version: '11' millargs: mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources scalafix-check: + needs: build-linux uses: ./.github/workflows/run-mill-action.yml with: java-version: '11' millargs: -i -k __.fix --check bincompat-check: + needs: build-linux uses: ./.github/workflows/run-mill-action.yml with: java-version: '11' @@ -149,6 +155,7 @@ jobs: continue-on-error: true windows: + needs: build-windows strategy: fail-fast: false matrix: From 423319ec3c8aeeee277124dc1de88f1cef278db8 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 13:54:27 +0800 Subject: [PATCH 14/60] . --- .github/workflows/run-mill-action.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index 33acb52f2e9..35a4398477f 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -46,6 +46,10 @@ jobs: - uses: actions/download-artifact@v4 if: ${{ !inputs.populate_cache }} + - name: Unzip Artifact + run: | + unzip -l artifact + unzip artifact - uses: coursier/cache-action@v6 - uses: actions/setup-java@v4 From 308e0e56cad82842858c94db2d202edcc5efbc77 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 13:56:08 +0800 Subject: [PATCH 15/60] . --- .github/workflows/run-mill-action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index 35a4398477f..94eb8627b1d 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -50,6 +50,8 @@ jobs: run: | unzip -l artifact unzip artifact + if: ${{ !inputs.populate_cache }} + - uses: coursier/cache-action@v6 - uses: actions/setup-java@v4 From 6b7484e71fe3a99f71f19eed4c080aaa1effbec0 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 14:02:50 +0800 Subject: [PATCH 16/60] . --- .github/workflows/run-mill-action.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index 94eb8627b1d..a9f469ffd68 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -45,11 +45,13 @@ jobs: - uses: actions/download-artifact@v4 if: ${{ !inputs.populate_cache }} + with: + name: ${{ inputs.os }}-artifact - name: Unzip Artifact run: | - unzip -l artifact - unzip artifact + unzip -l /home/runner/work/mill/mill/artifact + unzip /home/runner/work/mill/mill/artifact if: ${{ !inputs.populate_cache }} - uses: coursier/cache-action@v6 @@ -79,4 +81,5 @@ jobs: - uses: actions/upload-artifact@v4 with: path: . + name: ${{ inputs.os }}-artifact if: ${{ inputs.populate_cache }} \ No newline at end of file From 1719dd2f1d6c65e63b0dc40726691215dc1d9e79 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 14:08:55 +0800 Subject: [PATCH 17/60] . --- .github/workflows/run-mill-action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index a9f469ffd68..576baf03af1 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -46,6 +46,7 @@ jobs: - uses: actions/download-artifact@v4 if: ${{ !inputs.populate_cache }} with: + path: artifact name: ${{ inputs.os }}-artifact - name: Unzip Artifact From 9cb20e0d4e154dfb128a2f1a4dde50c9a466a0f6 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 14:15:04 +0800 Subject: [PATCH 18/60] . --- .github/workflows/run-mill-action.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index 576baf03af1..0e83a28c9ec 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -49,6 +49,10 @@ jobs: path: artifact name: ${{ inputs.os }}-artifact + - name: Unzip Artifact + run: find . + if: ${{ !inputs.populate_cache }} + - name: Unzip Artifact run: | unzip -l /home/runner/work/mill/mill/artifact From ce0d6e4bc2e41bcd32a7193612587cd473a86ca7 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 14:16:51 +0800 Subject: [PATCH 19/60] . --- .github/workflows/run-mill-action.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index 0e83a28c9ec..6ecae2bc70a 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -46,13 +46,9 @@ jobs: - uses: actions/download-artifact@v4 if: ${{ !inputs.populate_cache }} with: - path: artifact + path: . name: ${{ inputs.os }}-artifact - - name: Unzip Artifact - run: find . - if: ${{ !inputs.populate_cache }} - - name: Unzip Artifact run: | unzip -l /home/runner/work/mill/mill/artifact From ae90e4006af018b9df7a773870393d3614e97b3a Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 14:22:12 +0800 Subject: [PATCH 20/60] . --- .github/workflows/run-mill-action.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index 6ecae2bc70a..fa69cddd2fc 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -49,12 +49,6 @@ jobs: path: . name: ${{ inputs.os }}-artifact - - name: Unzip Artifact - run: | - unzip -l /home/runner/work/mill/mill/artifact - unzip /home/runner/work/mill/mill/artifact - if: ${{ !inputs.populate_cache }} - - uses: coursier/cache-action@v6 - uses: actions/setup-java@v4 @@ -71,9 +65,9 @@ jobs: run: ${{ inputs.buildcmd }} if: inputs.buildcmd != '' - - name: Run Mill '${{ inputs.millargs }}' - run: ./mill -i -k ${{ inputs.millargs }} - if: inputs.millargs != '' && !startsWith(inputs.os, 'windows') +# - name: Run Mill '${{ inputs.millargs }}' +# run: ./mill -i -k ${{ inputs.millargs }} +# if: inputs.millargs != '' && !startsWith(inputs.os, 'windows') - name: Run Mill (on Windows) '${{ inputs.millargs }}' run: cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -ij1 __.resolvedIvyDeps; cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -i -d -k ${{ inputs.millargs }} From abf0065b2a97064b783531cfc021e3cad3d65e22 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 14:31:51 +0800 Subject: [PATCH 21/60] . --- .github/workflows/run-mill-action.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index fa69cddd2fc..987103b8fb5 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -49,6 +49,9 @@ jobs: path: . name: ${{ inputs.os }}-artifact + - name: chmod executable + run: "chmod -R +x ." + - uses: coursier/cache-action@v6 - uses: actions/setup-java@v4 From b6c03d56fb02ee693a65e86b91adbece076183d8 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 14:36:13 +0800 Subject: [PATCH 22/60] . --- .github/workflows/run-mill-action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index 987103b8fb5..2de9ad593d7 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -68,9 +68,9 @@ jobs: run: ${{ inputs.buildcmd }} if: inputs.buildcmd != '' -# - name: Run Mill '${{ inputs.millargs }}' -# run: ./mill -i -k ${{ inputs.millargs }} -# if: inputs.millargs != '' && !startsWith(inputs.os, 'windows') + - name: Run Mill '${{ inputs.millargs }}' + run: ./mill -i -k ${{ inputs.millargs }} + if: inputs.millargs != '' && !startsWith(inputs.os, 'windows') - name: Run Mill (on Windows) '${{ inputs.millargs }}' run: cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -ij1 __.resolvedIvyDeps; cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -i -d -k ${{ inputs.millargs }} From 44af1cad2aded421380cc27eb8d37b42c68bd929 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 14:42:29 +0800 Subject: [PATCH 23/60] . --- .github/workflows/run-mill-action.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index 2de9ad593d7..7a767d590de 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -52,6 +52,9 @@ jobs: - name: chmod executable run: "chmod -R +x ." + - name: find . + run: "find ." + - uses: coursier/cache-action@v6 - uses: actions/setup-java@v4 @@ -68,9 +71,9 @@ jobs: run: ${{ inputs.buildcmd }} if: inputs.buildcmd != '' - - name: Run Mill '${{ inputs.millargs }}' - run: ./mill -i -k ${{ inputs.millargs }} - if: inputs.millargs != '' && !startsWith(inputs.os, 'windows') +# - name: Run Mill '${{ inputs.millargs }}' +# run: ./mill -i -k ${{ inputs.millargs }} +# if: inputs.millargs != '' && !startsWith(inputs.os, 'windows') - name: Run Mill (on Windows) '${{ inputs.millargs }}' run: cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -ij1 __.resolvedIvyDeps; cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -i -d -k ${{ inputs.millargs }} From 37de28af3b81d5203fb23b93450fa8c7a5047fe8 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 14:46:53 +0800 Subject: [PATCH 24/60] . --- .github/workflows/run-mill-action.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index 7a767d590de..9282aedabdb 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -52,9 +52,6 @@ jobs: - name: chmod executable run: "chmod -R +x ." - - name: find . - run: "find ." - - uses: coursier/cache-action@v6 - uses: actions/setup-java@v4 @@ -83,4 +80,5 @@ jobs: with: path: . name: ${{ inputs.os }}-artifact + include-hidden-files: true if: ${{ inputs.populate_cache }} \ No newline at end of file From 98fca895c9c7305e3a671f12e8e736a1c2212152 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 14:49:06 +0800 Subject: [PATCH 25/60] . --- .github/workflows/run-mill-action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index 9282aedabdb..0beb36480de 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -68,9 +68,9 @@ jobs: run: ${{ inputs.buildcmd }} if: inputs.buildcmd != '' -# - name: Run Mill '${{ inputs.millargs }}' -# run: ./mill -i -k ${{ inputs.millargs }} -# if: inputs.millargs != '' && !startsWith(inputs.os, 'windows') + - name: Run Mill '${{ inputs.millargs }}' + run: ./mill -i -k ${{ inputs.millargs }} + if: inputs.millargs != '' && !startsWith(inputs.os, 'windows') - name: Run Mill (on Windows) '${{ inputs.millargs }}' run: cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -ij1 __.resolvedIvyDeps; cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -i -d -k ${{ inputs.millargs }} From fb3da09d108b1ac05c947faa8511837c3ff680bd Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 14:57:27 +0800 Subject: [PATCH 26/60] . --- .github/workflows/run-mill-action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index 0beb36480de..c5b0339ad9b 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -76,6 +76,11 @@ jobs: run: cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -ij1 __.resolvedIvyDeps; cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -i -d -k ${{ inputs.millargs }} if: inputs.millargs != '' && startsWith(inputs.os, 'windows') + - name: Run Mill (on Windows) '${{ inputs.millargs }}' + run: 'rm -rf out/mill-worker-*' + if: inputs.millargs != '' && startsWith(inputs.os, 'windows') + shell: bash + - uses: actions/upload-artifact@v4 with: path: . From 263c8080a03a995b0372b868fc6b55423f898b7c Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 15:04:46 +0800 Subject: [PATCH 27/60] . --- .github/workflows/run-mill-action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index c5b0339ad9b..ae66c9aa7a3 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -76,8 +76,8 @@ jobs: run: cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -ij1 __.resolvedIvyDeps; cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -i -d -k ${{ inputs.millargs }} if: inputs.millargs != '' && startsWith(inputs.os, 'windows') - - name: Run Mill (on Windows) '${{ inputs.millargs }}' - run: 'rm -rf out/mill-worker-*' + - name: Run Mill (on Windows) Worker Cleanup + run: 'pkill -f java && rm -rf out/mill-worker-*' if: inputs.millargs != '' && startsWith(inputs.os, 'windows') shell: bash From 217944e47ea030771110b9d5f03312018274824e Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 15:11:50 +0800 Subject: [PATCH 28/60] . --- .github/workflows/run-mill-action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index ae66c9aa7a3..efd22d22631 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -77,7 +77,7 @@ jobs: if: inputs.millargs != '' && startsWith(inputs.os, 'windows') - name: Run Mill (on Windows) Worker Cleanup - run: 'pkill -f java && rm -rf out/mill-worker-*' + run: 'taskkill -f -im java* && rm -rf out/mill-worker-*' if: inputs.millargs != '' && startsWith(inputs.os, 'windows') shell: bash From 9ffdbbe2779653396bd21b3ca6d02287a2966af7 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 16:48:57 +0800 Subject: [PATCH 29/60] . --- .github/workflows/run-mill-action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index efd22d22631..a10dee039f4 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -81,7 +81,7 @@ jobs: if: inputs.millargs != '' && startsWith(inputs.os, 'windows') shell: bash - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v4.3.5 with: path: . name: ${{ inputs.os }}-artifact From 51e5ef5adef5fb5759e7e0516fe4b3241fea47a4 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 17:02:57 +0800 Subject: [PATCH 30/60] . --- .github/workflows/actions.yml | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index a86bd65dd75..f87e8a360ba 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -49,16 +49,9 @@ jobs: include: # bootstrap tests - java-version: 11 # Have one job on oldest JVM - buildcmd: ci/test-mill-dev.sh + buildcmd: ci/test-mill-dev.sh && ci/test-mill-release.sh && ./mill -i -k __.ivyDepsTree && ./mill -i -k __.ivyDepsTree --withRuntime - java-version: 17 # Have one job on default JVM - buildcmd: ci/test-mill-release.sh - - java-version: 17 buildcmd: ci/test-mill-bootstrap.sh - # Just some reporting to enable reasoning about library upgrades - - java-version: 11 - buildcmd: | - ./mill -i -k __.ivyDepsTree - ./mill -i -k __.ivyDepsTree --withRuntime uses: ./.github/workflows/run-mill-action.yml with: @@ -132,27 +125,12 @@ jobs: millargs: bridge.__.publishLocal env-bridge-versions: 'essential' - format-check: - needs: build-linux - uses: ./.github/workflows/run-mill-action.yml - with: - java-version: '11' - millargs: mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources - - scalafix-check: - needs: build-linux - uses: ./.github/workflows/run-mill-action.yml - with: - java-version: '11' - millargs: -i -k __.fix --check - - bincompat-check: + format-scalafix-bincompat-check: needs: build-linux uses: ./.github/workflows/run-mill-action.yml with: java-version: '11' - millargs: __.mimaReportBinaryIssues - continue-on-error: true + buildcmd: ./mill -i mill.scalalib.scalafmt.ScalafmtModule/checkFormatAll __.sources + __.mimaReportBinaryIssues + __.fix --check windows: needs: build-windows From 8fcb5c3af7640ae896551bfc59c8d8148e9b72e7 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 17:04:00 +0800 Subject: [PATCH 31/60] . --- .github/workflows/actions.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index f87e8a360ba..02e4186377d 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -125,7 +125,7 @@ jobs: millargs: bridge.__.publishLocal env-bridge-versions: 'essential' - format-scalafix-bincompat-check: + format-scalafix-bincompat: needs: build-linux uses: ./.github/workflows/run-mill-action.yml with: @@ -164,7 +164,7 @@ jobs: publish-sonatype: # when in master repo, publish all tags and manual runs on main if: github.repository == 'com-lihaoyi/mill' && (startsWith( github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' ) ) - needs: [linux, windows, compiler-bridge, format-check, bincompat-check, scalafix-check, itest] + needs: [linux, windows, compiler-bridge, format-scalafix-bincompat, itest] runs-on: ubuntu-latest From 7fbf05c62302ffeae0267f716cfc6416a7418f96 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 17:06:32 +0800 Subject: [PATCH 32/60] . --- .github/workflows/actions.yml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 02e4186377d..da065e53fb7 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -68,30 +68,24 @@ jobs: # Run unit and module tests on both oldest and newest Java versions - '"{main,scalalib,testrunner,bsp}.__.test"' include: - # For most tests, run them arbitrarily on Java 8 or Java 17 on Linux, and + # For most tests, run them arbitrarily on Java 11 or Java 17 on Linux, and # on the opposite version on Windows below, so we get decent coverage of # each test on each Java version and each operating system - java-version: 11 - millargs: '"scalajslib.__.test"' - - java-version: 11 - millargs: '"scalanativelib.__.test"' + millargs: "'{scalajslib,scalanativelib}.__.test'" - java-version: 17 millargs: "contrib._.test" # Group these tests together to try and balance out the runtimes of each job # Just running in `local` mode since they shouldn't depend on the mode - java-version: 17 - millargs: "'example.javalib.__.local.test'" - - java-version: 17 - millargs: "'example.scalalib.__.local.test'" + millargs: "'example.{javalib,scalalib}.__.local.test'" - java-version: 11 millargs: "'example.thirdparty[{mockito,acyclic,commons-io}].local.test'" - java-version: 17 millargs: "'example.thirdparty[{fansi,jimfs,netty,gatling}].local.test'" - java-version: 11 - millargs: "'example.depth.__.local.test'" - - java-version: 17 - millargs: "'example.extending.__.local.test'" + millargs: "'example.{depth,extending}.__.local.test'" # Most of these integration tests should not depend on which mode they # are run in, so just run them in `local` From bc42f2050396e2d32226138e241a21ea77e1747c Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 17:19:31 +0800 Subject: [PATCH 33/60] . --- .github/workflows/actions.yml | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index da065e53fb7..63d0a1e4265 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -66,40 +66,40 @@ jobs: java-version: [11, 17] millargs: # Run unit and module tests on both oldest and newest Java versions - - '"{main,scalalib,testrunner,bsp}.__.test"' + - '"{main,scalalib,testrunner,bsp}.__.testCached"' include: # For most tests, run them arbitrarily on Java 11 or Java 17 on Linux, and # on the opposite version on Windows below, so we get decent coverage of # each test on each Java version and each operating system - java-version: 11 - millargs: "'{scalajslib,scalanativelib}.__.test'" + millargs: "'{scalajslib,scalanativelib}.__.testCached'" - java-version: 17 - millargs: "contrib._.test" + millargs: "contrib._.testCached" # Group these tests together to try and balance out the runtimes of each job # Just running in `local` mode since they shouldn't depend on the mode - java-version: 17 - millargs: "'example.{javalib,scalalib}.__.local.test'" + millargs: "'example.{javalib,scalalib}.__.local.testCached'" - java-version: 11 - millargs: "'example.thirdparty[{mockito,acyclic,commons-io}].local.test'" + millargs: "'example.thirdparty[{mockito,acyclic,commons-io}].local.testCached'" - java-version: 17 - millargs: "'example.thirdparty[{fansi,jimfs,netty,gatling}].local.test'" + millargs: "'example.thirdparty[{fansi,jimfs,netty,gatling}].local.testCached'" - java-version: 11 - millargs: "'example.{depth,extending}.__.local.test'" + millargs: "'example.{depth,extending}.__.local.testCached'" # Most of these integration tests should not depend on which mode they # are run in, so just run them in `local` - java-version: 11 - millargs: "'integration.{failure,feature,ide}[_].local.test'" + millargs: "'integration.{failure,feature,ide}[_].local.testCached'" # These invalidation tests need to be exercised in all three execution modes # to make sure they work with and without -i/--no-server being passed - java-version: 17 - millargs: "'integration.invalidation[_].local.test'" + millargs: "'integration.invalidation[_].local.testCached'" - java-version: 17 - millargs: "'integration.invalidation[_].fork.test'" + millargs: "'integration.invalidation[_].fork.testCached'" - java-version: 17 - millargs: "'integration.invalidation[_].server.test'" + millargs: "'integration.invalidation[_].server.testCached'" # Check docsite compiles - java-version: 17 @@ -135,19 +135,19 @@ jobs: # just run a subset of examples/ on Windows, because for some reason running # the whole suite can take hours on windows v.s. half an hour on linux - java-version: 11 - millargs: '"{main,scalalib,bsp}.__.test"' + millargs: '"{main,scalalib,bsp}.__.testCached"' - java-version: 17 - millargs: '"scalajslib.__.test"' + millargs: '"scalajslib.__.testCached"' - java-version: 11 - millargs: '"example.scalalib.basic.__.fork.test"' + millargs: '"example.scalalib.basic.__.fork.testCached"' - java-version: 17 - millargs: "'integration.feature[_].fork.test'" + millargs: "'integration.feature[_].fork.testCached'" - java-version: 11 - millargs: "'integration.invalidation[_].server.test'" + millargs: "'integration.invalidation[_].server.testCached'" - java-version: 17 - millargs: "'integration.failure[_].fork.test'" + millargs: "'integration.failure[_].fork.testCached'" - java-version: 11 - millargs: "contrib.__.test" + millargs: "contrib.__.testCached" uses: ./.github/workflows/run-mill-action.yml with: From 2cb7ff0d97d14f57228b4cee126754e75d057f69 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 17:26:00 +0800 Subject: [PATCH 34/60] . --- .github/workflows/run-mill-action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index a10dee039f4..ce0b267a15c 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -80,6 +80,7 @@ jobs: run: 'taskkill -f -im java* && rm -rf out/mill-worker-*' if: inputs.millargs != '' && startsWith(inputs.os, 'windows') shell: bash + continue-on-error: true - uses: actions/upload-artifact@v4.3.5 with: From 40b24e55fad462bfcad11bd7a3c8bac074c602ac Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 17:26:39 +0800 Subject: [PATCH 35/60] . --- .github/workflows/actions.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 63d0a1e4265..1a405fd3bd0 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -141,11 +141,9 @@ jobs: - java-version: 11 millargs: '"example.scalalib.basic.__.fork.testCached"' - java-version: 17 - millargs: "'integration.feature[_].fork.testCached'" + millargs: "'integration.{feature,failure}[_].fork.testCached'" - java-version: 11 millargs: "'integration.invalidation[_].server.testCached'" - - java-version: 17 - millargs: "'integration.failure[_].fork.testCached'" - java-version: 11 millargs: "contrib.__.testCached" From 8c50d0511d42d24988d474b020312c2508a3a3ef Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 17:45:37 +0800 Subject: [PATCH 36/60] . --- .github/workflows/actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 1a405fd3bd0..9175a17fb32 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -74,7 +74,7 @@ jobs: - java-version: 11 millargs: "'{scalajslib,scalanativelib}.__.testCached'" - java-version: 17 - millargs: "contrib._.testCached" + millargs: "contrib.__.testCached" # Group these tests together to try and balance out the runtimes of each job # Just running in `local` mode since they shouldn't depend on the mode From 132b5d2d03671e1bfb62e1183a18852c48d05878 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 17:48:30 +0800 Subject: [PATCH 37/60] . --- .github/workflows/actions.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 9175a17fb32..745097df284 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -92,14 +92,10 @@ jobs: - java-version: 11 millargs: "'integration.{failure,feature,ide}[_].local.testCached'" - # These invalidation tests need to be exercised in all three execution modes + # These invalidation tests need to be exercised in both execution modes # to make sure they work with and without -i/--no-server being passed - java-version: 17 - millargs: "'integration.invalidation[_].local.testCached'" - - java-version: 17 - millargs: "'integration.invalidation[_].fork.testCached'" - - java-version: 17 - millargs: "'integration.invalidation[_].server.testCached'" + millargs: "'integration.invalidation[_].{fork,server}.testCached'" # Check docsite compiles - java-version: 17 From 13f5c36569e1eb8b0239f837513594ec8ae7f709 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 18:09:33 +0800 Subject: [PATCH 38/60] . --- .../src/MillPluginClasspathTest.scala | 52 +++++++++++-------- .../main/client/FileToStreamTailerTest.java | 4 +- .../mill/main/server/ClientServerTests.scala | 7 ++- 3 files changed, 36 insertions(+), 27 deletions(-) diff --git a/integration/feature/plugin-classpath/src/MillPluginClasspathTest.scala b/integration/feature/plugin-classpath/src/MillPluginClasspathTest.scala index c7062ff0a35..b316625b110 100644 --- a/integration/feature/plugin-classpath/src/MillPluginClasspathTest.scala +++ b/integration/feature/plugin-classpath/src/MillPluginClasspathTest.scala @@ -5,7 +5,7 @@ import mill.testkit.IntegrationTestSuite import utest._ object MillPluginClasspathTest extends IntegrationTestSuite { - initWorkspace() + val embeddedModules: Seq[(String, String)] = Seq( ("com.lihaoyi", "mill-main-client"), @@ -31,37 +31,43 @@ object MillPluginClasspathTest extends IntegrationTestSuite { ) val tests: Tests = Tests { - test("exclusions") - { - val res1 = eval(("--meta-level", "1", "resolveDepsExclusions")) - assert(res1.isSuccess) - val exclusions = out("mill-build.resolveDepsExclusions").value[Seq[(String, String)]] - val expectedExclusions = embeddedModules + test("exclusions") - { + retry(3) { + initWorkspace() + val res1 = eval(("--meta-level", "1", "resolveDepsExclusions")) + assert(res1.isSuccess) - val diff = expectedExclusions.toSet.diff(exclusions.toSet) - assert(diff.isEmpty) + val exclusions = out("mill-build.resolveDepsExclusions").value[Seq[(String, String)]] + val expectedExclusions = embeddedModules + val diff = expectedExclusions.toSet.diff(exclusions.toSet) + assert(diff.isEmpty) + } } test("runClasspath") - { - // We expect Mill core transitive dependencies to be filtered out - val res1 = eval(("--meta-level", "1", "runClasspath")) - assert(res1.isSuccess) + retry(3) { + initWorkspace() + // We expect Mill core transitive dependencies to be filtered out + val res1 = eval(("--meta-level", "1", "runClasspath")) + assert(res1.isSuccess) - val runClasspath = out("mill-build.runClasspath").value[Seq[String]] + val runClasspath = out("mill-build.runClasspath").value[Seq[String]] - val unexpectedArtifacts = embeddedModules.map { - case (o, n) => s"${o.replaceAll("[.]", "/")}/${n}" - } + val unexpectedArtifacts = embeddedModules.map { + case (o, n) => s"${o.replaceAll("[.]", "/")}/${n}" + } - val unexpected = unexpectedArtifacts.flatMap { a => - runClasspath.find(p => p.toString.contains(a)).map((a, _)) - }.toMap - assert(unexpected.isEmpty) + val unexpected = unexpectedArtifacts.flatMap { a => + runClasspath.find(p => p.toString.contains(a)).map((a, _)) + }.toMap + assert(unexpected.isEmpty) - val expected = Seq("com/disneystreaming/smithy4s/smithy4s-mill-codegen-plugin_mill0.11_2.13") - assert(expected.forall(a => - runClasspath.exists(p => p.toString().replace('\\', '/').contains(a)) - )) + val expected = Seq("com/disneystreaming/smithy4s/smithy4s-mill-codegen-plugin_mill0.11_2.13") + assert(expected.forall(a => + runClasspath.exists(p => p.toString().replace('\\', '/').contains(a)) + )) + } } } diff --git a/main/client/test/src/mill/main/client/FileToStreamTailerTest.java b/main/client/test/src/mill/main/client/FileToStreamTailerTest.java index bb960cafc4a..9a38584ee43 100644 --- a/main/client/test/src/mill/main/client/FileToStreamTailerTest.java +++ b/main/client/test/src/mill/main/client/FileToStreamTailerTest.java @@ -99,11 +99,11 @@ public FileToStreamTailerTest() { final FileToStreamTailer tailer = new FileToStreamTailer(file, ps, 10); ) { tailer.start(); - Thread.sleep(100); + Thread.sleep(500); expectEquals(bas.toString(), ""); out.println("log line"); expectTrue(file.exists()); - Thread.sleep(100); + Thread.sleep(500); expectEquals(bas.toString(), "log line" + System.lineSeparator()); } } diff --git a/main/server/test/src/mill/main/server/ClientServerTests.scala b/main/server/test/src/mill/main/server/ClientServerTests.scala index d9b14286f5c..e6a0a090696 100644 --- a/main/server/test/src/mill/main/server/ClientServerTests.scala +++ b/main/server/test/src/mill/main/server/ClientServerTests.scala @@ -121,9 +121,9 @@ object ClientServerTests extends TestSuite { } def tests = Tests { - val tester = new Tester - test("hello") - retry(3) { + test("hello") - retry(3) { + val tester = new Tester val res1 = tester(args = Array("world")) assert( @@ -163,6 +163,7 @@ object ClientServerTests extends TestSuite { } test("concurrency") { + val tester = new Tester // Make sure concurrently running client commands results in multiple processes // being spawned, running in different folders import concurrent._ @@ -187,6 +188,7 @@ object ClientServerTests extends TestSuite { } test("clientLockReleasedOnFailure") { + val tester = new Tester // When the client gets interrupted via Ctrl-C, we exit the server immediately. This // is because Mill ends up executing arbitrary JVM code, and there is no generic way // to interrupt such an execution. The two options are to leave the server running @@ -212,6 +214,7 @@ object ClientServerTests extends TestSuite { } test("envVars") - retry(3) { + val tester = new Tester // Make sure the simple "have the client start a server and // exchange one message" workflow works from end to end. From 9321c1a274256c86a5dbc5f24cbb2b79b9f00d45 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 18:29:00 +0800 Subject: [PATCH 39/60] . --- .../plugin-classpath/src/MillPluginClasspathTest.scala | 4 ++-- main/util/src/mill/util/CoursierSupport.scala | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/integration/feature/plugin-classpath/src/MillPluginClasspathTest.scala b/integration/feature/plugin-classpath/src/MillPluginClasspathTest.scala index b316625b110..bd27ee7542a 100644 --- a/integration/feature/plugin-classpath/src/MillPluginClasspathTest.scala +++ b/integration/feature/plugin-classpath/src/MillPluginClasspathTest.scala @@ -6,7 +6,6 @@ import utest._ object MillPluginClasspathTest extends IntegrationTestSuite { - val embeddedModules: Seq[(String, String)] = Seq( ("com.lihaoyi", "mill-main-client"), ("com.lihaoyi", "mill-main-api_2.13"), @@ -63,7 +62,8 @@ object MillPluginClasspathTest extends IntegrationTestSuite { }.toMap assert(unexpected.isEmpty) - val expected = Seq("com/disneystreaming/smithy4s/smithy4s-mill-codegen-plugin_mill0.11_2.13") + val expected = + Seq("com/disneystreaming/smithy4s/smithy4s-mill-codegen-plugin_mill0.11_2.13") assert(expected.forall(a => runClasspath.exists(p => p.toString().replace('\\', '/').contains(a)) )) diff --git a/main/util/src/mill/util/CoursierSupport.scala b/main/util/src/mill/util/CoursierSupport.scala index 2fa9c7783e3..9fa405f0282 100644 --- a/main/util/src/mill/util/CoursierSupport.scala +++ b/main/util/src/mill/util/CoursierSupport.scala @@ -38,8 +38,12 @@ trait CoursierSupport { )(f: () => T): T = { val tried = Try(f()) tried match { - case Failure(e: NoSuchFileException) - if retryCount > 0 && e.getMessage.contains("__sha1.computed") => + case Failure(e) + if retryCount > 0 + && e.getMessage.contains("__sha1.computed") + && (e.isInstanceOf[NoSuchFileException] || e.isInstanceOf[ + java.nio.file.AccessDeniedException + ]) => // this one is not detected by coursier itself, so we try-catch handle it // I assume, this happens when another coursier thread already moved or rename dthe temporary file ctx.foreach(_.log.debug( From ef433644355d6d0e846c2304555264bde14ecf98 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 19:06:26 +0800 Subject: [PATCH 40/60] . --- example/javalib/web/2-hello-spring-boot/build.mill | 2 +- example/javalib/web/3-todo-spring-boot/build.mill | 2 +- main/api/src/mill/api/Result.scala | 4 +++- .../test/src/mill/main/client/FileToStreamTailerTest.java | 2 +- runner/src/mill/runner/CodeGen.scala | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/example/javalib/web/2-hello-spring-boot/build.mill b/example/javalib/web/2-hello-spring-boot/build.mill index da4b7f308c1..cc3ce13aad7 100644 --- a/example/javalib/web/2-hello-spring-boot/build.mill +++ b/example/javalib/web/2-hello-spring-boot/build.mill @@ -23,7 +23,7 @@ object `package` extends RootModule with JavaModule { > mill test ...com.example.HelloSpringBootTest#shouldReturnDefaultMessage() finished... -> mill runBackground; sleep 10 # give time for server to start +> mill runBackground; sleep 15 # give time for server to start > curl http://localhost:8086 ...

Hello, World!

... diff --git a/example/javalib/web/3-todo-spring-boot/build.mill b/example/javalib/web/3-todo-spring-boot/build.mill index 6b48e5f64af..8f0d5d12abd 100644 --- a/example/javalib/web/3-todo-spring-boot/build.mill +++ b/example/javalib/web/3-todo-spring-boot/build.mill @@ -61,7 +61,7 @@ object `package` extends RootModule with JavaModule { ...com.example.TodomvcIntegrationTests#homePageLoads() finished... ...com.example.TodomvcIntegrationTests#addNewTodoItem() finished... -> mill test.runBackground; sleep 10 # give time for server to start +> mill test.runBackground; sleep 15 # give time for server to start > curl http://localhost:8087 ...

todos

... diff --git a/main/api/src/mill/api/Result.scala b/main/api/src/mill/api/Result.scala index a06cd191c99..d2a57d6fdf7 100644 --- a/main/api/src/mill/api/Result.scala +++ b/main/api/src/mill/api/Result.scala @@ -74,8 +74,10 @@ object Result { */ case class Failure[T](msg: String, value: Option[T] = None) extends Failing[T] { def map[V](f: T => V): Failure[V] = Result.Failure(msg, value.map(f(_))) - def flatMap[V](f: T => Result[V]): Failure[V] = + def flatMap[V](f: T => Result[V]): Failure[V] = { Failure(msg, value.flatMap(f(_).asSuccess.map(_.value))) + } + override def toString = s"Failure($msg, $value)" } /** diff --git a/main/client/test/src/mill/main/client/FileToStreamTailerTest.java b/main/client/test/src/mill/main/client/FileToStreamTailerTest.java index 9a38584ee43..929896f0f25 100644 --- a/main/client/test/src/mill/main/client/FileToStreamTailerTest.java +++ b/main/client/test/src/mill/main/client/FileToStreamTailerTest.java @@ -104,7 +104,7 @@ public FileToStreamTailerTest() { out.println("log line"); expectTrue(file.exists()); Thread.sleep(500); - expectEquals(bas.toString(), "log line" + System.lineSeparator()); + expectEquals(bas.toString().trim, "log line"); } } }); diff --git a/runner/src/mill/runner/CodeGen.scala b/runner/src/mill/runner/CodeGen.scala index 714f337862b..dbe14739c82 100644 --- a/runner/src/mill/runner/CodeGen.scala +++ b/runner/src/mill/runner/CodeGen.scala @@ -104,7 +104,7 @@ object CodeGen { ) } - os.write(dest, parts, createFolders = true) + os.write.over(dest, parts, createFolders = true) } } From aba531b136a3d2867abe1491f59d1a6a4968b8fd Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 19:08:20 +0800 Subject: [PATCH 41/60] . --- .github/workflows/actions.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 745097df284..3d4757d56d1 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -132,10 +132,8 @@ jobs: # the whole suite can take hours on windows v.s. half an hour on linux - java-version: 11 millargs: '"{main,scalalib,bsp}.__.testCached"' - - java-version: 17 - millargs: '"scalajslib.__.testCached"' - java-version: 11 - millargs: '"example.scalalib.basic.__.fork.testCached"' + millargs: '"example.scalalib.{basic,web}.__.fork.testCached"' - java-version: 17 millargs: "'integration.{feature,failure}[_].fork.testCached'" - java-version: 11 From d1759423a73c2e8d23661090fad1cfa268125b08 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 19:10:57 +0800 Subject: [PATCH 42/60] . --- .github/workflows/actions.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 3d4757d56d1..a95b4373f5e 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -63,21 +63,19 @@ jobs: strategy: fail-fast: false matrix: - java-version: [11, 17] - millargs: - # Run unit and module tests on both oldest and newest Java versions - - '"{main,scalalib,testrunner,bsp}.__.testCached"' + include: # For most tests, run them arbitrarily on Java 11 or Java 17 on Linux, and # on the opposite version on Windows below, so we get decent coverage of # each test on each Java version and each operating system + # We also try to group tests together to manuaully balance out the runtimes of each jobs + - java-version: 17 + millargs: "'{main,scalalib,testrunner,bsp}.__.testCached'" - java-version: 11 millargs: "'{scalajslib,scalanativelib}.__.testCached'" - java-version: 17 millargs: "contrib.__.testCached" - # Group these tests together to try and balance out the runtimes of each job - # Just running in `local` mode since they shouldn't depend on the mode - java-version: 17 millargs: "'example.{javalib,scalalib}.__.local.testCached'" - java-version: 11 @@ -98,7 +96,7 @@ jobs: millargs: "'integration.invalidation[_].{fork,server}.testCached'" # Check docsite compiles - - java-version: 17 + - java-version: 11 millargs: docs.githubPages From e01eb6ff6ad3481a56dc5f0875518d7bd15dea16 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 19:17:28 +0800 Subject: [PATCH 43/60] . --- .github/workflows/actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index a95b4373f5e..ff5c4512ead 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -70,7 +70,7 @@ jobs: # each test on each Java version and each operating system # We also try to group tests together to manuaully balance out the runtimes of each jobs - java-version: 17 - millargs: "'{main,scalalib,testrunner,bsp}.__.testCached'" + millargs: "'{main,scalalib,testrunner,bsp,testkit}.__.testCached'" - java-version: 11 millargs: "'{scalajslib,scalanativelib}.__.testCached'" - java-version: 17 From 67aebc02cc4d8fe8c5d6f3384f0bc9b31ff3c386 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 19:55:57 +0800 Subject: [PATCH 44/60] intergrationTest{} helper --- .../src/BuildFileInSubfolderTests.scala | 6 +- .../compile-error/src/CompileErrorTests.scala | 6 +- .../src/CrossCollisionsTests.scala | 6 +- .../src/InvalidMetaModuleTests.scala | 6 +- .../src/InvalidPackageDeclaration.scala | 6 +- .../src/InvalidRootModuleTests.scala | 6 +- .../src/InvalidSubfolderRootModuleTests.scala | 6 +- .../src/MisnamedRootModuleTests.scala | 6 +- .../src/MissingBuildFileTests.scala | 6 +- .../src/ModuleInitErrorTests.scala | 28 +- .../ModuleOutsideTopLevelModuleTests.scala | 4 +- .../src/NoModulesInHelperFileTests.scala | 4 +- .../src/PackageFileInRootTests.scala | 4 +- .../parse-error/src/ParseErrorTests.scala | 4 +- .../src/RootModuleCompileErrorTests.scala | 4 +- .../RootSubfolderModuleCollisionTests.scala | 4 +- .../SubfolderHelperModuleCollisionTests.scala | 4 +- .../src/SubfolderMissingBuildPrefix.scala | 4 +- .../ThingsOutsideTopLevelModuleTests.scala | 4 +- .../src/AuxiliaryClassFilesTests.scala | 13 +- .../src/DocAnnotationsTests.scala | 3 +- .../feature/hygiene/src/HygieneTests.scala | 4 +- .../src/ImportIvyWorkerInvalidation.scala | 3 +- .../feature/init/src/MillInitTests.scala | 3 +- .../large-project/src/LargeProjectTests.scala | 3 +- .../mill-jvm-opts/src/MillJvmOptsTests.scala | 3 +- .../src/NonIdentifierImport.scala | 3 +- .../src/MillPluginClasspathTest.scala | 6 +- .../src/PrivateMethodsTests.scala | 3 +- .../src/ImportRepoTests.scala | 3 +- .../scoverage/src/ScoverageTests.scala | 3 +- .../src/SubprocessStdoutTests.scala | 6 +- integration/ide/bloop/src/BloopTests.scala | 21 +- .../src/BspInstallDebugTests.scala | 3 +- .../ide/bsp-install/src/BspInstallTests.scala | 3 +- .../ide/bsp-modules/src/BspModulesTests.scala | 6 +- .../gen-idea/src/GenIdeaExtendedTests.scala | 3 +- .../ide/gen-idea/src/GenIdeaTests.scala | 5 +- .../codesig-hello/src/CodeSigHelloTests.scala | 3 +- .../src/CodeSigNestedTests.scala | 6 +- .../src/CodeSigScalaModuleTests.scala | 5 +- .../src/ScriptsInvalidationTests.scala | 111 ++++---- .../src/MultiLevelBuildTests.scala | 253 +++++++++--------- .../src/WatchSourceInputTests.scala | 70 +++-- .../src/ZincIncrementalCompilationTests.scala | 7 +- .../main/client/FileToStreamTailerTest.java | 2 +- .../mill/testkit/IntegrationTestSuite.scala | 9 +- .../testkit/IntegrationTestSuiteBase.scala | 6 +- .../src/mill/testkit/IntegrationTester.scala | 4 +- 49 files changed, 320 insertions(+), 371 deletions(-) diff --git a/integration/failure/build-file-in-subfolder/src/BuildFileInSubfolderTests.scala b/integration/failure/build-file-in-subfolder/src/BuildFileInSubfolderTests.scala index f5d51acafd0..d2824c57259 100644 --- a/integration/failure/build-file-in-subfolder/src/BuildFileInSubfolderTests.scala +++ b/integration/failure/build-file-in-subfolder/src/BuildFileInSubfolderTests.scala @@ -6,10 +6,8 @@ import utest._ object BuildFileInSubfolderTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - - test("success") { - val res = eval(("resolve", "_")) + test("success") - integrationTest { tester => import tester._ + val res = tester.eval(("resolve", "_")) assert(res.isSuccess == false) assert(res.err.contains("Mill build.mill files can only be in the project root")) } diff --git a/integration/failure/compile-error/src/CompileErrorTests.scala b/integration/failure/compile-error/src/CompileErrorTests.scala index 6c718d80ae4..30567116dfd 100644 --- a/integration/failure/compile-error/src/CompileErrorTests.scala +++ b/integration/failure/compile-error/src/CompileErrorTests.scala @@ -6,10 +6,8 @@ import utest._ object CompileErrorTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - - test { - val res = eval("foo.scalaVersion") + test - integrationTest { tester => import tester._ + val res = tester.eval("foo.scalaVersion") assert(res.isSuccess == false) assert(res.err.contains("""bar.mill:15:9: not found: value doesntExist""")) diff --git a/integration/failure/cross-collisions/src/CrossCollisionsTests.scala b/integration/failure/cross-collisions/src/CrossCollisionsTests.scala index f964a019fb7..d1d5b578a16 100644 --- a/integration/failure/cross-collisions/src/CrossCollisionsTests.scala +++ b/integration/failure/cross-collisions/src/CrossCollisionsTests.scala @@ -6,10 +6,8 @@ import utest._ object CrossCollisionsTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - - test("detect-collision") { - val res = eval(("resolve", "foo._")) + test("detect-collision") - integrationTest { tester => import tester._ + val res = tester.eval(("resolve", "foo._")) assert(!res.isSuccess) assert(res.err.contains("Cross module ")) assert( diff --git a/integration/failure/invalid-meta-module/src/InvalidMetaModuleTests.scala b/integration/failure/invalid-meta-module/src/InvalidMetaModuleTests.scala index 3387cc7fbeb..4b8e1c2e748 100644 --- a/integration/failure/invalid-meta-module/src/InvalidMetaModuleTests.scala +++ b/integration/failure/invalid-meta-module/src/InvalidMetaModuleTests.scala @@ -6,10 +6,8 @@ import utest._ object InvalidMetaModuleTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - - test("success") { - val res = eval(("resolve", "_")) + test("success") - integrationTest { tester => import tester._ + val res = tester.eval(("resolve", "_")) assert(res.isSuccess == false) assert(res.err.contains("object `package` ")) assert(res.err.contains("must extend `MillBuildRootModule`")) diff --git a/integration/failure/invalid-package-declaration/src/InvalidPackageDeclaration.scala b/integration/failure/invalid-package-declaration/src/InvalidPackageDeclaration.scala index b7afb1dbd2e..a8ee628a53c 100644 --- a/integration/failure/invalid-package-declaration/src/InvalidPackageDeclaration.scala +++ b/integration/failure/invalid-package-declaration/src/InvalidPackageDeclaration.scala @@ -6,10 +6,8 @@ import utest._ object InvalidPackageDeclaration extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - - test("success") { - val res = eval(("resolve", "_")) + test("success") - integrationTest { tester => import tester._ + val res = tester.eval(("resolve", "_")) assert(res.isSuccess == false) assert(res.err.contains( """Package declaration "package wrong" in build.mill does not match folder structure. Expected: "package build"""" diff --git a/integration/failure/invalid-root-module/src/InvalidRootModuleTests.scala b/integration/failure/invalid-root-module/src/InvalidRootModuleTests.scala index 7d1573a2044..da4142f5899 100644 --- a/integration/failure/invalid-root-module/src/InvalidRootModuleTests.scala +++ b/integration/failure/invalid-root-module/src/InvalidRootModuleTests.scala @@ -6,10 +6,8 @@ import utest._ object InvalidRootModuleTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - - test("success") { - val res = eval(("resolve", "_")) + test("success") - integrationTest { tester => import tester._ + val res = tester.eval(("resolve", "_")) assert(res.isSuccess == false) assert(res.err.contains("object `package` in ")) assert(res.err.contains("must extend `RootModule`")) diff --git a/integration/failure/invalid-subfolder-root-module/src/InvalidSubfolderRootModuleTests.scala b/integration/failure/invalid-subfolder-root-module/src/InvalidSubfolderRootModuleTests.scala index 6cbd9d98f75..b1faf917b0e 100644 --- a/integration/failure/invalid-subfolder-root-module/src/InvalidSubfolderRootModuleTests.scala +++ b/integration/failure/invalid-subfolder-root-module/src/InvalidSubfolderRootModuleTests.scala @@ -6,10 +6,8 @@ import utest._ object InvalidSubfolderRootModuleTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - - test("success") { - val res = eval(("resolve", "_")) + test("success") - integrationTest { tester => import tester._ + val res = tester.eval(("resolve", "_")) assert(res.isSuccess == false) assert(res.err.contains("object `package` ")) assert(res.err.contains("must extend `RootModule`")) diff --git a/integration/failure/misnamed-root-module/src/MisnamedRootModuleTests.scala b/integration/failure/misnamed-root-module/src/MisnamedRootModuleTests.scala index 466f32784e7..bba2bcffb8e 100644 --- a/integration/failure/misnamed-root-module/src/MisnamedRootModuleTests.scala +++ b/integration/failure/misnamed-root-module/src/MisnamedRootModuleTests.scala @@ -6,10 +6,8 @@ import utest._ object MisnamedRootModuleTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - - test("success") { - val res = eval(("resolve", "_")) + test("success") - integrationTest { tester => import tester._ + val res = tester.eval(("resolve", "_")) assert(!res.isSuccess) assert(res.err.contains( "Only one RootModule named `package` can be defined in a build, not: foo" diff --git a/integration/failure/missing-build-file/src/MissingBuildFileTests.scala b/integration/failure/missing-build-file/src/MissingBuildFileTests.scala index 412c1766651..641c325d6a2 100644 --- a/integration/failure/missing-build-file/src/MissingBuildFileTests.scala +++ b/integration/failure/missing-build-file/src/MissingBuildFileTests.scala @@ -6,10 +6,8 @@ import utest._ object MissingBuildFileTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - - test { - val res = eval(("resolve", "_")) + test - integrationTest { tester => import tester._ + val res = tester.eval(("resolve", "_")) assert(!res.isSuccess) val s"build.mill file not found in $msg. Are you in a Mill project folder?" = res.err } diff --git a/integration/failure/module-init-error/src/ModuleInitErrorTests.scala b/integration/failure/module-init-error/src/ModuleInitErrorTests.scala index a0609b6856d..0a3f0bb6272 100644 --- a/integration/failure/module-init-error/src/ModuleInitErrorTests.scala +++ b/integration/failure/module-init-error/src/ModuleInitErrorTests.scala @@ -7,16 +7,14 @@ import utest._ object ModuleInitErrorTests extends IntegrationTestSuite { def captureOutErr = true val tests: Tests = Tests { - initWorkspace() - - test("resolve") { + test("resolve") - integrationTest { tester => import tester._ // Ensure that resolve works even of the modules containing the resolved // tasks are broken - val res1 = eval(("resolve", "foo.fooTarget")) + val res1 = tester.eval(("resolve", "foo.fooTarget")) assert(res1.isSuccess == true) assert(res1.out.contains("foo.fooTarget")) - val res2 = eval(("resolve", "_._")) + val res2 = tester.eval(("resolve", "_._")) assert(res2.isSuccess == true) assert( res2.out.contains("bar.barCommand"), @@ -26,11 +24,11 @@ object ModuleInitErrorTests extends IntegrationTestSuite { res2.out.contains("foo.fooCommand") ) - val res3 = eval(("resolve", "__.fooTarget")) + val res3 = tester.eval(("resolve", "__.fooTarget")) assert(res3.isSuccess == true) assert(res3.out.contains("foo.fooTarget")) - val res4 = eval(("resolve", "__")) + val res4 = tester.eval(("resolve", "__")) assert(res4.isSuccess == true) assert(res4.out.contains("bar")) assert(res4.out.contains("bar.barCommand")) @@ -43,21 +41,21 @@ object ModuleInitErrorTests extends IntegrationTestSuite { assert(res4.out.contains("foo.fooTarget")) } - test("rootTarget") { + test("rootTarget") - integrationTest { tester => import tester._ // If we specify a target in the root module, we are not // affected by the sub-modules failing to initialize val res = eval("rootTarget") assert(res.isSuccess == true) assert(res.out.contains("""Running rootTarget""")) } - test("rootCommand") { + test("rootCommand") - integrationTest { tester => import tester._ // If we specify a target in the root module, we are not // affected by the sub-modules failing to initialize val res = eval(("rootCommand", "-s", "hello")) assert(res.isSuccess == true) assert(res.out.contains("""Running rootCommand hello""")) } - test("fooTarget") { + test("fooTarget") - integrationTest { tester => import tester._ val res = eval("foo.fooTarget") assert(res.isSuccess == false) assert(fansi.Str(res.err).plainText.contains("""java.lang.Exception: Foo Boom""")) @@ -65,29 +63,29 @@ object ModuleInitErrorTests extends IntegrationTestSuite { // frames from the Mill launcher assert(fansi.Str(res.err).plainText.linesIterator.size < 20) } - test("fooCommand") { + test("fooCommand") - integrationTest { tester => import tester._ val res = eval(("foo.fooCommand", "-s", "hello")) assert(res.isSuccess == false) assert(fansi.Str(res.err).plainText.contains("""java.lang.Exception: Foo Boom""")) assert(fansi.Str(res.err).plainText.linesIterator.size < 20) } - test("barTarget") { + test("barTarget") - integrationTest { tester => import tester._ val res = eval("bar.barTarget") assert(res.isSuccess == true) assert(res.out.contains("""Running barTarget""")) } - test("barCommand") { + test("barCommand") - integrationTest { tester => import tester._ val res = eval(("bar.barCommand", "-s", "hello")) assert(res.isSuccess == true) assert(res.out.contains("""Running barCommand hello""")) } - test("quxTarget") { + test("quxTarget") - integrationTest { tester => import tester._ val res = eval("bar.qux.quxTarget") assert(res.isSuccess == false) assert(fansi.Str(res.err).plainText.contains("""java.lang.Exception: Qux Boom""")) assert(fansi.Str(res.err).plainText.linesIterator.size < 20) } - test("quxCommand") { + test("quxCommand") - integrationTest { tester => import tester._ val res = eval(("bar.qux.quxCommand", "-s", "hello")) assert(res.isSuccess == false) assert(fansi.Str(res.err).plainText.contains("""java.lang.Exception: Qux Boom""")) diff --git a/integration/failure/module-outside-top-level-module/src/ModuleOutsideTopLevelModuleTests.scala b/integration/failure/module-outside-top-level-module/src/ModuleOutsideTopLevelModuleTests.scala index 0633cb930ac..f028398e8a3 100644 --- a/integration/failure/module-outside-top-level-module/src/ModuleOutsideTopLevelModuleTests.scala +++ b/integration/failure/module-outside-top-level-module/src/ModuleOutsideTopLevelModuleTests.scala @@ -6,9 +6,7 @@ import utest._ object ModuleOutsideTopLevelModuleTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - - test("success") { + test("success") - integrationTest { tester => import tester._ val res = eval(("resolve", "_")) assert(!res.isSuccess) assert( diff --git a/integration/failure/no-modules-in-helper-file/src/NoModulesInHelperFileTests.scala b/integration/failure/no-modules-in-helper-file/src/NoModulesInHelperFileTests.scala index 0b5afb37c33..b1ad1da6fe9 100644 --- a/integration/failure/no-modules-in-helper-file/src/NoModulesInHelperFileTests.scala +++ b/integration/failure/no-modules-in-helper-file/src/NoModulesInHelperFileTests.scala @@ -6,9 +6,7 @@ import utest._ object NoModulesInHelperFileTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - - test("success") { + test("success") - integrationTest { tester => import tester._ val res = eval(("resolve", "_")) assert(res.isSuccess == false) assert( diff --git a/integration/failure/package-file-in-root/src/PackageFileInRootTests.scala b/integration/failure/package-file-in-root/src/PackageFileInRootTests.scala index 87b8f4eddf2..5ba7863efd1 100644 --- a/integration/failure/package-file-in-root/src/PackageFileInRootTests.scala +++ b/integration/failure/package-file-in-root/src/PackageFileInRootTests.scala @@ -6,9 +6,7 @@ import utest._ object PackageFileInRootTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - - test("success") { + test("success") - integrationTest { tester => import tester._ val res = eval(("resolve", "_")) assert(res.isSuccess == false) assert(res.err.contains("Mill package.mill files can only be in subfolders")) diff --git a/integration/failure/parse-error/src/ParseErrorTests.scala b/integration/failure/parse-error/src/ParseErrorTests.scala index 772df82f476..279cad11aa1 100644 --- a/integration/failure/parse-error/src/ParseErrorTests.scala +++ b/integration/failure/parse-error/src/ParseErrorTests.scala @@ -6,9 +6,7 @@ import utest._ object ParseErrorTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - - test { + test - integrationTest { tester => import tester._ val res = eval("foo.scalaVersion") assert(res.isSuccess == false) diff --git a/integration/failure/root-module-compile-error/src/RootModuleCompileErrorTests.scala b/integration/failure/root-module-compile-error/src/RootModuleCompileErrorTests.scala index 97244a3f8e1..5cf5182b95b 100644 --- a/integration/failure/root-module-compile-error/src/RootModuleCompileErrorTests.scala +++ b/integration/failure/root-module-compile-error/src/RootModuleCompileErrorTests.scala @@ -6,9 +6,7 @@ import utest._ object RootModuleCompileErrorTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - - test { + test - integrationTest { tester => import tester._ val res = eval("foo.scalaVersion") assert(res.isSuccess == false) diff --git a/integration/failure/root-subfolder-module-collision/src/RootSubfolderModuleCollisionTests.scala b/integration/failure/root-subfolder-module-collision/src/RootSubfolderModuleCollisionTests.scala index c33cbf5ff72..7e05b994067 100644 --- a/integration/failure/root-subfolder-module-collision/src/RootSubfolderModuleCollisionTests.scala +++ b/integration/failure/root-subfolder-module-collision/src/RootSubfolderModuleCollisionTests.scala @@ -6,9 +6,7 @@ import utest._ object RootSubfolderModuleCollisionTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - - test("success") { + test("success") - integrationTest { tester => import tester._ val res = eval(("resolve", "_")) assert(res.isSuccess == false) assert(res.err.contains("cannot override final member")) diff --git a/integration/failure/subfolder-helper-module-collision/src/SubfolderHelperModuleCollisionTests.scala b/integration/failure/subfolder-helper-module-collision/src/SubfolderHelperModuleCollisionTests.scala index d694aab1ed0..5aa1758d301 100644 --- a/integration/failure/subfolder-helper-module-collision/src/SubfolderHelperModuleCollisionTests.scala +++ b/integration/failure/subfolder-helper-module-collision/src/SubfolderHelperModuleCollisionTests.scala @@ -6,9 +6,7 @@ import utest._ object SubfolderHelperModuleCollisionTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - - test("success") { + test("success") - integrationTest { tester => import tester._ val res = eval(("resolve", "_")) assert(res.isSuccess == false) // Not a great error message but it will have to do for now diff --git a/integration/failure/subfolder-missing-build-prefix/src/SubfolderMissingBuildPrefix.scala b/integration/failure/subfolder-missing-build-prefix/src/SubfolderMissingBuildPrefix.scala index 7711bbdc64d..ad7a03b2387 100644 --- a/integration/failure/subfolder-missing-build-prefix/src/SubfolderMissingBuildPrefix.scala +++ b/integration/failure/subfolder-missing-build-prefix/src/SubfolderMissingBuildPrefix.scala @@ -6,9 +6,7 @@ import utest._ object SubfolderMissingBuildPrefix extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - - test("success") { + test("success") - integrationTest { tester => import tester._ val res = eval(("resolve", "_")) assert(res.isSuccess == false) assert(res.err.contains("object y is not a member of package build_.sub")) diff --git a/integration/failure/things-outside-top-level-module/src/ThingsOutsideTopLevelModuleTests.scala b/integration/failure/things-outside-top-level-module/src/ThingsOutsideTopLevelModuleTests.scala index 564df09a65f..9d7707db119 100644 --- a/integration/failure/things-outside-top-level-module/src/ThingsOutsideTopLevelModuleTests.scala +++ b/integration/failure/things-outside-top-level-module/src/ThingsOutsideTopLevelModuleTests.scala @@ -6,9 +6,7 @@ import utest._ object ThingsOutsideTopLevelModuleTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - - test("success") { + test("success") - integrationTest { tester => import tester._ val res = eval(("resolve", "_")) assert(!res.isSuccess) assert( diff --git a/integration/feature/auxiliary-class-files/src/AuxiliaryClassFilesTests.scala b/integration/feature/auxiliary-class-files/src/AuxiliaryClassFilesTests.scala index 5551fa0f4e1..412c8ced7c7 100644 --- a/integration/feature/auxiliary-class-files/src/AuxiliaryClassFilesTests.scala +++ b/integration/feature/auxiliary-class-files/src/AuxiliaryClassFilesTests.scala @@ -7,8 +7,7 @@ import utest._ // Regress test for issue https://github.com/com-lihaoyi/mill/issues/1901 object AuxiliaryClassFilesTests extends IntegrationTestSuite { val tests: Tests = Tests { - test("tasty files are deleted together with companion class files") { - initWorkspace() + test("tasty files are deleted together with companion class files") - integrationTest { tester => import tester._ assert(eval("app.jvm.compile").isSuccess) val classes = workspacePath / "out" / "app" / "jvm" / "compile.dest" / "classes" @@ -24,9 +23,7 @@ object AuxiliaryClassFilesTests extends IntegrationTestSuite { assert(secondRun == Seq.empty) } - test("compilation fails when deleting a class used by other files") { - initWorkspace() - + test("compilation fails when deleting a class used by other files") - integrationTest { tester => import tester._ os.write(workspacePath / "app" / "src" / "bar.scala", "object bar { println(foo) }") val firstRunSuccessful = eval("app.jvm.compile") assert(firstRunSuccessful.isSuccess) @@ -52,8 +49,7 @@ object AuxiliaryClassFilesTests extends IntegrationTestSuite { assert(secondRun == Seq.empty) } - test("nir files are deleted together with companion class files") { - initWorkspace() + test("nir files are deleted together with companion class files") - integrationTest { tester => import tester._ assert(eval("app.native.compile").isSuccess) val classes = workspacePath / "out" / "app" / "native" / "compile.dest" / "classes" @@ -69,8 +65,7 @@ object AuxiliaryClassFilesTests extends IntegrationTestSuite { assert(secondRun == Seq.empty) } - test("sjsir files are deleted together with companion class files") { - initWorkspace() + test("sjsir files are deleted together with companion class files") - integrationTest { tester => import tester._ assert(eval("app.js.compile").isSuccess) val classes = workspacePath / "out" / "app" / "js" / "compile.dest" / "classes" diff --git a/integration/feature/docannotations/src/DocAnnotationsTests.scala b/integration/feature/docannotations/src/DocAnnotationsTests.scala index 8c4948e75be..38506940327 100644 --- a/integration/feature/docannotations/src/DocAnnotationsTests.scala +++ b/integration/feature/docannotations/src/DocAnnotationsTests.scala @@ -16,8 +16,7 @@ object DocAnnotationsTests extends IntegrationTestSuite { } val tests: Tests = Tests { - initWorkspace() - test("test") - { + test("test") - integrationTest { tester => import tester._ val res = eval(("inspect", "core.test.ivyDeps")) assert(res.isSuccess == true) diff --git a/integration/feature/hygiene/src/HygieneTests.scala b/integration/feature/hygiene/src/HygieneTests.scala index f805400b1ec..679daa8815e 100644 --- a/integration/feature/hygiene/src/HygieneTests.scala +++ b/integration/feature/hygiene/src/HygieneTests.scala @@ -6,9 +6,7 @@ import utest._ object HygieneTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - - test { + test - integrationTest { tester => import tester._ val res = eval("scala.foo") assert(res.isSuccess == true) val output = out("scala.foo").text diff --git a/integration/feature/import-ivy-worker-invalidation/src/ImportIvyWorkerInvalidation.scala b/integration/feature/import-ivy-worker-invalidation/src/ImportIvyWorkerInvalidation.scala index 999015576c9..29a4f4abbfe 100644 --- a/integration/feature/import-ivy-worker-invalidation/src/ImportIvyWorkerInvalidation.scala +++ b/integration/feature/import-ivy-worker-invalidation/src/ImportIvyWorkerInvalidation.scala @@ -7,8 +7,7 @@ import utest._ object ImportIvyWorkerInvalidation extends IntegrationTestSuite { val tests: Tests = Tests { - test { - initWorkspace() + test - integrationTest { tester => import tester._ assert(eval("app.compile").isSuccess) modifyFile( workspacePath / "build.mill", diff --git a/integration/feature/init/src/MillInitTests.scala b/integration/feature/init/src/MillInitTests.scala index c7558d05340..038a0eaa3bc 100644 --- a/integration/feature/init/src/MillInitTests.scala +++ b/integration/feature/init/src/MillInitTests.scala @@ -6,8 +6,7 @@ import utest._ object MillInitTests extends IntegrationTestSuite { def tests: Tests = Tests { - test("Mill init works") { - initWorkspace() + test("Mill init works") - integrationTest { tester => import tester._ eval(("init", "com-lihaoyi/mill-scala-hello.g8", "--name=example")).isSuccess ==> true val projFile = workspacePath / "example" / "build.sc" assert(os.exists(projFile)) diff --git a/integration/feature/large-project/src/LargeProjectTests.scala b/integration/feature/large-project/src/LargeProjectTests.scala index 7bc1585af7b..baf310dad3c 100644 --- a/integration/feature/large-project/src/LargeProjectTests.scala +++ b/integration/feature/large-project/src/LargeProjectTests.scala @@ -6,8 +6,7 @@ import utest._ object LargeProjectTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - test("test") - { + test("test") - integrationTest { tester => import tester._ assert(eval("foo.common.one.compile").isSuccess) } diff --git a/integration/feature/mill-jvm-opts/src/MillJvmOptsTests.scala b/integration/feature/mill-jvm-opts/src/MillJvmOptsTests.scala index b3379e10eb4..1d946aaae3e 100644 --- a/integration/feature/mill-jvm-opts/src/MillJvmOptsTests.scala +++ b/integration/feature/mill-jvm-opts/src/MillJvmOptsTests.scala @@ -6,8 +6,7 @@ import utest._ object MillJvmOptsTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - test("JVM options from file .mill-jvm-opts are properly read") { + test("JVM options from file .mill-jvm-opts are properly read") - integrationTest { tester => import tester._ assert(eval("checkJvmOpts").isSuccess) } } diff --git a/integration/feature/non-identifier-import/src/NonIdentifierImport.scala b/integration/feature/non-identifier-import/src/NonIdentifierImport.scala index 29fd1117160..6edfca7da46 100644 --- a/integration/feature/non-identifier-import/src/NonIdentifierImport.scala +++ b/integration/feature/non-identifier-import/src/NonIdentifierImport.scala @@ -6,8 +6,7 @@ import utest._ object NonIdentifierImport extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - test("test") - { + test("test") - integrationTest { tester => import tester._ assert(eval("foo-bar-module.compile").isSuccess) } } diff --git a/integration/feature/plugin-classpath/src/MillPluginClasspathTest.scala b/integration/feature/plugin-classpath/src/MillPluginClasspathTest.scala index bd27ee7542a..55973b75f98 100644 --- a/integration/feature/plugin-classpath/src/MillPluginClasspathTest.scala +++ b/integration/feature/plugin-classpath/src/MillPluginClasspathTest.scala @@ -31,9 +31,8 @@ object MillPluginClasspathTest extends IntegrationTestSuite { val tests: Tests = Tests { - test("exclusions") - { + test("exclusions") - integrationTest { tester => import tester._ retry(3) { - initWorkspace() val res1 = eval(("--meta-level", "1", "resolveDepsExclusions")) assert(res1.isSuccess) @@ -44,9 +43,8 @@ object MillPluginClasspathTest extends IntegrationTestSuite { assert(diff.isEmpty) } } - test("runClasspath") - { + test("runClasspath") - integrationTest { tester => import tester._ retry(3) { - initWorkspace() // We expect Mill core transitive dependencies to be filtered out val res1 = eval(("--meta-level", "1", "runClasspath")) assert(res1.isSuccess) diff --git a/integration/feature/private-methods/src/PrivateMethodsTests.scala b/integration/feature/private-methods/src/PrivateMethodsTests.scala index 122e444bfed..f82846e534c 100644 --- a/integration/feature/private-methods/src/PrivateMethodsTests.scala +++ b/integration/feature/private-methods/src/PrivateMethodsTests.scala @@ -6,8 +6,7 @@ import utest._ object PrivateMethodsTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - test("simple") { + test("simple") - integrationTest { tester => import tester._ // Simple public target depending on private target works val pub = eval(("show", "pub")) assert(pub.out == "\"priv\"") diff --git a/integration/feature/repo-config-via-import/src/ImportRepoTests.scala b/integration/feature/repo-config-via-import/src/ImportRepoTests.scala index 9a3d233a26c..911a8803816 100644 --- a/integration/feature/repo-config-via-import/src/ImportRepoTests.scala +++ b/integration/feature/repo-config-via-import/src/ImportRepoTests.scala @@ -6,8 +6,7 @@ import utest._ object ImportRepoTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - test("test") - { + test("test") - integrationTest { tester => import tester._ // Make sure, we propery parse a line: // ``` // import $repo.`file:///tmp/testrepo` diff --git a/integration/feature/scoverage/src/ScoverageTests.scala b/integration/feature/scoverage/src/ScoverageTests.scala index 8b2497e0414..5e85cbdb4b1 100644 --- a/integration/feature/scoverage/src/ScoverageTests.scala +++ b/integration/feature/scoverage/src/ScoverageTests.scala @@ -6,8 +6,7 @@ import utest._ object ScoverageTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - test("test") - { + test("test") - integrationTest { tester => import tester._ assert(eval("__.compile").isSuccess) assert(eval("core[2.13.11].scoverage.xmlReport").isSuccess) } diff --git a/integration/feature/subprocess-stdout/src/SubprocessStdoutTests.scala b/integration/feature/subprocess-stdout/src/SubprocessStdoutTests.scala index cbe745ef2b2..5151f3257c2 100644 --- a/integration/feature/subprocess-stdout/src/SubprocessStdoutTests.scala +++ b/integration/feature/subprocess-stdout/src/SubprocessStdoutTests.scala @@ -6,9 +6,7 @@ import utest._ object SubprocessStdoutTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - - test { + test - integrationTest { tester => import tester._ val res1 = eval("inheritInterleaved", mergeErrIntoOut = true).out // Make sure that when a lot of printed/inherited stdout/stderr is printed // in quick succession, the output ordering is preserved and it doesn't get @@ -62,7 +60,7 @@ object SubprocessStdoutTests extends IntegrationTestSuite { // up in the console somewhere and not disappear // val res2 = eval("inheritRaw", mergeErrIntoOut = true).out - if (!clientServerMode) { + if (!tester.clientServerMode) { // For `fork` tests, which represent `-i`/`--interactive`/`--no-server`, the output should // be properly ordered since it all comes directly from the stdout/stderr of the same process assert( diff --git a/integration/ide/bloop/src/BloopTests.scala b/integration/ide/bloop/src/BloopTests.scala index fe4e7afb5b6..dc5de41d38c 100644 --- a/integration/ide/bloop/src/BloopTests.scala +++ b/integration/ide/bloop/src/BloopTests.scala @@ -5,24 +5,29 @@ import mill.testkit.IntegrationTestSuite import utest._ object BloopTests extends IntegrationTestSuite { - initWorkspace() - val installResult: Boolean = eval("mill.contrib.bloop.Bloop/install").isSuccess val tests: Tests = Tests { test("test") - { - assert(installResult) - test("root module bloop config should be created") { + + test("root module bloop config should be created") - integrationTest { tester => import tester._ + val installResult: Boolean = eval("mill.contrib.bloop.Bloop/install").isSuccess + assert(installResult) assert(os.exists(workspacePath / ".bloop" / "root-module.json")) } - val millBuildJsonFile = workspacePath / ".bloop" / "mill-build-.json" - test("mill-build module bloop config should be created") { + test("mill-build module bloop config should be created") - integrationTest { tester => import tester._ + val installResult: Boolean = eval("mill.contrib.bloop.Bloop/install").isSuccess + val millBuildJsonFile = workspacePath / ".bloop" / "mill-build-.json" + assert(installResult) assert(os.exists(millBuildJsonFile)) } - val config = ujson.read(os.read.stream(millBuildJsonFile)) - test("mill-build config should contain build.mill source") { + test("mill-build config should contain build.mill source") - integrationTest { tester => import tester._ + val millBuildJsonFile = workspacePath / ".bloop" / "mill-build-.json" + val config = ujson.read(os.read.stream(millBuildJsonFile)) + val installResult: Boolean = eval("mill.contrib.bloop.Bloop/install").isSuccess + assert(installResult) assert(config("project")("sources").arr.exists(path => os.Path(path.str).last == "build.mill" )) diff --git a/integration/ide/bsp-install/src/BspInstallDebugTests.scala b/integration/ide/bsp-install/src/BspInstallDebugTests.scala index 543c2f6929d..a2364544a16 100644 --- a/integration/ide/bsp-install/src/BspInstallDebugTests.scala +++ b/integration/ide/bsp-install/src/BspInstallDebugTests.scala @@ -11,8 +11,7 @@ object BspInstallDebugTests extends IntegrationTestSuite { override val debugLog: Boolean = true def tests: Tests = Tests { - test("BSP install forwards --debug option to server") { - initWorkspace() + test("BSP install forwards --debug option to server") - integrationTest { tester => import tester._ eval("mill.bsp.BSP/install").isSuccess ==> true val jsonFile = workspacePath / Constants.bspDir / s"${Constants.serverName}.json" assert(os.exists(jsonFile)) diff --git a/integration/ide/bsp-install/src/BspInstallTests.scala b/integration/ide/bsp-install/src/BspInstallTests.scala index afeea1d53a1..393be236c02 100644 --- a/integration/ide/bsp-install/src/BspInstallTests.scala +++ b/integration/ide/bsp-install/src/BspInstallTests.scala @@ -8,8 +8,7 @@ object BspInstallTests extends IntegrationTestSuite { val bsp4jVersion: String = sys.props.getOrElse("BSP4J_VERSION", ???) def tests: Tests = Tests { - test("BSP install") { - initWorkspace() + test("BSP install") - integrationTest { tester => import tester._ assert(eval("mill.bsp.BSP/install").isSuccess) val jsonFile = workspacePath / Constants.bspDir / s"${Constants.serverName}.json" assert(os.exists(jsonFile)) diff --git a/integration/ide/bsp-modules/src/BspModulesTests.scala b/integration/ide/bsp-modules/src/BspModulesTests.scala index 8ffb3d10b28..50d5ad73d94 100644 --- a/integration/ide/bsp-modules/src/BspModulesTests.scala +++ b/integration/ide/bsp-modules/src/BspModulesTests.scala @@ -9,13 +9,11 @@ object BspModulesTests extends IntegrationTestSuite { def tests: Tests = Tests { test("BSP module with foreign modules") { - test("can be installed") { - initWorkspace() + test("can be installed") - integrationTest { tester => import tester._ assert(eval("mill.bsp.BSP/install").isSuccess) os.exists(workspacePath / Constants.bspDir / s"${Constants.serverName}.json") ==> true } - test("ModuleUtils resolves all referenced transitive modules") { - initWorkspace() + test("ModuleUtils resolves all referenced transitive modules") - integrationTest { tester => import tester._ val res = eval("validate") assert(res.isSuccess) val file = workspacePath / "out" / "validate.dest" / "transitive-modules.json" diff --git a/integration/ide/gen-idea/src/GenIdeaExtendedTests.scala b/integration/ide/gen-idea/src/GenIdeaExtendedTests.scala index f60401bd313..fcef8837a0f 100644 --- a/integration/ide/gen-idea/src/GenIdeaExtendedTests.scala +++ b/integration/ide/gen-idea/src/GenIdeaExtendedTests.scala @@ -11,8 +11,7 @@ object GenIdeaExtendedTests extends IntegrationTestSuite { override def workspaceSourcePath: Path = super.workspaceSourcePath / "extended" def tests: Tests = Tests { - test("genIdeaTests") { - initWorkspace() + test("genIdeaTests") - integrationTest { tester => import tester._ val expectedBase = workspacePath / "idea" val resources = os.walk(expectedBase).filter(os.isFile).map(_.subRelativeTo(expectedBase)) diff --git a/integration/ide/gen-idea/src/GenIdeaTests.scala b/integration/ide/gen-idea/src/GenIdeaTests.scala index 913b3903995..ac71e3480e1 100644 --- a/integration/ide/gen-idea/src/GenIdeaTests.scala +++ b/integration/ide/gen-idea/src/GenIdeaTests.scala @@ -12,7 +12,7 @@ object GenIdeaTests extends IntegrationTestSuite { override def workspaceSourcePath: Path = super.workspaceSourcePath / "hello-idea" def tests: Tests = Tests { - test("helper assertPartialContentMatches works") { + test("helper assertPartialContentMatches works") - integrationTest { tester => import tester._ val testContent = s"""line 1 |line 2 @@ -51,8 +51,7 @@ object GenIdeaTests extends IntegrationTestSuite { () } - test("genIdeaTests") { - initWorkspace() + test("genIdeaTests") - integrationTest { tester => import tester._ val expectedBase = workspacePath / "idea" val resources = os.walk(expectedBase).filter(os.isFile).map(_.subRelativeTo(expectedBase)) diff --git a/integration/invalidation/codesig-hello/src/CodeSigHelloTests.scala b/integration/invalidation/codesig-hello/src/CodeSigHelloTests.scala index 25066443a7d..866374169f2 100644 --- a/integration/invalidation/codesig-hello/src/CodeSigHelloTests.scala +++ b/integration/invalidation/codesig-hello/src/CodeSigHelloTests.scala @@ -6,8 +6,7 @@ import utest._ object CodeSigHelloTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - test("simple") { + test("simple") - integrationTest { tester => import tester._ // Make sure the simplest case where we have a single target calling a single helper // method is properly invalidated when either the target body, or the helper method's body // is changed, or something changed in the constructor diff --git a/integration/invalidation/codesig-nested/src/CodeSigNestedTests.scala b/integration/invalidation/codesig-nested/src/CodeSigNestedTests.scala index 04a72f94e7b..03bc8ea45b7 100644 --- a/integration/invalidation/codesig-nested/src/CodeSigNestedTests.scala +++ b/integration/invalidation/codesig-nested/src/CodeSigNestedTests.scala @@ -6,9 +6,7 @@ import utest._ object CodeSigNestedTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - - test("nested") { + test("nested") - integrationTest { tester => import tester._ // Make sure the code-change invalidation works in more complex cases: multi-step // target graphs, targets inside module objects, targets inside module traits @@ -190,7 +188,7 @@ object CodeSigNestedTests extends IntegrationTestSuite { assert(addedNewlinesInsideCurlies.out == "") } - test("trait") { + test("trait") - integrationTest { tester => import tester._ val initial = eval("traitOuter.traitInner.inner") assert( initial.out.linesIterator.toSet == Set( diff --git a/integration/invalidation/codesig-scalamodule/src/CodeSigScalaModuleTests.scala b/integration/invalidation/codesig-scalamodule/src/CodeSigScalaModuleTests.scala index a14ef8d9603..2642844052b 100644 --- a/integration/invalidation/codesig-scalamodule/src/CodeSigScalaModuleTests.scala +++ b/integration/invalidation/codesig-scalamodule/src/CodeSigScalaModuleTests.scala @@ -9,8 +9,7 @@ object CodeSigScalaModuleTests extends IntegrationTestSuite { def filterLines(out: String) = { out.linesIterator.filter(!_.contains("[info]")).toSet } - initWorkspace() - test("single") { + test("single") - integrationTest { tester => import tester._ // Tests for fine-grained method-based invalidation within a single ScalaModule // Check normal behavior for initial run and subsequent fully-cached run @@ -120,7 +119,7 @@ object CodeSigScalaModuleTests extends IntegrationTestSuite { ) } - test("multiple") { + test("multiple") - integrationTest { tester => import tester._ // Tests for fine-grained method-based invalidation between multiple ScalaModules, // some related and some not diff --git a/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala b/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala index 9d6b3afbd82..bd61a7dacd1 100644 --- a/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala +++ b/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala @@ -1,90 +1,81 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.{IntegrationTestSuite, IntegrationTester} import utest._ object ScriptsInvalidationTests extends IntegrationTestSuite { - def runTask(task: String): Set[String] = { - val res = eval(task) + def runTask(tester: IntegrationTester, task: String): Set[String] = { + val res = tester.eval(task) assert(res.isSuccess) res.out.linesIterator.map(_.trim).toSet } val tests: Tests = Tests { - test("should not invalidate tasks in different untouched sc files") { - test("first run") { - initWorkspace() + test("should not invalidate tasks in different untouched sc files") - integrationTest { tester => import tester._ + // first run + val result = runTask(tester, "task") - val result = runTask("task") + val expected = Set("a", "d", "b", "c") - val expected = Set("a", "d", "b", "c") + assert(result == expected) - assert(result == expected) - } - test("second run modifying script") { - modifyFile( - workspacePath / "build.mill", - _.replace("""println("task")""", """System.out.println("task2")""") - ) + // second run modifying script + modifyFile( + workspacePath / "build.mill", + _.replace("""println("task")""", """System.out.println("task2")""") + ) - val stdout = runTask("task") + val stdout = runTask(tester, "task") - assert(stdout.isEmpty) - } + assert(stdout.isEmpty) } - test("should invalidate tasks if leaf file is changed") { - test("first run") { - initWorkspace() - val result = runTask("task") - val expected = Set("a", "d", "b", "c") + test("should invalidate tasks if leaf file is changed") - integrationTest { tester => import tester._ + // first run - assert(result == expected) - } + val result = runTask(tester, "task") + val expected = Set("a", "d", "b", "c") - test("second run modifying script") { - modifyFile( - workspacePath / "b" / "inputD.mill", - _.replace("""println("d")""", """System.out.println("d2")""") - ) + assert(result == expected) - val result = runTask("task") - val expected = Set("d2", "b") + // second run modifying script + modifyFile( + workspacePath / "b" / "inputD.mill", + _.replace("""println("d")""", """System.out.println("d2")""") + ) + + val result2 = runTask(tester, "task") + val expected2 = Set("d2", "b") + + assert(result2 == expected2) - assert(result == expected) - } } - test("should handle submodules in scripts") { - test("first run") { - initWorkspace() + test("should handle submodules in scripts") - integrationTest { tester => import tester._ + // first run + val result = runTask(tester, "module.task") + val expected = Set("a", "d", "b", "c", "task") - val result = runTask("module.task") - val expected = Set("a", "d", "b", "c", "task") + assert(result == expected) - assert(result == expected) - } - test("second run modifying script") { - modifyFile( - workspacePath / "build.mill", - _.replace("""println("task")""", """System.out.println("task2")""") - ) + // second run modifying script + modifyFile( + workspacePath / "build.mill", + _.replace("""println("task")""", """System.out.println("task2")""") + ) - val result = runTask("module.task") - val expected = Set("task2") + val result2 = runTask(tester, "module.task") + val expected2 = Set("task2") - assert(result == expected) - } + assert(result2 == expected2) } - test("should handle ammonite ^ imports") { + test("should handle ammonite ^ imports") - integrationTest { tester => import tester._ retry(3) { // first run - initWorkspace() - - val result = runTask("taskE") + val result = runTask(tester, "taskE") val expected = Set("a", "e", "taskE") assert(result == expected) @@ -95,24 +86,22 @@ object ScriptsInvalidationTests extends IntegrationTestSuite { _.replace("""println("taskE")""", """System.out.println("taskE2")""") ) - val result2 = runTask("taskE") + val result2 = runTask(tester, "taskE") val expected2 = Set("taskE2") assert(result2 == expected2) } } - test("should handle ammonite paths with symbols") { - initWorkspace() + test("should handle ammonite paths with symbols") - integrationTest { tester => import tester._ - val result = runTask("taskSymbols") + val result = runTask(tester, "taskSymbols") val expected = Set("taskSymbols") assert(result == expected) } - test("should handle ammonite files with symbols") { - initWorkspace() + test("should handle ammonite files with symbols") - integrationTest { tester => import tester._ - val result = runTask("taskSymbolsInFile") + val result = runTask(tester, "taskSymbolsInFile") val expected = Set("taskSymbolsInFile") assert(result == expected) diff --git a/integration/invalidation/multi-level-editing/src/MultiLevelBuildTests.scala b/integration/invalidation/multi-level-editing/src/MultiLevelBuildTests.scala index 53c3628e0b3..30eb9666685 100644 --- a/integration/invalidation/multi-level-editing/src/MultiLevelBuildTests.scala +++ b/integration/invalidation/multi-level-editing/src/MultiLevelBuildTests.scala @@ -1,6 +1,6 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.{IntegrationTestSuite, IntegrationTester} import mill.main.client.OutFiles._ import mill.runner.RunnerState @@ -15,43 +15,42 @@ import scala.util.matching.Regex // in all cases. object MultiLevelBuildTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - def runAssertSuccess(expected: String) = { - val res = eval("foo.run") + def runAssertSuccess(tester: IntegrationTester, expected: String) = { + val res = tester.eval("foo.run") assert(res.isSuccess == true) assert(res.out.contains(expected)) } - val fooPaths = Seq( - workspacePath / "foo" / "compile-resources", - workspacePath / "foo" / "resources", - workspacePath / "foo" / "src" + def fooPaths(tester: IntegrationTester) = Seq( + tester.workspacePath / "foo" / "compile-resources", + tester.workspacePath / "foo" / "resources", + tester.workspacePath / "foo" / "src" ) - val buildPaths = Seq( - workspacePath / "build.mill", - workspacePath / "mill-build" / "compile-resources", - workspacePath / "mill-build" / "resources", - workspacePath / "mill-build" / "src" + def buildPaths(tester: IntegrationTester) = Seq( + tester.workspacePath / "build.mill", + tester.workspacePath / "mill-build" / "compile-resources", + tester.workspacePath / "mill-build" / "resources", + tester.workspacePath / "mill-build" / "src" ) - val buildPaths2 = Seq( - workspacePath / "mill-build" / "build.mill", - workspacePath / "mill-build" / "mill-build" / "compile-resources", - workspacePath / "mill-build" / "mill-build" / "resources", - workspacePath / "mill-build" / "mill-build" / "src" + def buildPaths2(tester: IntegrationTester) = Seq( + tester.workspacePath / "mill-build" / "build.mill", + tester.workspacePath / "mill-build" / "mill-build" / "compile-resources", + tester.workspacePath / "mill-build" / "mill-build" / "resources", + tester.workspacePath / "mill-build" / "mill-build" / "src" ) - val buildPaths3 = Seq( - workspacePath / "mill-build" / "mill-build" / "build.mill", - workspacePath / "mill-build" / "mill-build" / "mill-build" / "compile-resources", - workspacePath / "mill-build" / "mill-build" / "mill-build" / "resources", - workspacePath / "mill-build" / "mill-build" / "mill-build" / "src" + def buildPaths3(tester: IntegrationTester) = Seq( + tester.workspacePath / "mill-build" / "mill-build" / "build.mill", + tester.workspacePath / "mill-build" / "mill-build" / "mill-build" / "compile-resources", + tester.workspacePath / "mill-build" / "mill-build" / "mill-build" / "resources", + tester.workspacePath / "mill-build" / "mill-build" / "mill-build" / "src" ) - def loadFrames(n: Int) = { + def loadFrames(tester: IntegrationTester, n: Int) = { for (depth <- Range(0, n)) yield { val path = - workspacePath / "out" / Seq.fill(depth)(millBuild) / millRunnerState + tester. workspacePath / "out" / Seq.fill(depth)(millBuild) / millRunnerState if (os.exists(path)) upickle.default.read[RunnerState.Frame.Logged](os.read(path)) -> path else RunnerState.Frame.Logged(Map(), Seq(), Seq(), None, Seq(), 0) -> path } @@ -61,12 +60,12 @@ object MultiLevelBuildTests extends IntegrationTestSuite { * Verify that each level of the multi-level build ends upcausing the * appropriate files to get watched */ - def checkWatchedFiles(expected0: Seq[os.Path]*) = { - for ((expectedWatched0, (frame, path)) <- expected0.zip(loadFrames(expected0.length))) { + def checkWatchedFiles(tester: IntegrationTester, expected0: Seq[os.Path]*) = { + for ((expectedWatched0, (frame, path)) <- expected0.zip(loadFrames(tester, expected0.length))) { val frameWatched = frame .evalWatched .map(_.path) - .filter(_.startsWith(workspacePath)) + .filter(_.startsWith(tester.workspacePath)) .filter(!_.segments.contains("mill-launcher")) .sorted @@ -75,14 +74,14 @@ object MultiLevelBuildTests extends IntegrationTestSuite { } } - def evalCheckErr(expectedSnippets: String*) = { + def evalCheckErr(tester: IntegrationTester, expectedSnippets: String*) = { // Wipe out stale state files to make sure they don't get picked up when // Mill aborts early and fails to generate a new one - os.walk(workspacePath / "out").filter(_.last == "mill-runner-state.json").foreach( + os.walk(tester.workspacePath / "out").filter(_.last == "mill-runner-state.json").foreach( os.remove(_) ) - val res = eval("foo.run") + val res = tester.eval("foo.run") assert(res.isSuccess == false) // Prepend a "\n" to allow callsites to use "\n" to test for start of // line, even though the first line doesn't have a "\n" at the start @@ -100,9 +99,9 @@ object MultiLevelBuildTests extends IntegrationTestSuite { * the previous classloader was re-used, `null` means there is no * classloader at that level */ - def checkChangedClassloaders(expectedChanged0: java.lang.Boolean*) = { + def checkChangedClassloaders(tester: IntegrationTester, expectedChanged0: java.lang.Boolean*) = { val currentClassLoaderIds = - for ((frame, path) <- loadFrames(expectedChanged0.length)) + for ((frame, path) <- loadFrames(tester, expectedChanged0.length)) yield frame.classLoaderIdentity val changed = currentClassLoaderIds @@ -124,197 +123,197 @@ object MultiLevelBuildTests extends IntegrationTestSuite { savedClassLoaderIds = currentClassLoaderIds } - test("validEdits") { - runAssertSuccess("

hello

world

0.8.2

!") - checkWatchedFiles(fooPaths, buildPaths, buildPaths2, buildPaths3) + test("validEdits") - integrationTest { tester => import tester._ + runAssertSuccess(tester, "

hello

world

0.8.2

!") + checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) // First run all classloaders are new, except level 0 running user code // which doesn't need generate a classloader which never changes - checkChangedClassloaders(null, true, true, true) + checkChangedClassloaders(tester,null, true, true, true) modifyFile(workspacePath / "foo" / "src" / "Example.scala", _.replace("!", "?")) - runAssertSuccess("

hello

world

0.8.2

?") - checkWatchedFiles(fooPaths, buildPaths, buildPaths2, buildPaths3) + runAssertSuccess(tester, "

hello

world

0.8.2

?") + checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) // Second run with no build changes, all classloaders are unchanged - checkChangedClassloaders(null, false, false, false) + checkChangedClassloaders(tester,null, false, false, false) modifyFile(workspacePath / "build.mill", _.replace("hello", "HELLO")) - runAssertSuccess("

HELLO

world

0.8.2

?") - checkWatchedFiles(fooPaths, buildPaths, buildPaths2, buildPaths3) - checkChangedClassloaders(null, true, false, false) + runAssertSuccess(tester, "

HELLO

world

0.8.2

?") + checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester,null, true, false, false) modifyFile( workspacePath / "mill-build" / "build.mill", _.replace("def scalatagsVersion = ", "def scalatagsVersion = \"changed-\" + ") ) - runAssertSuccess("

HELLO

world

changed-0.8.2

?") - checkWatchedFiles(fooPaths, buildPaths, buildPaths2, buildPaths3) - checkChangedClassloaders(null, true, true, false) + runAssertSuccess(tester, "

HELLO

world

changed-0.8.2

?") + checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester,null, true, true, false) modifyFile( workspacePath / "mill-build" / "mill-build" / "build.mill", _.replace("0.8.2", "0.12.0") ) - runAssertSuccess("

HELLO

world

changed-0.12.0

?") - checkWatchedFiles(fooPaths, buildPaths, buildPaths2, buildPaths3) - checkChangedClassloaders(null, true, true, true) + runAssertSuccess(tester, "

HELLO

world

changed-0.12.0

?") + checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester,null, true, true, true) modifyFile( workspacePath / "mill-build" / "mill-build" / "build.mill", _.replace("0.12.0", "0.8.2") ) - runAssertSuccess("

HELLO

world

changed-0.8.2

?") - checkWatchedFiles(fooPaths, buildPaths, buildPaths2, buildPaths3) - checkChangedClassloaders(null, true, true, true) + runAssertSuccess(tester, "

HELLO

world

changed-0.8.2

?") + checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester,null, true, true, true) modifyFile( workspacePath / "mill-build" / "build.mill", _.replace("def scalatagsVersion = \"changed-\" + ", "def scalatagsVersion = ") ) - runAssertSuccess("

HELLO

world

0.8.2

?") - checkWatchedFiles(fooPaths, buildPaths, buildPaths2, buildPaths3) - checkChangedClassloaders(null, true, true, false) + runAssertSuccess(tester, "

HELLO

world

0.8.2

?") + checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester,null, true, true, false) modifyFile(workspacePath / "build.mill", _.replace("HELLO", "hello")) - runAssertSuccess("

hello

world

0.8.2

?") - checkWatchedFiles(fooPaths, buildPaths, buildPaths2, buildPaths3) - checkChangedClassloaders(null, true, false, false) + runAssertSuccess(tester, "

hello

world

0.8.2

?") + checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester,null, true, false, false) modifyFile(workspacePath / "foo" / "src" / "Example.scala", _.replace("?", "!")) - runAssertSuccess("

hello

world

0.8.2

!") - checkWatchedFiles(fooPaths, buildPaths, buildPaths2, buildPaths3) - checkChangedClassloaders(null, false, false, false) + runAssertSuccess(tester, "

hello

world

0.8.2

!") + checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester,null, false, false, false) } - test("parseErrorEdits") { + test("parseErrorEdits") - integrationTest { tester => import tester._ def causeParseError(p: os.Path) = modifyFile(p, _.replace("extends", "extendx")) def fixParseError(p: os.Path) = modifyFile(p, _.replace("extendx", "extends")) - runAssertSuccess("

hello

world

0.8.2

!") - checkWatchedFiles(fooPaths, buildPaths, buildPaths2, buildPaths3) - checkChangedClassloaders(null, true, true, true) + runAssertSuccess(tester, "

hello

world

0.8.2

!") + checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester,null, true, true, true) causeParseError(workspacePath / "build.mill") - evalCheckErr( + evalCheckErr(tester, "\n1 targets failed", "\ngenerateScriptSources build.mill" ) - checkWatchedFiles(Nil, buildPaths, Nil, Nil) + checkWatchedFiles(tester,Nil, buildPaths(tester), Nil, Nil) // When one of the meta-builds still has parse errors, all classloaders // remain null, because none of the meta-builds can evaluate. Only once // all of them parse successfully do we get a new set of classloaders for // every level of the meta-build - checkChangedClassloaders(null, null, null, null) + checkChangedClassloaders(tester,null, null, null, null) fixParseError(workspacePath / "build.mill") causeParseError(workspacePath / "mill-build" / "build.mill") - evalCheckErr( + evalCheckErr(tester, "\n1 targets failed", "\ngenerateScriptSources mill-build/build.mill" ) - checkWatchedFiles(Nil, Nil, buildPaths2, Nil) - checkChangedClassloaders(null, null, null, null) + checkWatchedFiles(tester,Nil, Nil, buildPaths2(tester), Nil) + checkChangedClassloaders(tester,null, null, null, null) fixParseError(workspacePath / "mill-build" / "build.mill") causeParseError(workspacePath / "mill-build" / "mill-build" / "build.mill") - evalCheckErr( + evalCheckErr(tester, "\n1 targets failed", "\ngenerateScriptSources mill-build/mill-build/build.mill" ) - checkWatchedFiles(Nil, Nil, Nil, buildPaths3) - checkChangedClassloaders(null, null, null, null) + checkWatchedFiles(tester,Nil, Nil, Nil, buildPaths3(tester)) + checkChangedClassloaders(tester,null, null, null, null) fixParseError(workspacePath / "mill-build" / "mill-build" / "build.mill") causeParseError(workspacePath / "mill-build" / "build.mill") - evalCheckErr( + evalCheckErr(tester, "\n1 targets failed", "\ngenerateScriptSources mill-build/build.mill" ) - checkWatchedFiles(Nil, Nil, buildPaths2, Nil) - checkChangedClassloaders(null, null, null, null) + checkWatchedFiles(tester,Nil, Nil, buildPaths2(tester), Nil) + checkChangedClassloaders(tester,null, null, null, null) fixParseError(workspacePath / "mill-build" / "build.mill") causeParseError(workspacePath / "build.mill") - evalCheckErr( + evalCheckErr(tester, "\n1 targets failed", "\ngenerateScriptSources build.mill" ) - checkWatchedFiles(Nil, buildPaths, Nil, Nil) - checkChangedClassloaders(null, null, null, null) + checkWatchedFiles(tester,Nil, buildPaths(tester), Nil, Nil) + checkChangedClassloaders(tester,null, null, null, null) fixParseError(workspacePath / "build.mill") - runAssertSuccess("

hello

world

0.8.2

!") - checkWatchedFiles(fooPaths, buildPaths, buildPaths2, buildPaths3) - checkChangedClassloaders(null, true, true, true) + runAssertSuccess(tester, "

hello

world

0.8.2

!") + checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester,null, true, true, true) } - test("compileErrorEdits") { + test("compileErrorEdits") - integrationTest { tester => import tester._ def causeCompileError(p: os.Path) = modifyFile(p, _ + "\nimport doesnt.exist") def fixCompileError(p: os.Path) = modifyFile(p, _.replace("import doesnt.exist", "")) - runAssertSuccess("

hello

world

0.8.2

!") - checkWatchedFiles(fooPaths, buildPaths, buildPaths2, buildPaths3) - checkChangedClassloaders(null, true, true, true) + runAssertSuccess(tester, "

hello

world

0.8.2

!") + checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester,null, true, true, true) causeCompileError(workspacePath / "build.mill") - evalCheckErr( + evalCheckErr(tester, "\n1 targets failed", // Ensure the file path in the compile error is properly adjusted to point // at the original source file and not the generated file (workspacePath / "build.mill").toString, "not found: value doesnt" ) - checkWatchedFiles(Nil, buildPaths, buildPaths2, buildPaths3) - checkChangedClassloaders(null, null, false, false) + checkWatchedFiles(tester,Nil, buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester,null, null, false, false) causeCompileError(workspacePath / "mill-build" / "build.mill") - evalCheckErr( + evalCheckErr(tester, "\n1 targets failed", (workspacePath / "mill-build" / "build.mill").toString, "not found: object doesnt" ) - checkWatchedFiles(Nil, Nil, buildPaths2, buildPaths3) - checkChangedClassloaders(null, null, null, false) + checkWatchedFiles(tester,Nil, Nil, buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester,null, null, null, false) causeCompileError(workspacePath / "mill-build" / "mill-build" / "build.mill") - evalCheckErr( + evalCheckErr(tester, "\n1 targets failed", (workspacePath / "mill-build" / "mill-build" / "build.mill").toString, "not found: object doesnt" ) - checkWatchedFiles(Nil, Nil, Nil, buildPaths3) - checkChangedClassloaders(null, null, null, null) + checkWatchedFiles(tester,Nil, Nil, Nil, buildPaths3(tester)) + checkChangedClassloaders(tester,null, null, null, null) fixCompileError(workspacePath / "mill-build" / "mill-build" / "build.mill") - evalCheckErr( + evalCheckErr(tester, "\n1 targets failed", (workspacePath / "mill-build" / "build.mill").toString, "not found: object doesnt" ) - checkWatchedFiles(Nil, Nil, buildPaths2, buildPaths3) - checkChangedClassloaders(null, null, null, true) + checkWatchedFiles(tester,Nil, Nil, buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester,null, null, null, true) fixCompileError(workspacePath / "mill-build" / "build.mill") - evalCheckErr( + evalCheckErr(tester, "\n1 targets failed", (workspacePath / "build.mill").toString, "not found: value doesnt" ) - checkWatchedFiles(Nil, buildPaths, buildPaths2, buildPaths3) - checkChangedClassloaders(null, null, true, false) + checkWatchedFiles(tester,Nil, buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester,null, null, true, false) fixCompileError(workspacePath / "build.mill") - runAssertSuccess("

hello

world

0.8.2

!") - checkWatchedFiles(fooPaths, buildPaths, buildPaths2, buildPaths3) - checkChangedClassloaders(null, true, false, false) + runAssertSuccess(tester, "

hello

world

0.8.2

!") + checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester,null, true, false, false) } - test("runtimeErrorEdits") { + test("runtimeErrorEdits") - integrationTest { tester => import tester._ val runErrorSnippet = """{ |override def runClasspath = T{ | throw new Exception("boom") @@ -327,58 +326,58 @@ object MultiLevelBuildTests extends IntegrationTestSuite { def fixRuntimeError(p: os.Path) = modifyFile(p, _.replaceFirst(Regex.quote(runErrorSnippet), "\\{")) - runAssertSuccess("

hello

world

0.8.2

!") - checkWatchedFiles(fooPaths, buildPaths, buildPaths2, buildPaths3) - checkChangedClassloaders(null, true, true, true) + runAssertSuccess(tester, "

hello

world

0.8.2

!") + checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester,null, true, true, true) causeRuntimeError(workspacePath / "build.mill") - evalCheckErr( + evalCheckErr(tester, "\n1 targets failed", "foo.runClasspath java.lang.Exception: boom" ) - checkWatchedFiles(fooPaths, buildPaths, buildPaths2, buildPaths3) - checkChangedClassloaders(null, true, false, false) + checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester,null, true, false, false) causeRuntimeError(workspacePath / "mill-build" / "build.mill") - evalCheckErr( + evalCheckErr(tester, "\n1 targets failed", "build.mill", "runClasspath java.lang.Exception: boom" ) - checkWatchedFiles(Nil, buildPaths, buildPaths2, buildPaths3) - checkChangedClassloaders(null, null, true, false) + checkWatchedFiles(tester,Nil, buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester,null, null, true, false) causeRuntimeError(workspacePath / "mill-build" / "mill-build" / "build.mill") - evalCheckErr( + evalCheckErr(tester, "\n1 targets failed", "build.mill", "runClasspath java.lang.Exception: boom" ) - checkWatchedFiles(Nil, Nil, buildPaths2, buildPaths3) - checkChangedClassloaders(null, null, null, true) + checkWatchedFiles(tester,Nil, Nil, buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester,null, null, null, true) fixRuntimeError(workspacePath / "mill-build" / "mill-build" / "build.mill") - evalCheckErr( + evalCheckErr(tester, "\n1 targets failed", "build.mill", "runClasspath java.lang.Exception: boom" ) - checkWatchedFiles(Nil, buildPaths, buildPaths2, buildPaths3) - checkChangedClassloaders(null, null, true, true) + checkWatchedFiles(tester,Nil, buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester,null, null, true, true) fixRuntimeError(workspacePath / "mill-build" / "build.mill") - evalCheckErr( + evalCheckErr(tester, "\n1 targets failed", "build.mill", "foo.runClasspath java.lang.Exception: boom" ) - checkWatchedFiles(fooPaths, buildPaths, buildPaths2, buildPaths3) - checkChangedClassloaders(null, true, true, false) + checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester,null, true, true, false) fixRuntimeError(workspacePath / "build.mill") - runAssertSuccess("

hello

world

0.8.2

!") - checkWatchedFiles(fooPaths, buildPaths, buildPaths2, buildPaths3) - checkChangedClassloaders(null, true, false, false) + runAssertSuccess(tester, "

hello

world

0.8.2

!") + checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester,null, true, false, false) } } diff --git a/integration/invalidation/watch-source-input/src/WatchSourceInputTests.scala b/integration/invalidation/watch-source-input/src/WatchSourceInputTests.scala index 6230a43a2fd..103b2c5075a 100644 --- a/integration/invalidation/watch-source-input/src/WatchSourceInputTests.scala +++ b/integration/invalidation/watch-source-input/src/WatchSourceInputTests.scala @@ -24,11 +24,9 @@ object WatchSourceInputTests extends IntegrationTestSuite { val maxDuration = 60000 val tests: Tests = Tests { - initWorkspace() - - def awaitCompletionMarker(name: String) = { + def awaitCompletionMarker(tester: IntegrationTester, name: String) = { val maxTime = System.currentTimeMillis() + maxDuration - while (!os.exists(workspacePath / "out" / name)) { + while (!os.exists(tester.workspacePath / "out" / name)) { if (System.currentTimeMillis() > maxTime) { sys.error(s"awaitCompletionMarker($name) timed out") } @@ -63,14 +61,14 @@ object WatchSourceInputTests extends IntegrationTestSuite { if (show) assert(shows == expectedShows.map('"' + _ + '"')) } - def testWatchSource(show: Boolean) = + def testWatchSource(tester: IntegrationTester, show: Boolean) = testBase(show) { (expectedOut, expectedErr, expectedShows) => val showArgs = if (show) Seq("show") else Nil - + import tester._ val evalResult = Future { eval(("--watch", showArgs, "qux"), timeout = maxDuration) } - awaitCompletionMarker("initialized0") - awaitCompletionMarker("quxRan0") + awaitCompletionMarker(tester, "initialized0") + awaitCompletionMarker(tester, "quxRan0") expectedOut.append( "Setting up build.mill" ) @@ -83,7 +81,7 @@ object WatchSourceInputTests extends IntegrationTestSuite { ) os.write.over(workspacePath / "foo1.txt", "edited-foo1") - awaitCompletionMarker("quxRan1") + awaitCompletionMarker(tester, "quxRan1") expectedErr.append( "Running qux foo contents edited-foo1 initial-foo2", "Running qux bar contents initial-bar" @@ -93,7 +91,7 @@ object WatchSourceInputTests extends IntegrationTestSuite { ) os.write.over(workspacePath / "foo2.txt", "edited-foo2") - awaitCompletionMarker("quxRan2") + awaitCompletionMarker(tester, "quxRan2") expectedErr.append( "Running qux foo contents edited-foo1 edited-foo2", "Running qux bar contents initial-bar" @@ -103,7 +101,7 @@ object WatchSourceInputTests extends IntegrationTestSuite { ) os.write.over(workspacePath / "bar.txt", "edited-bar") - awaitCompletionMarker("quxRan3") + awaitCompletionMarker(tester, "quxRan3") expectedErr.append( "Running qux foo contents edited-foo1 edited-foo2", "Running qux bar contents edited-bar" @@ -113,7 +111,7 @@ object WatchSourceInputTests extends IntegrationTestSuite { ) os.write.append(workspacePath / "build.mill", "\ndef unrelated = true") - awaitCompletionMarker("initialized1") + awaitCompletionMarker(tester, "initialized1") expectedOut.append( "Setting up build.mill" // These targets do not re-evaluate, because the change to the build @@ -126,7 +124,7 @@ object WatchSourceInputTests extends IntegrationTestSuite { ) os.write.over(workspacePath / "watchValue.txt", "exit") - awaitCompletionMarker("initialized2") + awaitCompletionMarker(tester, "initialized2") expectedOut.append("Setting up build.mill") Await.result(evalResult, Duration.apply(maxDuration, SECONDS)) @@ -135,18 +133,30 @@ object WatchSourceInputTests extends IntegrationTestSuite { test("sources") { // Make sure we clean up the workspace between retries - test("noshow") - retry(3) { if (!Util.isWindows) { initWorkspace(); testWatchSource(false) } } - test("show") - retry(3) { if (!Util.isWindows) { initWorkspace(); testWatchSource(true) } } + test("noshow") - integrationTest { tester => import tester._ + retry(3) { + if (!Util.isWindows) { + testWatchSource(tester, false) + } + } + } + test("show") - integrationTest { tester => import tester._ + retry(3) { + if (!Util.isWindows) { + testWatchSource(tester, true) + } + } + } } - def testWatchInput(show: Boolean) = + def testWatchInput(tester: IntegrationTester, show: Boolean) = testBase(show) { (expectedOut, expectedErr, expectedShows) => val showArgs = if (show) Seq("show") else Nil - + import tester._ val evalResult = Future { eval(("--watch", showArgs, "lol"), timeout = maxDuration) } - awaitCompletionMarker("initialized0") - awaitCompletionMarker("lolRan0") + awaitCompletionMarker(tester, "initialized0") + awaitCompletionMarker(tester, "lolRan0") expectedOut.append( "Setting up build.mill" ) @@ -156,17 +166,17 @@ object WatchSourceInputTests extends IntegrationTestSuite { expectedShows.append("Running lol baz contents initial-baz") os.write.over(workspacePath / "baz.txt", "edited-baz") - awaitCompletionMarker("lolRan1") + awaitCompletionMarker(tester, "lolRan1") expectedErr.append("Running lol baz contents edited-baz") expectedShows.append("Running lol baz contents edited-baz") os.write.over(workspacePath / "watchValue.txt", "edited-watchValue") - awaitCompletionMarker("initialized1") + awaitCompletionMarker(tester, "initialized1") expectedOut.append("Setting up build.mill") expectedShows.append("Running lol baz contents edited-baz") os.write.over(workspacePath / "watchValue.txt", "exit") - awaitCompletionMarker("initialized2") + awaitCompletionMarker(tester, "initialized2") expectedOut.append("Setting up build.mill") Await.result(evalResult, Duration.apply(maxDuration, SECONDS)) @@ -175,8 +185,20 @@ object WatchSourceInputTests extends IntegrationTestSuite { test("input") { // Make sure we clean up the workspace between retries - test("noshow") - retry(3) { if (!Util.isWindows) { initWorkspace(); testWatchInput(false) } } - test("show") - retry(3) { if (!Util.isWindows) { initWorkspace(); testWatchInput(true) } } + test("noshow") - integrationTest { tester => import tester._ + retry(3) { + if (!Util.isWindows) { + testWatchInput(tester, false) + } + } + } + test("show") - integrationTest { tester => import tester._ + retry(3) { + if (!Util.isWindows) { + testWatchInput(tester, true) + } + } + } } } } diff --git a/integration/invalidation/zinc-incremental-compilation/src/ZincIncrementalCompilationTests.scala b/integration/invalidation/zinc-incremental-compilation/src/ZincIncrementalCompilationTests.scala index cf61225ff9f..11ec9fa9db9 100644 --- a/integration/invalidation/zinc-incremental-compilation/src/ZincIncrementalCompilationTests.scala +++ b/integration/invalidation/zinc-incremental-compilation/src/ZincIncrementalCompilationTests.scala @@ -7,9 +7,8 @@ import utest._ // Regress test for issue https://github.com/com-lihaoyi/mill/issues/1901 object ZincIncrementalCompilationTests extends IntegrationTestSuite { val tests: Tests = Tests { - initWorkspace() - test("incremental compilation only compiles changed files") { - val successful = eval("app.compile") + test("incremental compilation only compiles changed files") - integrationTest { tester => import tester._ + val successful = tester.eval("app.compile") assert(successful.isSuccess) val appSrc = workspacePath / "app" / "src" / "main" / "scala" / "App.scala" @@ -25,7 +24,7 @@ object ZincIncrementalCompilationTests extends IntegrationTestSuite { println("** second run **") os.write.append(appSrc, "\n ") - val succ2nd = eval("app.compile") + val succ2nd = tester.eval("app.compile") assert(succ2nd.isSuccess) val appSrcInfo2 = os.stat(appSrc) diff --git a/main/client/test/src/mill/main/client/FileToStreamTailerTest.java b/main/client/test/src/mill/main/client/FileToStreamTailerTest.java index 929896f0f25..0c68b5e12fe 100644 --- a/main/client/test/src/mill/main/client/FileToStreamTailerTest.java +++ b/main/client/test/src/mill/main/client/FileToStreamTailerTest.java @@ -104,7 +104,7 @@ public FileToStreamTailerTest() { out.println("log line"); expectTrue(file.exists()); Thread.sleep(500); - expectEquals(bas.toString().trim, "log line"); + expectEquals(bas.toString().trim(), "log line"); } } }); diff --git a/testkit/src/mill/testkit/IntegrationTestSuite.scala b/testkit/src/mill/testkit/IntegrationTestSuite.scala index 9ad34228288..0fead3f9097 100644 --- a/testkit/src/mill/testkit/IntegrationTestSuite.scala +++ b/testkit/src/mill/testkit/IntegrationTestSuite.scala @@ -1,7 +1,10 @@ package mill.testkit -abstract class IntegrationTestSuite extends IntegrationTestSuiteBase with IntegrationTester.Impl { - override def utestAfterEach(path: Seq[String]): Unit = { - if (clientServerMode) close() +abstract class IntegrationTestSuite extends IntegrationTestSuiteBase { + def debugLog: Boolean = false + def integrationTest[T](t: IntegrationTester => T) = { + val tester = new IntegrationTester(clientServerMode, workspaceSourcePath, millExecutable, debugLog) + try t(tester) + finally tester.close() } } diff --git a/testkit/src/mill/testkit/IntegrationTestSuiteBase.scala b/testkit/src/mill/testkit/IntegrationTestSuiteBase.scala index b3a06993be1..95399abb9d3 100644 --- a/testkit/src/mill/testkit/IntegrationTestSuiteBase.scala +++ b/testkit/src/mill/testkit/IntegrationTestSuiteBase.scala @@ -4,8 +4,8 @@ import os.Path import utest._ abstract class IntegrationTestSuiteBase extends TestSuite { - def workspaceSourcePath: os.Path = os.Path(sys.env("MILL_TEST_RESOURCE_FOLDER")) - val clientServerMode: Boolean = sys.env("MILL_INTEGRATION_SERVER_MODE").toBoolean + protected def workspaceSourcePath: os.Path = os.Path(sys.env("MILL_TEST_RESOURCE_FOLDER")) + protected val clientServerMode: Boolean = sys.env("MILL_INTEGRATION_SERVER_MODE").toBoolean - def millExecutable: Path = os.Path(System.getenv("MILL_INTEGRATION_LAUNCHER"), os.pwd) + protected def millExecutable: Path = os.Path(System.getenv("MILL_INTEGRATION_LAUNCHER"), os.pwd) } diff --git a/testkit/src/mill/testkit/IntegrationTester.scala b/testkit/src/mill/testkit/IntegrationTester.scala index d6bece57248..a1cb878ea5a 100644 --- a/testkit/src/mill/testkit/IntegrationTester.scala +++ b/testkit/src/mill/testkit/IntegrationTester.scala @@ -23,13 +23,13 @@ import scala.util.control.NonFatal class IntegrationTester( val clientServerMode: Boolean, val workspaceSourcePath: os.Path, - val millExecutable: os.Path + val millExecutable: os.Path, + override val debugLog: Boolean = false ) extends IntegrationTester.Impl { initWorkspace() } object IntegrationTester { - /** * A very simplified version of `os.CommandResult` meant for easily * performing assertions against. From e6cd0d1fe2835c7028e51dc2e916dba8ae76d6b3 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 20:03:05 +0800 Subject: [PATCH 45/60] . --- .../test/src/mill/main/client/FileToStreamTailerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/client/test/src/mill/main/client/FileToStreamTailerTest.java b/main/client/test/src/mill/main/client/FileToStreamTailerTest.java index 929896f0f25..0c68b5e12fe 100644 --- a/main/client/test/src/mill/main/client/FileToStreamTailerTest.java +++ b/main/client/test/src/mill/main/client/FileToStreamTailerTest.java @@ -104,7 +104,7 @@ public FileToStreamTailerTest() { out.println("log line"); expectTrue(file.exists()); Thread.sleep(500); - expectEquals(bas.toString().trim, "log line"); + expectEquals(bas.toString().trim(), "log line"); } } }); From a02f68702935bedcc2e091a70146a2b168ea7a4f Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 20:05:37 +0800 Subject: [PATCH 46/60] . --- testkit/src/mill/testkit/IntegrationTesterBase.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testkit/src/mill/testkit/IntegrationTesterBase.scala b/testkit/src/mill/testkit/IntegrationTesterBase.scala index a67f5a7b27d..7e43e720e95 100644 --- a/testkit/src/mill/testkit/IntegrationTesterBase.scala +++ b/testkit/src/mill/testkit/IntegrationTesterBase.scala @@ -11,7 +11,7 @@ trait IntegrationTesterBase { * * Typically just `pwd`, which is a sandbox directory for test suites run using Mill. */ - val workspacePath: os.Path = os.pwd + val workspacePath: os.Path = os.temp(dir = os.pwd) /** * Initializes the workspace in preparation for integration testing From d202effbb8c0a2400097ad10f190c9e4350d5a7b Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 20:12:25 +0800 Subject: [PATCH 47/60] makedir --- testkit/src/mill/testkit/IntegrationTesterBase.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/testkit/src/mill/testkit/IntegrationTesterBase.scala b/testkit/src/mill/testkit/IntegrationTesterBase.scala index 7e43e720e95..95f263c4f02 100644 --- a/testkit/src/mill/testkit/IntegrationTesterBase.scala +++ b/testkit/src/mill/testkit/IntegrationTesterBase.scala @@ -18,6 +18,7 @@ trait IntegrationTesterBase { */ def initWorkspace(): Unit = { println(s"Copying integration test sources from $workspaceSourcePath to $workspacePath") + os.makeDir.all(workspacePath) os.list(workspacePath).foreach(os.remove.all(_)) os.list(workspaceSourcePath).filter(_.last != out).foreach(os.copy.into(_, workspacePath)) os.remove.all(workspacePath / "out") From 64becba28dbd8b3907519a4d621f174b1dcb00ea Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 20:13:04 +0800 Subject: [PATCH 48/60] makedir --- testkit/src/mill/testkit/IntegrationTesterBase.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testkit/src/mill/testkit/IntegrationTesterBase.scala b/testkit/src/mill/testkit/IntegrationTesterBase.scala index 95f263c4f02..ae6cbdea504 100644 --- a/testkit/src/mill/testkit/IntegrationTesterBase.scala +++ b/testkit/src/mill/testkit/IntegrationTesterBase.scala @@ -9,7 +9,8 @@ trait IntegrationTesterBase { * Mill build being tested. Contains the `build.mill` file, any application code, and * the `out/` folder containing the build output * - * Typically just `pwd`, which is a sandbox directory for test suites run using Mill. + * Typically a temp folder inside `pwd`, just in case there's some leftover + * files/processes from previous integration tests that may interfere with the current one */ val workspacePath: os.Path = os.temp(dir = os.pwd) From 4d7547ed2d1cf5369f18f662c90d3f062946e9ba Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 20:27:56 +0800 Subject: [PATCH 49/60] makedir --- testkit/src/mill/testkit/IntegrationTesterBase.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testkit/src/mill/testkit/IntegrationTesterBase.scala b/testkit/src/mill/testkit/IntegrationTesterBase.scala index ae6cbdea504..523fc2728a9 100644 --- a/testkit/src/mill/testkit/IntegrationTesterBase.scala +++ b/testkit/src/mill/testkit/IntegrationTesterBase.scala @@ -12,7 +12,7 @@ trait IntegrationTesterBase { * Typically a temp folder inside `pwd`, just in case there's some leftover * files/processes from previous integration tests that may interfere with the current one */ - val workspacePath: os.Path = os.temp(dir = os.pwd) + val workspacePath: os.Path = os.temp.dir(dir = os.pwd) /** * Initializes the workspace in preparation for integration testing From e3b325c3f1729a7117ebd7bf5398700ffbcfe084 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 20:59:24 +0800 Subject: [PATCH 50/60] . --- .github/workflows/actions.yml | 10 +++++----- ci/test-mill-dev.sh | 2 ++ ci/test-mill-release.sh | 2 ++ main/api/src/mill/api/Result.scala | 2 +- scalalib/src/mill/scalalib/JavaModule.scala | 6 +++++- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index ff5c4512ead..b0d307557e7 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -129,15 +129,15 @@ jobs: # just run a subset of examples/ on Windows, because for some reason running # the whole suite can take hours on windows v.s. half an hour on linux - java-version: 11 - millargs: '"{main,scalalib,bsp}.__.testCached"' + millargs: '"{main,scalalib,bsp}.__.test"' - java-version: 11 - millargs: '"example.scalalib.{basic,web}.__.fork.testCached"' + millargs: '"example.scalalib.{basic,web}.__.fork.test"' - java-version: 17 - millargs: "'integration.{feature,failure}[_].fork.testCached'" + millargs: "'integration.{feature,failure}[_].fork.test'" - java-version: 11 - millargs: "'integration.invalidation[_].server.testCached'" + millargs: "'integration.invalidation[_].server.test'" - java-version: 11 - millargs: "contrib.__.testCached" + millargs: "contrib.__.test" uses: ./.github/workflows/run-mill-action.yml with: diff --git a/ci/test-mill-dev.sh b/ci/test-mill-dev.sh index 44828909db0..8ffede49a8c 100755 --- a/ci/test-mill-dev.sh +++ b/ci/test-mill-dev.sh @@ -16,3 +16,5 @@ test -d $EXAMPLE/out/foo/3.3.3/compile.dest ./mill -i dist.run $EXAMPLE show "bar[2.13.8].assembly" test -f $EXAMPLE/out/bar/2.13.8/assembly.dest/out.jar + +./mill -i dist.run $EXAMPLE shutdown \ No newline at end of file diff --git a/ci/test-mill-release.sh b/ci/test-mill-release.sh index 562771dff96..56fd55d69c4 100755 --- a/ci/test-mill-release.sh +++ b/ci/test-mill-release.sh @@ -19,3 +19,5 @@ test -d $EXAMPLE/out/foo/3.3.3/compile.dest (cd $EXAMPLE && ../../../../out/dist/assembly.dest/mill show "bar[2.13.8].assembly") test -f $EXAMPLE/out/bar/2.13.8/assembly.dest/out.jar + +(cd $EXAMPLE && ../../../../out/dist/assembly.dest/mill shutdown) \ No newline at end of file diff --git a/main/api/src/mill/api/Result.scala b/main/api/src/mill/api/Result.scala index d2a57d6fdf7..ad7af1e051b 100644 --- a/main/api/src/mill/api/Result.scala +++ b/main/api/src/mill/api/Result.scala @@ -77,7 +77,7 @@ object Result { def flatMap[V](f: T => Result[V]): Failure[V] = { Failure(msg, value.flatMap(f(_).asSuccess.map(_.value))) } - override def toString = s"Failure($msg, $value)" + override def toString: String = s"Failure($msg, $value)" } /** diff --git a/scalalib/src/mill/scalalib/JavaModule.scala b/scalalib/src/mill/scalalib/JavaModule.scala index 98fdc303a40..297ba05b190 100644 --- a/scalalib/src/mill/scalalib/JavaModule.scala +++ b/scalalib/src/mill/scalalib/JavaModule.scala @@ -533,7 +533,11 @@ trait JavaModule * Resolved dependencies based on [[transitiveIvyDeps]] and [[transitiveCompileIvyDeps]]. */ def resolvedIvyDeps: T[Agg[PathRef]] = T { - defaultResolver().resolveDeps(transitiveCompileIvyDeps() ++ transitiveIvyDeps()) + def resolvedIvyDeps0() = defaultResolver().resolveDeps(transitiveCompileIvyDeps() ++ transitiveIvyDeps()) + try resolvedIvyDeps0() + catch{case e: java.nio.file.AccessDeniedException => + resolvedIvyDeps0() // this is caused by a coursier race condition on windows, just retry + } } /** From d07d69434451a483f49f896f6add566a41371369 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 21:14:00 +0800 Subject: [PATCH 51/60] . --- .../src/BuildFileInSubfolderTests.scala | 3 +- .../compile-error/src/CompileErrorTests.scala | 3 +- .../src/CrossCollisionsTests.scala | 3 +- .../src/InvalidMetaModuleTests.scala | 3 +- .../src/InvalidPackageDeclaration.scala | 3 +- .../src/InvalidRootModuleTests.scala | 3 +- .../src/InvalidSubfolderRootModuleTests.scala | 3 +- .../src/MisnamedRootModuleTests.scala | 3 +- .../src/MissingBuildFileTests.scala | 3 +- .../src/ModuleInitErrorTests.scala | 27 +- .../ModuleOutsideTopLevelModuleTests.scala | 3 +- .../src/NoModulesInHelperFileTests.scala | 3 +- .../src/PackageFileInRootTests.scala | 3 +- .../parse-error/src/ParseErrorTests.scala | 3 +- .../src/RootModuleCompileErrorTests.scala | 3 +- .../RootSubfolderModuleCollisionTests.scala | 3 +- .../SubfolderHelperModuleCollisionTests.scala | 3 +- .../src/SubfolderMissingBuildPrefix.scala | 3 +- .../ThingsOutsideTopLevelModuleTests.scala | 3 +- .../src/AuxiliaryClassFilesTests.scala | 83 ++--- .../src/DocAnnotationsTests.scala | 3 +- .../feature/hygiene/src/HygieneTests.scala | 3 +- .../src/ImportIvyWorkerInvalidation.scala | 3 +- .../feature/init/src/MillInitTests.scala | 3 +- .../large-project/src/LargeProjectTests.scala | 3 +- .../mill-jvm-opts/src/MillJvmOptsTests.scala | 3 +- .../src/NonIdentifierImport.scala | 3 +- .../src/MillPluginClasspathTest.scala | 6 +- .../src/PrivateMethodsTests.scala | 3 +- .../src/ImportRepoTests.scala | 3 +- .../scoverage/src/ScoverageTests.scala | 3 +- .../src/SubprocessStdoutTests.scala | 3 +- integration/ide/bloop/src/BloopTests.scala | 11 +- .../src/BspInstallDebugTests.scala | 3 +- .../ide/bsp-install/src/BspInstallTests.scala | 3 +- .../ide/bsp-modules/src/BspModulesTests.scala | 6 +- .../gen-idea/src/GenIdeaExtendedTests.scala | 3 +- .../ide/gen-idea/src/GenIdeaTests.scala | 6 +- .../codesig-hello/src/CodeSigHelloTests.scala | 3 +- .../src/CodeSigNestedTests.scala | 6 +- .../src/CodeSigScalaModuleTests.scala | 6 +- .../src/ScriptsInvalidationTests.scala | 43 +-- .../src/MultiLevelBuildTests.scala | 298 ++++++++++++------ .../src/WatchSourceInputTests.scala | 12 +- .../src/ZincIncrementalCompilationTests.scala | 3 +- scalalib/src/mill/scalalib/JavaModule.scala | 8 +- .../mill/testkit/IntegrationTestSuite.scala | 3 +- .../src/mill/testkit/IntegrationTester.scala | 1 + 48 files changed, 399 insertions(+), 219 deletions(-) diff --git a/integration/failure/build-file-in-subfolder/src/BuildFileInSubfolderTests.scala b/integration/failure/build-file-in-subfolder/src/BuildFileInSubfolderTests.scala index d2824c57259..bdfd5eef507 100644 --- a/integration/failure/build-file-in-subfolder/src/BuildFileInSubfolderTests.scala +++ b/integration/failure/build-file-in-subfolder/src/BuildFileInSubfolderTests.scala @@ -6,7 +6,8 @@ import utest._ object BuildFileInSubfolderTests extends IntegrationTestSuite { val tests: Tests = Tests { - test("success") - integrationTest { tester => import tester._ + test("success") - integrationTest { tester => + import tester._ val res = tester.eval(("resolve", "_")) assert(res.isSuccess == false) assert(res.err.contains("Mill build.mill files can only be in the project root")) diff --git a/integration/failure/compile-error/src/CompileErrorTests.scala b/integration/failure/compile-error/src/CompileErrorTests.scala index 30567116dfd..ecca74105eb 100644 --- a/integration/failure/compile-error/src/CompileErrorTests.scala +++ b/integration/failure/compile-error/src/CompileErrorTests.scala @@ -6,7 +6,8 @@ import utest._ object CompileErrorTests extends IntegrationTestSuite { val tests: Tests = Tests { - test - integrationTest { tester => import tester._ + test - integrationTest { tester => + import tester._ val res = tester.eval("foo.scalaVersion") assert(res.isSuccess == false) diff --git a/integration/failure/cross-collisions/src/CrossCollisionsTests.scala b/integration/failure/cross-collisions/src/CrossCollisionsTests.scala index d1d5b578a16..86e8fa4852d 100644 --- a/integration/failure/cross-collisions/src/CrossCollisionsTests.scala +++ b/integration/failure/cross-collisions/src/CrossCollisionsTests.scala @@ -6,7 +6,8 @@ import utest._ object CrossCollisionsTests extends IntegrationTestSuite { val tests: Tests = Tests { - test("detect-collision") - integrationTest { tester => import tester._ + test("detect-collision") - integrationTest { tester => + import tester._ val res = tester.eval(("resolve", "foo._")) assert(!res.isSuccess) assert(res.err.contains("Cross module ")) diff --git a/integration/failure/invalid-meta-module/src/InvalidMetaModuleTests.scala b/integration/failure/invalid-meta-module/src/InvalidMetaModuleTests.scala index 4b8e1c2e748..1411f3b8931 100644 --- a/integration/failure/invalid-meta-module/src/InvalidMetaModuleTests.scala +++ b/integration/failure/invalid-meta-module/src/InvalidMetaModuleTests.scala @@ -6,7 +6,8 @@ import utest._ object InvalidMetaModuleTests extends IntegrationTestSuite { val tests: Tests = Tests { - test("success") - integrationTest { tester => import tester._ + test("success") - integrationTest { tester => + import tester._ val res = tester.eval(("resolve", "_")) assert(res.isSuccess == false) assert(res.err.contains("object `package` ")) diff --git a/integration/failure/invalid-package-declaration/src/InvalidPackageDeclaration.scala b/integration/failure/invalid-package-declaration/src/InvalidPackageDeclaration.scala index a8ee628a53c..102579301fc 100644 --- a/integration/failure/invalid-package-declaration/src/InvalidPackageDeclaration.scala +++ b/integration/failure/invalid-package-declaration/src/InvalidPackageDeclaration.scala @@ -6,7 +6,8 @@ import utest._ object InvalidPackageDeclaration extends IntegrationTestSuite { val tests: Tests = Tests { - test("success") - integrationTest { tester => import tester._ + test("success") - integrationTest { tester => + import tester._ val res = tester.eval(("resolve", "_")) assert(res.isSuccess == false) assert(res.err.contains( diff --git a/integration/failure/invalid-root-module/src/InvalidRootModuleTests.scala b/integration/failure/invalid-root-module/src/InvalidRootModuleTests.scala index da4142f5899..8d04578b9e3 100644 --- a/integration/failure/invalid-root-module/src/InvalidRootModuleTests.scala +++ b/integration/failure/invalid-root-module/src/InvalidRootModuleTests.scala @@ -6,7 +6,8 @@ import utest._ object InvalidRootModuleTests extends IntegrationTestSuite { val tests: Tests = Tests { - test("success") - integrationTest { tester => import tester._ + test("success") - integrationTest { tester => + import tester._ val res = tester.eval(("resolve", "_")) assert(res.isSuccess == false) assert(res.err.contains("object `package` in ")) diff --git a/integration/failure/invalid-subfolder-root-module/src/InvalidSubfolderRootModuleTests.scala b/integration/failure/invalid-subfolder-root-module/src/InvalidSubfolderRootModuleTests.scala index b1faf917b0e..1e611a70802 100644 --- a/integration/failure/invalid-subfolder-root-module/src/InvalidSubfolderRootModuleTests.scala +++ b/integration/failure/invalid-subfolder-root-module/src/InvalidSubfolderRootModuleTests.scala @@ -6,7 +6,8 @@ import utest._ object InvalidSubfolderRootModuleTests extends IntegrationTestSuite { val tests: Tests = Tests { - test("success") - integrationTest { tester => import tester._ + test("success") - integrationTest { tester => + import tester._ val res = tester.eval(("resolve", "_")) assert(res.isSuccess == false) assert(res.err.contains("object `package` ")) diff --git a/integration/failure/misnamed-root-module/src/MisnamedRootModuleTests.scala b/integration/failure/misnamed-root-module/src/MisnamedRootModuleTests.scala index bba2bcffb8e..96ae3c3ef25 100644 --- a/integration/failure/misnamed-root-module/src/MisnamedRootModuleTests.scala +++ b/integration/failure/misnamed-root-module/src/MisnamedRootModuleTests.scala @@ -6,7 +6,8 @@ import utest._ object MisnamedRootModuleTests extends IntegrationTestSuite { val tests: Tests = Tests { - test("success") - integrationTest { tester => import tester._ + test("success") - integrationTest { tester => + import tester._ val res = tester.eval(("resolve", "_")) assert(!res.isSuccess) assert(res.err.contains( diff --git a/integration/failure/missing-build-file/src/MissingBuildFileTests.scala b/integration/failure/missing-build-file/src/MissingBuildFileTests.scala index 641c325d6a2..44011513372 100644 --- a/integration/failure/missing-build-file/src/MissingBuildFileTests.scala +++ b/integration/failure/missing-build-file/src/MissingBuildFileTests.scala @@ -6,7 +6,8 @@ import utest._ object MissingBuildFileTests extends IntegrationTestSuite { val tests: Tests = Tests { - test - integrationTest { tester => import tester._ + test - integrationTest { tester => + import tester._ val res = tester.eval(("resolve", "_")) assert(!res.isSuccess) val s"build.mill file not found in $msg. Are you in a Mill project folder?" = res.err diff --git a/integration/failure/module-init-error/src/ModuleInitErrorTests.scala b/integration/failure/module-init-error/src/ModuleInitErrorTests.scala index 0a3f0bb6272..29e74302364 100644 --- a/integration/failure/module-init-error/src/ModuleInitErrorTests.scala +++ b/integration/failure/module-init-error/src/ModuleInitErrorTests.scala @@ -7,7 +7,8 @@ import utest._ object ModuleInitErrorTests extends IntegrationTestSuite { def captureOutErr = true val tests: Tests = Tests { - test("resolve") - integrationTest { tester => import tester._ + test("resolve") - integrationTest { tester => + import tester._ // Ensure that resolve works even of the modules containing the resolved // tasks are broken val res1 = tester.eval(("resolve", "foo.fooTarget")) @@ -41,21 +42,24 @@ object ModuleInitErrorTests extends IntegrationTestSuite { assert(res4.out.contains("foo.fooTarget")) } - test("rootTarget") - integrationTest { tester => import tester._ + test("rootTarget") - integrationTest { tester => + import tester._ // If we specify a target in the root module, we are not // affected by the sub-modules failing to initialize val res = eval("rootTarget") assert(res.isSuccess == true) assert(res.out.contains("""Running rootTarget""")) } - test("rootCommand") - integrationTest { tester => import tester._ + test("rootCommand") - integrationTest { tester => + import tester._ // If we specify a target in the root module, we are not // affected by the sub-modules failing to initialize val res = eval(("rootCommand", "-s", "hello")) assert(res.isSuccess == true) assert(res.out.contains("""Running rootCommand hello""")) } - test("fooTarget") - integrationTest { tester => import tester._ + test("fooTarget") - integrationTest { tester => + import tester._ val res = eval("foo.fooTarget") assert(res.isSuccess == false) assert(fansi.Str(res.err).plainText.contains("""java.lang.Exception: Foo Boom""")) @@ -63,29 +67,34 @@ object ModuleInitErrorTests extends IntegrationTestSuite { // frames from the Mill launcher assert(fansi.Str(res.err).plainText.linesIterator.size < 20) } - test("fooCommand") - integrationTest { tester => import tester._ + test("fooCommand") - integrationTest { tester => + import tester._ val res = eval(("foo.fooCommand", "-s", "hello")) assert(res.isSuccess == false) assert(fansi.Str(res.err).plainText.contains("""java.lang.Exception: Foo Boom""")) assert(fansi.Str(res.err).plainText.linesIterator.size < 20) } - test("barTarget") - integrationTest { tester => import tester._ + test("barTarget") - integrationTest { tester => + import tester._ val res = eval("bar.barTarget") assert(res.isSuccess == true) assert(res.out.contains("""Running barTarget""")) } - test("barCommand") - integrationTest { tester => import tester._ + test("barCommand") - integrationTest { tester => + import tester._ val res = eval(("bar.barCommand", "-s", "hello")) assert(res.isSuccess == true) assert(res.out.contains("""Running barCommand hello""")) } - test("quxTarget") - integrationTest { tester => import tester._ + test("quxTarget") - integrationTest { tester => + import tester._ val res = eval("bar.qux.quxTarget") assert(res.isSuccess == false) assert(fansi.Str(res.err).plainText.contains("""java.lang.Exception: Qux Boom""")) assert(fansi.Str(res.err).plainText.linesIterator.size < 20) } - test("quxCommand") - integrationTest { tester => import tester._ + test("quxCommand") - integrationTest { tester => + import tester._ val res = eval(("bar.qux.quxCommand", "-s", "hello")) assert(res.isSuccess == false) assert(fansi.Str(res.err).plainText.contains("""java.lang.Exception: Qux Boom""")) diff --git a/integration/failure/module-outside-top-level-module/src/ModuleOutsideTopLevelModuleTests.scala b/integration/failure/module-outside-top-level-module/src/ModuleOutsideTopLevelModuleTests.scala index f028398e8a3..bbd7c6abbe8 100644 --- a/integration/failure/module-outside-top-level-module/src/ModuleOutsideTopLevelModuleTests.scala +++ b/integration/failure/module-outside-top-level-module/src/ModuleOutsideTopLevelModuleTests.scala @@ -6,7 +6,8 @@ import utest._ object ModuleOutsideTopLevelModuleTests extends IntegrationTestSuite { val tests: Tests = Tests { - test("success") - integrationTest { tester => import tester._ + test("success") - integrationTest { tester => + import tester._ val res = eval(("resolve", "_")) assert(!res.isSuccess) assert( diff --git a/integration/failure/no-modules-in-helper-file/src/NoModulesInHelperFileTests.scala b/integration/failure/no-modules-in-helper-file/src/NoModulesInHelperFileTests.scala index b1ad1da6fe9..6ebbc82b0a8 100644 --- a/integration/failure/no-modules-in-helper-file/src/NoModulesInHelperFileTests.scala +++ b/integration/failure/no-modules-in-helper-file/src/NoModulesInHelperFileTests.scala @@ -6,7 +6,8 @@ import utest._ object NoModulesInHelperFileTests extends IntegrationTestSuite { val tests: Tests = Tests { - test("success") - integrationTest { tester => import tester._ + test("success") - integrationTest { tester => + import tester._ val res = eval(("resolve", "_")) assert(res.isSuccess == false) assert( diff --git a/integration/failure/package-file-in-root/src/PackageFileInRootTests.scala b/integration/failure/package-file-in-root/src/PackageFileInRootTests.scala index 5ba7863efd1..df185f893d3 100644 --- a/integration/failure/package-file-in-root/src/PackageFileInRootTests.scala +++ b/integration/failure/package-file-in-root/src/PackageFileInRootTests.scala @@ -6,7 +6,8 @@ import utest._ object PackageFileInRootTests extends IntegrationTestSuite { val tests: Tests = Tests { - test("success") - integrationTest { tester => import tester._ + test("success") - integrationTest { tester => + import tester._ val res = eval(("resolve", "_")) assert(res.isSuccess == false) assert(res.err.contains("Mill package.mill files can only be in subfolders")) diff --git a/integration/failure/parse-error/src/ParseErrorTests.scala b/integration/failure/parse-error/src/ParseErrorTests.scala index 279cad11aa1..e3e9272da61 100644 --- a/integration/failure/parse-error/src/ParseErrorTests.scala +++ b/integration/failure/parse-error/src/ParseErrorTests.scala @@ -6,7 +6,8 @@ import utest._ object ParseErrorTests extends IntegrationTestSuite { val tests: Tests = Tests { - test - integrationTest { tester => import tester._ + test - integrationTest { tester => + import tester._ val res = eval("foo.scalaVersion") assert(res.isSuccess == false) diff --git a/integration/failure/root-module-compile-error/src/RootModuleCompileErrorTests.scala b/integration/failure/root-module-compile-error/src/RootModuleCompileErrorTests.scala index 5cf5182b95b..b78dfdc470a 100644 --- a/integration/failure/root-module-compile-error/src/RootModuleCompileErrorTests.scala +++ b/integration/failure/root-module-compile-error/src/RootModuleCompileErrorTests.scala @@ -6,7 +6,8 @@ import utest._ object RootModuleCompileErrorTests extends IntegrationTestSuite { val tests: Tests = Tests { - test - integrationTest { tester => import tester._ + test - integrationTest { tester => + import tester._ val res = eval("foo.scalaVersion") assert(res.isSuccess == false) diff --git a/integration/failure/root-subfolder-module-collision/src/RootSubfolderModuleCollisionTests.scala b/integration/failure/root-subfolder-module-collision/src/RootSubfolderModuleCollisionTests.scala index 7e05b994067..a43ab449975 100644 --- a/integration/failure/root-subfolder-module-collision/src/RootSubfolderModuleCollisionTests.scala +++ b/integration/failure/root-subfolder-module-collision/src/RootSubfolderModuleCollisionTests.scala @@ -6,7 +6,8 @@ import utest._ object RootSubfolderModuleCollisionTests extends IntegrationTestSuite { val tests: Tests = Tests { - test("success") - integrationTest { tester => import tester._ + test("success") - integrationTest { tester => + import tester._ val res = eval(("resolve", "_")) assert(res.isSuccess == false) assert(res.err.contains("cannot override final member")) diff --git a/integration/failure/subfolder-helper-module-collision/src/SubfolderHelperModuleCollisionTests.scala b/integration/failure/subfolder-helper-module-collision/src/SubfolderHelperModuleCollisionTests.scala index 5aa1758d301..c8e86115eff 100644 --- a/integration/failure/subfolder-helper-module-collision/src/SubfolderHelperModuleCollisionTests.scala +++ b/integration/failure/subfolder-helper-module-collision/src/SubfolderHelperModuleCollisionTests.scala @@ -6,7 +6,8 @@ import utest._ object SubfolderHelperModuleCollisionTests extends IntegrationTestSuite { val tests: Tests = Tests { - test("success") - integrationTest { tester => import tester._ + test("success") - integrationTest { tester => + import tester._ val res = eval(("resolve", "_")) assert(res.isSuccess == false) // Not a great error message but it will have to do for now diff --git a/integration/failure/subfolder-missing-build-prefix/src/SubfolderMissingBuildPrefix.scala b/integration/failure/subfolder-missing-build-prefix/src/SubfolderMissingBuildPrefix.scala index ad7a03b2387..e4d62b88ba1 100644 --- a/integration/failure/subfolder-missing-build-prefix/src/SubfolderMissingBuildPrefix.scala +++ b/integration/failure/subfolder-missing-build-prefix/src/SubfolderMissingBuildPrefix.scala @@ -6,7 +6,8 @@ import utest._ object SubfolderMissingBuildPrefix extends IntegrationTestSuite { val tests: Tests = Tests { - test("success") - integrationTest { tester => import tester._ + test("success") - integrationTest { tester => + import tester._ val res = eval(("resolve", "_")) assert(res.isSuccess == false) assert(res.err.contains("object y is not a member of package build_.sub")) diff --git a/integration/failure/things-outside-top-level-module/src/ThingsOutsideTopLevelModuleTests.scala b/integration/failure/things-outside-top-level-module/src/ThingsOutsideTopLevelModuleTests.scala index 9d7707db119..684a8503a0f 100644 --- a/integration/failure/things-outside-top-level-module/src/ThingsOutsideTopLevelModuleTests.scala +++ b/integration/failure/things-outside-top-level-module/src/ThingsOutsideTopLevelModuleTests.scala @@ -6,7 +6,8 @@ import utest._ object ThingsOutsideTopLevelModuleTests extends IntegrationTestSuite { val tests: Tests = Tests { - test("success") - integrationTest { tester => import tester._ + test("success") - integrationTest { tester => + import tester._ val res = eval(("resolve", "_")) assert(!res.isSuccess) assert( diff --git a/integration/feature/auxiliary-class-files/src/AuxiliaryClassFilesTests.scala b/integration/feature/auxiliary-class-files/src/AuxiliaryClassFilesTests.scala index 412c8ced7c7..88dbb7322d8 100644 --- a/integration/feature/auxiliary-class-files/src/AuxiliaryClassFilesTests.scala +++ b/integration/feature/auxiliary-class-files/src/AuxiliaryClassFilesTests.scala @@ -7,49 +7,54 @@ import utest._ // Regress test for issue https://github.com/com-lihaoyi/mill/issues/1901 object AuxiliaryClassFilesTests extends IntegrationTestSuite { val tests: Tests = Tests { - test("tasty files are deleted together with companion class files") - integrationTest { tester => import tester._ - assert(eval("app.jvm.compile").isSuccess) + test("tasty files are deleted together with companion class files") - integrationTest { + tester => + import tester._ + assert(eval("app.jvm.compile").isSuccess) - val classes = workspacePath / "out" / "app" / "jvm" / "compile.dest" / "classes" - val firstRun = os.list(classes).map(_.last) + val classes = workspacePath / "out" / "app" / "jvm" / "compile.dest" / "classes" + val firstRun = os.list(classes).map(_.last) - os.remove(workspacePath / "app" / "src" / "foo.scala") + os.remove(workspacePath / "app" / "src" / "foo.scala") - assert(eval("app.jvm.compile").isSuccess) + assert(eval("app.jvm.compile").isSuccess) - val secondRun = os.list(classes).map(_.last) + val secondRun = os.list(classes).map(_.last) - assert(firstRun == Seq("foo$.class", "foo.class", "foo.tasty")) - assert(secondRun == Seq.empty) + assert(firstRun == Seq("foo$.class", "foo.class", "foo.tasty")) + assert(secondRun == Seq.empty) } - test("compilation fails when deleting a class used by other files") - integrationTest { tester => import tester._ - os.write(workspacePath / "app" / "src" / "bar.scala", "object bar { println(foo) }") - val firstRunSuccessful = eval("app.jvm.compile") - assert(firstRunSuccessful.isSuccess) + test("compilation fails when deleting a class used by other files") - integrationTest { + tester => + import tester._ + os.write(workspacePath / "app" / "src" / "bar.scala", "object bar { println(foo) }") + val firstRunSuccessful = eval("app.jvm.compile") + assert(firstRunSuccessful.isSuccess) - val classes = workspacePath / "out" / "app" / "jvm" / "compile.dest" / "classes" - val firstRun = os.list(classes).map(_.last) + val classes = workspacePath / "out" / "app" / "jvm" / "compile.dest" / "classes" + val firstRun = os.list(classes).map(_.last) - os.remove(workspacePath / "app" / "src" / "foo.scala") + os.remove(workspacePath / "app" / "src" / "foo.scala") - val secondRunSuccessful = eval("app.jvm.compile") - assert(!secondRunSuccessful.isSuccess) + val secondRunSuccessful = eval("app.jvm.compile") + assert(!secondRunSuccessful.isSuccess) - val secondRun = os.list(classes).map(_.last) + val secondRun = os.list(classes).map(_.last) - assert(firstRun == Seq( - "bar$.class", - "bar.class", - "bar.tasty", - "foo$.class", - "foo.class", - "foo.tasty" - )) - assert(secondRun == Seq.empty) + assert(firstRun == Seq( + "bar$.class", + "bar.class", + "bar.tasty", + "foo$.class", + "foo.class", + "foo.tasty" + )) + assert(secondRun == Seq.empty) } - test("nir files are deleted together with companion class files") - integrationTest { tester => import tester._ + test("nir files are deleted together with companion class files") - integrationTest { tester => + import tester._ assert(eval("app.native.compile").isSuccess) val classes = workspacePath / "out" / "app" / "native" / "compile.dest" / "classes" @@ -65,20 +70,22 @@ object AuxiliaryClassFilesTests extends IntegrationTestSuite { assert(secondRun == Seq.empty) } - test("sjsir files are deleted together with companion class files") - integrationTest { tester => import tester._ - assert(eval("app.js.compile").isSuccess) + test("sjsir files are deleted together with companion class files") - integrationTest { + tester => + import tester._ + assert(eval("app.js.compile").isSuccess) - val classes = workspacePath / "out" / "app" / "js" / "compile.dest" / "classes" - val firstRun = os.list(classes).map(_.last) + val classes = workspacePath / "out" / "app" / "js" / "compile.dest" / "classes" + val firstRun = os.list(classes).map(_.last) - os.remove(workspacePath / "app" / "src" / "foo.scala") + os.remove(workspacePath / "app" / "src" / "foo.scala") - assert(eval("app.js.compile").isSuccess) + assert(eval("app.js.compile").isSuccess) - val secondRun = os.list(classes).map(_.last) + val secondRun = os.list(classes).map(_.last) - assert(firstRun == Seq("foo$.class", "foo$.sjsir", "foo.class", "foo.tasty")) - assert(secondRun == Seq.empty) + assert(firstRun == Seq("foo$.class", "foo$.sjsir", "foo.class", "foo.tasty")) + assert(secondRun == Seq.empty) } } } diff --git a/integration/feature/docannotations/src/DocAnnotationsTests.scala b/integration/feature/docannotations/src/DocAnnotationsTests.scala index 38506940327..31128bf670e 100644 --- a/integration/feature/docannotations/src/DocAnnotationsTests.scala +++ b/integration/feature/docannotations/src/DocAnnotationsTests.scala @@ -16,7 +16,8 @@ object DocAnnotationsTests extends IntegrationTestSuite { } val tests: Tests = Tests { - test("test") - integrationTest { tester => import tester._ + test("test") - integrationTest { tester => + import tester._ val res = eval(("inspect", "core.test.ivyDeps")) assert(res.isSuccess == true) diff --git a/integration/feature/hygiene/src/HygieneTests.scala b/integration/feature/hygiene/src/HygieneTests.scala index 679daa8815e..24f8a292cea 100644 --- a/integration/feature/hygiene/src/HygieneTests.scala +++ b/integration/feature/hygiene/src/HygieneTests.scala @@ -6,7 +6,8 @@ import utest._ object HygieneTests extends IntegrationTestSuite { val tests: Tests = Tests { - test - integrationTest { tester => import tester._ + test - integrationTest { tester => + import tester._ val res = eval("scala.foo") assert(res.isSuccess == true) val output = out("scala.foo").text diff --git a/integration/feature/import-ivy-worker-invalidation/src/ImportIvyWorkerInvalidation.scala b/integration/feature/import-ivy-worker-invalidation/src/ImportIvyWorkerInvalidation.scala index 29a4f4abbfe..f8b462dfabf 100644 --- a/integration/feature/import-ivy-worker-invalidation/src/ImportIvyWorkerInvalidation.scala +++ b/integration/feature/import-ivy-worker-invalidation/src/ImportIvyWorkerInvalidation.scala @@ -7,7 +7,8 @@ import utest._ object ImportIvyWorkerInvalidation extends IntegrationTestSuite { val tests: Tests = Tests { - test - integrationTest { tester => import tester._ + test - integrationTest { tester => + import tester._ assert(eval("app.compile").isSuccess) modifyFile( workspacePath / "build.mill", diff --git a/integration/feature/init/src/MillInitTests.scala b/integration/feature/init/src/MillInitTests.scala index 038a0eaa3bc..dc1738afcdd 100644 --- a/integration/feature/init/src/MillInitTests.scala +++ b/integration/feature/init/src/MillInitTests.scala @@ -6,7 +6,8 @@ import utest._ object MillInitTests extends IntegrationTestSuite { def tests: Tests = Tests { - test("Mill init works") - integrationTest { tester => import tester._ + test("Mill init works") - integrationTest { tester => + import tester._ eval(("init", "com-lihaoyi/mill-scala-hello.g8", "--name=example")).isSuccess ==> true val projFile = workspacePath / "example" / "build.sc" assert(os.exists(projFile)) diff --git a/integration/feature/large-project/src/LargeProjectTests.scala b/integration/feature/large-project/src/LargeProjectTests.scala index baf310dad3c..bd808b6a4a7 100644 --- a/integration/feature/large-project/src/LargeProjectTests.scala +++ b/integration/feature/large-project/src/LargeProjectTests.scala @@ -6,7 +6,8 @@ import utest._ object LargeProjectTests extends IntegrationTestSuite { val tests: Tests = Tests { - test("test") - integrationTest { tester => import tester._ + test("test") - integrationTest { tester => + import tester._ assert(eval("foo.common.one.compile").isSuccess) } diff --git a/integration/feature/mill-jvm-opts/src/MillJvmOptsTests.scala b/integration/feature/mill-jvm-opts/src/MillJvmOptsTests.scala index 1d946aaae3e..cbcd7ea48fd 100644 --- a/integration/feature/mill-jvm-opts/src/MillJvmOptsTests.scala +++ b/integration/feature/mill-jvm-opts/src/MillJvmOptsTests.scala @@ -6,7 +6,8 @@ import utest._ object MillJvmOptsTests extends IntegrationTestSuite { val tests: Tests = Tests { - test("JVM options from file .mill-jvm-opts are properly read") - integrationTest { tester => import tester._ + test("JVM options from file .mill-jvm-opts are properly read") - integrationTest { tester => + import tester._ assert(eval("checkJvmOpts").isSuccess) } } diff --git a/integration/feature/non-identifier-import/src/NonIdentifierImport.scala b/integration/feature/non-identifier-import/src/NonIdentifierImport.scala index 6edfca7da46..8a1cf72fa30 100644 --- a/integration/feature/non-identifier-import/src/NonIdentifierImport.scala +++ b/integration/feature/non-identifier-import/src/NonIdentifierImport.scala @@ -6,7 +6,8 @@ import utest._ object NonIdentifierImport extends IntegrationTestSuite { val tests: Tests = Tests { - test("test") - integrationTest { tester => import tester._ + test("test") - integrationTest { tester => + import tester._ assert(eval("foo-bar-module.compile").isSuccess) } } diff --git a/integration/feature/plugin-classpath/src/MillPluginClasspathTest.scala b/integration/feature/plugin-classpath/src/MillPluginClasspathTest.scala index 55973b75f98..65f0ca2fb2d 100644 --- a/integration/feature/plugin-classpath/src/MillPluginClasspathTest.scala +++ b/integration/feature/plugin-classpath/src/MillPluginClasspathTest.scala @@ -31,7 +31,8 @@ object MillPluginClasspathTest extends IntegrationTestSuite { val tests: Tests = Tests { - test("exclusions") - integrationTest { tester => import tester._ + test("exclusions") - integrationTest { tester => + import tester._ retry(3) { val res1 = eval(("--meta-level", "1", "resolveDepsExclusions")) assert(res1.isSuccess) @@ -43,7 +44,8 @@ object MillPluginClasspathTest extends IntegrationTestSuite { assert(diff.isEmpty) } } - test("runClasspath") - integrationTest { tester => import tester._ + test("runClasspath") - integrationTest { tester => + import tester._ retry(3) { // We expect Mill core transitive dependencies to be filtered out val res1 = eval(("--meta-level", "1", "runClasspath")) diff --git a/integration/feature/private-methods/src/PrivateMethodsTests.scala b/integration/feature/private-methods/src/PrivateMethodsTests.scala index f82846e534c..458866a09e5 100644 --- a/integration/feature/private-methods/src/PrivateMethodsTests.scala +++ b/integration/feature/private-methods/src/PrivateMethodsTests.scala @@ -6,7 +6,8 @@ import utest._ object PrivateMethodsTests extends IntegrationTestSuite { val tests: Tests = Tests { - test("simple") - integrationTest { tester => import tester._ + test("simple") - integrationTest { tester => + import tester._ // Simple public target depending on private target works val pub = eval(("show", "pub")) assert(pub.out == "\"priv\"") diff --git a/integration/feature/repo-config-via-import/src/ImportRepoTests.scala b/integration/feature/repo-config-via-import/src/ImportRepoTests.scala index 911a8803816..103ef1ba791 100644 --- a/integration/feature/repo-config-via-import/src/ImportRepoTests.scala +++ b/integration/feature/repo-config-via-import/src/ImportRepoTests.scala @@ -6,7 +6,8 @@ import utest._ object ImportRepoTests extends IntegrationTestSuite { val tests: Tests = Tests { - test("test") - integrationTest { tester => import tester._ + test("test") - integrationTest { tester => + import tester._ // Make sure, we propery parse a line: // ``` // import $repo.`file:///tmp/testrepo` diff --git a/integration/feature/scoverage/src/ScoverageTests.scala b/integration/feature/scoverage/src/ScoverageTests.scala index 5e85cbdb4b1..9f4a50ec5ae 100644 --- a/integration/feature/scoverage/src/ScoverageTests.scala +++ b/integration/feature/scoverage/src/ScoverageTests.scala @@ -6,7 +6,8 @@ import utest._ object ScoverageTests extends IntegrationTestSuite { val tests: Tests = Tests { - test("test") - integrationTest { tester => import tester._ + test("test") - integrationTest { tester => + import tester._ assert(eval("__.compile").isSuccess) assert(eval("core[2.13.11].scoverage.xmlReport").isSuccess) } diff --git a/integration/feature/subprocess-stdout/src/SubprocessStdoutTests.scala b/integration/feature/subprocess-stdout/src/SubprocessStdoutTests.scala index 5151f3257c2..1afd096811f 100644 --- a/integration/feature/subprocess-stdout/src/SubprocessStdoutTests.scala +++ b/integration/feature/subprocess-stdout/src/SubprocessStdoutTests.scala @@ -6,7 +6,8 @@ import utest._ object SubprocessStdoutTests extends IntegrationTestSuite { val tests: Tests = Tests { - test - integrationTest { tester => import tester._ + test - integrationTest { tester => + import tester._ val res1 = eval("inheritInterleaved", mergeErrIntoOut = true).out // Make sure that when a lot of printed/inherited stdout/stderr is printed // in quick succession, the output ordering is preserved and it doesn't get diff --git a/integration/ide/bloop/src/BloopTests.scala b/integration/ide/bloop/src/BloopTests.scala index dc5de41d38c..08ae4814932 100644 --- a/integration/ide/bloop/src/BloopTests.scala +++ b/integration/ide/bloop/src/BloopTests.scala @@ -6,24 +6,25 @@ import utest._ object BloopTests extends IntegrationTestSuite { - val tests: Tests = Tests { test("test") - { - - test("root module bloop config should be created") - integrationTest { tester => import tester._ + test("root module bloop config should be created") - integrationTest { tester => + import tester._ val installResult: Boolean = eval("mill.contrib.bloop.Bloop/install").isSuccess assert(installResult) assert(os.exists(workspacePath / ".bloop" / "root-module.json")) } - test("mill-build module bloop config should be created") - integrationTest { tester => import tester._ + test("mill-build module bloop config should be created") - integrationTest { tester => + import tester._ val installResult: Boolean = eval("mill.contrib.bloop.Bloop/install").isSuccess val millBuildJsonFile = workspacePath / ".bloop" / "mill-build-.json" assert(installResult) assert(os.exists(millBuildJsonFile)) } - test("mill-build config should contain build.mill source") - integrationTest { tester => import tester._ + test("mill-build config should contain build.mill source") - integrationTest { tester => + import tester._ val millBuildJsonFile = workspacePath / ".bloop" / "mill-build-.json" val config = ujson.read(os.read.stream(millBuildJsonFile)) val installResult: Boolean = eval("mill.contrib.bloop.Bloop/install").isSuccess diff --git a/integration/ide/bsp-install/src/BspInstallDebugTests.scala b/integration/ide/bsp-install/src/BspInstallDebugTests.scala index a2364544a16..cf831fabfb3 100644 --- a/integration/ide/bsp-install/src/BspInstallDebugTests.scala +++ b/integration/ide/bsp-install/src/BspInstallDebugTests.scala @@ -11,7 +11,8 @@ object BspInstallDebugTests extends IntegrationTestSuite { override val debugLog: Boolean = true def tests: Tests = Tests { - test("BSP install forwards --debug option to server") - integrationTest { tester => import tester._ + test("BSP install forwards --debug option to server") - integrationTest { tester => + import tester._ eval("mill.bsp.BSP/install").isSuccess ==> true val jsonFile = workspacePath / Constants.bspDir / s"${Constants.serverName}.json" assert(os.exists(jsonFile)) diff --git a/integration/ide/bsp-install/src/BspInstallTests.scala b/integration/ide/bsp-install/src/BspInstallTests.scala index 393be236c02..cc0206789c9 100644 --- a/integration/ide/bsp-install/src/BspInstallTests.scala +++ b/integration/ide/bsp-install/src/BspInstallTests.scala @@ -8,7 +8,8 @@ object BspInstallTests extends IntegrationTestSuite { val bsp4jVersion: String = sys.props.getOrElse("BSP4J_VERSION", ???) def tests: Tests = Tests { - test("BSP install") - integrationTest { tester => import tester._ + test("BSP install") - integrationTest { tester => + import tester._ assert(eval("mill.bsp.BSP/install").isSuccess) val jsonFile = workspacePath / Constants.bspDir / s"${Constants.serverName}.json" assert(os.exists(jsonFile)) diff --git a/integration/ide/bsp-modules/src/BspModulesTests.scala b/integration/ide/bsp-modules/src/BspModulesTests.scala index 50d5ad73d94..02ca46dda99 100644 --- a/integration/ide/bsp-modules/src/BspModulesTests.scala +++ b/integration/ide/bsp-modules/src/BspModulesTests.scala @@ -9,11 +9,13 @@ object BspModulesTests extends IntegrationTestSuite { def tests: Tests = Tests { test("BSP module with foreign modules") { - test("can be installed") - integrationTest { tester => import tester._ + test("can be installed") - integrationTest { tester => + import tester._ assert(eval("mill.bsp.BSP/install").isSuccess) os.exists(workspacePath / Constants.bspDir / s"${Constants.serverName}.json") ==> true } - test("ModuleUtils resolves all referenced transitive modules") - integrationTest { tester => import tester._ + test("ModuleUtils resolves all referenced transitive modules") - integrationTest { tester => + import tester._ val res = eval("validate") assert(res.isSuccess) val file = workspacePath / "out" / "validate.dest" / "transitive-modules.json" diff --git a/integration/ide/gen-idea/src/GenIdeaExtendedTests.scala b/integration/ide/gen-idea/src/GenIdeaExtendedTests.scala index fcef8837a0f..8a78aef6f16 100644 --- a/integration/ide/gen-idea/src/GenIdeaExtendedTests.scala +++ b/integration/ide/gen-idea/src/GenIdeaExtendedTests.scala @@ -11,7 +11,8 @@ object GenIdeaExtendedTests extends IntegrationTestSuite { override def workspaceSourcePath: Path = super.workspaceSourcePath / "extended" def tests: Tests = Tests { - test("genIdeaTests") - integrationTest { tester => import tester._ + test("genIdeaTests") - integrationTest { tester => + import tester._ val expectedBase = workspacePath / "idea" val resources = os.walk(expectedBase).filter(os.isFile).map(_.subRelativeTo(expectedBase)) diff --git a/integration/ide/gen-idea/src/GenIdeaTests.scala b/integration/ide/gen-idea/src/GenIdeaTests.scala index ac71e3480e1..209f5dcdbc5 100644 --- a/integration/ide/gen-idea/src/GenIdeaTests.scala +++ b/integration/ide/gen-idea/src/GenIdeaTests.scala @@ -12,7 +12,8 @@ object GenIdeaTests extends IntegrationTestSuite { override def workspaceSourcePath: Path = super.workspaceSourcePath / "hello-idea" def tests: Tests = Tests { - test("helper assertPartialContentMatches works") - integrationTest { tester => import tester._ + test("helper assertPartialContentMatches works") - integrationTest { tester => + import tester._ val testContent = s"""line 1 |line 2 @@ -51,7 +52,8 @@ object GenIdeaTests extends IntegrationTestSuite { () } - test("genIdeaTests") - integrationTest { tester => import tester._ + test("genIdeaTests") - integrationTest { tester => + import tester._ val expectedBase = workspacePath / "idea" val resources = os.walk(expectedBase).filter(os.isFile).map(_.subRelativeTo(expectedBase)) diff --git a/integration/invalidation/codesig-hello/src/CodeSigHelloTests.scala b/integration/invalidation/codesig-hello/src/CodeSigHelloTests.scala index 866374169f2..592c88a00b4 100644 --- a/integration/invalidation/codesig-hello/src/CodeSigHelloTests.scala +++ b/integration/invalidation/codesig-hello/src/CodeSigHelloTests.scala @@ -6,7 +6,8 @@ import utest._ object CodeSigHelloTests extends IntegrationTestSuite { val tests: Tests = Tests { - test("simple") - integrationTest { tester => import tester._ + test("simple") - integrationTest { tester => + import tester._ // Make sure the simplest case where we have a single target calling a single helper // method is properly invalidated when either the target body, or the helper method's body // is changed, or something changed in the constructor diff --git a/integration/invalidation/codesig-nested/src/CodeSigNestedTests.scala b/integration/invalidation/codesig-nested/src/CodeSigNestedTests.scala index 03bc8ea45b7..7f478c0101e 100644 --- a/integration/invalidation/codesig-nested/src/CodeSigNestedTests.scala +++ b/integration/invalidation/codesig-nested/src/CodeSigNestedTests.scala @@ -6,7 +6,8 @@ import utest._ object CodeSigNestedTests extends IntegrationTestSuite { val tests: Tests = Tests { - test("nested") - integrationTest { tester => import tester._ + test("nested") - integrationTest { tester => + import tester._ // Make sure the code-change invalidation works in more complex cases: multi-step // target graphs, targets inside module objects, targets inside module traits @@ -188,7 +189,8 @@ object CodeSigNestedTests extends IntegrationTestSuite { assert(addedNewlinesInsideCurlies.out == "") } - test("trait") - integrationTest { tester => import tester._ + test("trait") - integrationTest { tester => + import tester._ val initial = eval("traitOuter.traitInner.inner") assert( initial.out.linesIterator.toSet == Set( diff --git a/integration/invalidation/codesig-scalamodule/src/CodeSigScalaModuleTests.scala b/integration/invalidation/codesig-scalamodule/src/CodeSigScalaModuleTests.scala index 2642844052b..99b6e2081a4 100644 --- a/integration/invalidation/codesig-scalamodule/src/CodeSigScalaModuleTests.scala +++ b/integration/invalidation/codesig-scalamodule/src/CodeSigScalaModuleTests.scala @@ -9,7 +9,8 @@ object CodeSigScalaModuleTests extends IntegrationTestSuite { def filterLines(out: String) = { out.linesIterator.filter(!_.contains("[info]")).toSet } - test("single") - integrationTest { tester => import tester._ + test("single") - integrationTest { tester => + import tester._ // Tests for fine-grained method-based invalidation within a single ScalaModule // Check normal behavior for initial run and subsequent fully-cached run @@ -119,7 +120,8 @@ object CodeSigScalaModuleTests extends IntegrationTestSuite { ) } - test("multiple") - integrationTest { tester => import tester._ + test("multiple") - integrationTest { tester => + import tester._ // Tests for fine-grained method-based invalidation between multiple ScalaModules, // some related and some not diff --git a/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala b/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala index bd61a7dacd1..8e669c02435 100644 --- a/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala +++ b/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala @@ -13,27 +13,29 @@ object ScriptsInvalidationTests extends IntegrationTestSuite { } val tests: Tests = Tests { - test("should not invalidate tasks in different untouched sc files") - integrationTest { tester => import tester._ - // first run - val result = runTask(tester, "task") + test("should not invalidate tasks in different untouched sc files") - integrationTest { + tester => + import tester._ + // first run + val result = runTask(tester, "task") - val expected = Set("a", "d", "b", "c") - - assert(result == expected) + val expected = Set("a", "d", "b", "c") + assert(result == expected) - // second run modifying script - modifyFile( - workspacePath / "build.mill", - _.replace("""println("task")""", """System.out.println("task2")""") - ) + // second run modifying script + modifyFile( + workspacePath / "build.mill", + _.replace("""println("task")""", """System.out.println("task2")""") + ) - val stdout = runTask(tester, "task") + val stdout = runTask(tester, "task") - assert(stdout.isEmpty) + assert(stdout.isEmpty) } - test("should invalidate tasks if leaf file is changed") - integrationTest { tester => import tester._ + test("should invalidate tasks if leaf file is changed") - integrationTest { tester => + import tester._ // first run val result = runTask(tester, "task") @@ -53,14 +55,14 @@ object ScriptsInvalidationTests extends IntegrationTestSuite { assert(result2 == expected2) } - test("should handle submodules in scripts") - integrationTest { tester => import tester._ + test("should handle submodules in scripts") - integrationTest { tester => + import tester._ // first run val result = runTask(tester, "module.task") val expected = Set("a", "d", "b", "c", "task") assert(result == expected) - // second run modifying script modifyFile( workspacePath / "build.mill", @@ -72,7 +74,8 @@ object ScriptsInvalidationTests extends IntegrationTestSuite { assert(result2 == expected2) } - test("should handle ammonite ^ imports") - integrationTest { tester => import tester._ + test("should handle ammonite ^ imports") - integrationTest { tester => + import tester._ retry(3) { // first run val result = runTask(tester, "taskE") @@ -92,14 +95,16 @@ object ScriptsInvalidationTests extends IntegrationTestSuite { assert(result2 == expected2) } } - test("should handle ammonite paths with symbols") - integrationTest { tester => import tester._ + test("should handle ammonite paths with symbols") - integrationTest { tester => + import tester._ val result = runTask(tester, "taskSymbols") val expected = Set("taskSymbols") assert(result == expected) } - test("should handle ammonite files with symbols") - integrationTest { tester => import tester._ + test("should handle ammonite files with symbols") - integrationTest { tester => + import tester._ val result = runTask(tester, "taskSymbolsInFile") val expected = Set("taskSymbolsInFile") diff --git a/integration/invalidation/multi-level-editing/src/MultiLevelBuildTests.scala b/integration/invalidation/multi-level-editing/src/MultiLevelBuildTests.scala index 30eb9666685..8a0741bee8b 100644 --- a/integration/invalidation/multi-level-editing/src/MultiLevelBuildTests.scala +++ b/integration/invalidation/multi-level-editing/src/MultiLevelBuildTests.scala @@ -50,7 +50,7 @@ object MultiLevelBuildTests extends IntegrationTestSuite { for (depth <- Range(0, n)) yield { val path = - tester. workspacePath / "out" / Seq.fill(depth)(millBuild) / millRunnerState + tester.workspacePath / "out" / Seq.fill(depth)(millBuild) / millRunnerState if (os.exists(path)) upickle.default.read[RunnerState.Frame.Logged](os.read(path)) -> path else RunnerState.Frame.Logged(Map(), Seq(), Seq(), None, Seq(), 0) -> path } @@ -61,7 +61,9 @@ object MultiLevelBuildTests extends IntegrationTestSuite { * appropriate files to get watched */ def checkWatchedFiles(tester: IntegrationTester, expected0: Seq[os.Path]*) = { - for ((expectedWatched0, (frame, path)) <- expected0.zip(loadFrames(tester, expected0.length))) { + for ( + (expectedWatched0, (frame, path)) <- expected0.zip(loadFrames(tester, expected0.length)) + ) { val frameWatched = frame .evalWatched .map(_.path) @@ -99,7 +101,10 @@ object MultiLevelBuildTests extends IntegrationTestSuite { * the previous classloader was re-used, `null` means there is no * classloader at that level */ - def checkChangedClassloaders(tester: IntegrationTester, expectedChanged0: java.lang.Boolean*) = { + def checkChangedClassloaders( + tester: IntegrationTester, + expectedChanged0: java.lang.Boolean* + ) = { val currentClassLoaderIds = for ((frame, path) <- loadFrames(tester, expectedChanged0.length)) yield frame.classLoaderIdentity @@ -123,68 +128,124 @@ object MultiLevelBuildTests extends IntegrationTestSuite { savedClassLoaderIds = currentClassLoaderIds } - test("validEdits") - integrationTest { tester => import tester._ + test("validEdits") - integrationTest { tester => + import tester._ runAssertSuccess(tester, "

hello

world

0.8.2

!") - checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkWatchedFiles( + tester, + fooPaths(tester), + buildPaths(tester), + buildPaths2(tester), + buildPaths3(tester) + ) // First run all classloaders are new, except level 0 running user code // which doesn't need generate a classloader which never changes - checkChangedClassloaders(tester,null, true, true, true) + checkChangedClassloaders(tester, null, true, true, true) modifyFile(workspacePath / "foo" / "src" / "Example.scala", _.replace("!", "?")) runAssertSuccess(tester, "

hello

world

0.8.2

?") - checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkWatchedFiles( + tester, + fooPaths(tester), + buildPaths(tester), + buildPaths2(tester), + buildPaths3(tester) + ) // Second run with no build changes, all classloaders are unchanged - checkChangedClassloaders(tester,null, false, false, false) + checkChangedClassloaders(tester, null, false, false, false) modifyFile(workspacePath / "build.mill", _.replace("hello", "HELLO")) runAssertSuccess(tester, "

HELLO

world

0.8.2

?") - checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) - checkChangedClassloaders(tester,null, true, false, false) + checkWatchedFiles( + tester, + fooPaths(tester), + buildPaths(tester), + buildPaths2(tester), + buildPaths3(tester) + ) + checkChangedClassloaders(tester, null, true, false, false) modifyFile( workspacePath / "mill-build" / "build.mill", _.replace("def scalatagsVersion = ", "def scalatagsVersion = \"changed-\" + ") ) runAssertSuccess(tester, "

HELLO

world

changed-0.8.2

?") - checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) - checkChangedClassloaders(tester,null, true, true, false) + checkWatchedFiles( + tester, + fooPaths(tester), + buildPaths(tester), + buildPaths2(tester), + buildPaths3(tester) + ) + checkChangedClassloaders(tester, null, true, true, false) modifyFile( workspacePath / "mill-build" / "mill-build" / "build.mill", _.replace("0.8.2", "0.12.0") ) runAssertSuccess(tester, "

HELLO

world

changed-0.12.0

?") - checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) - checkChangedClassloaders(tester,null, true, true, true) + checkWatchedFiles( + tester, + fooPaths(tester), + buildPaths(tester), + buildPaths2(tester), + buildPaths3(tester) + ) + checkChangedClassloaders(tester, null, true, true, true) modifyFile( workspacePath / "mill-build" / "mill-build" / "build.mill", _.replace("0.12.0", "0.8.2") ) runAssertSuccess(tester, "

HELLO

world

changed-0.8.2

?") - checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) - checkChangedClassloaders(tester,null, true, true, true) + checkWatchedFiles( + tester, + fooPaths(tester), + buildPaths(tester), + buildPaths2(tester), + buildPaths3(tester) + ) + checkChangedClassloaders(tester, null, true, true, true) modifyFile( workspacePath / "mill-build" / "build.mill", _.replace("def scalatagsVersion = \"changed-\" + ", "def scalatagsVersion = ") ) runAssertSuccess(tester, "

HELLO

world

0.8.2

?") - checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) - checkChangedClassloaders(tester,null, true, true, false) + checkWatchedFiles( + tester, + fooPaths(tester), + buildPaths(tester), + buildPaths2(tester), + buildPaths3(tester) + ) + checkChangedClassloaders(tester, null, true, true, false) modifyFile(workspacePath / "build.mill", _.replace("HELLO", "hello")) runAssertSuccess(tester, "

hello

world

0.8.2

?") - checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) - checkChangedClassloaders(tester,null, true, false, false) + checkWatchedFiles( + tester, + fooPaths(tester), + buildPaths(tester), + buildPaths2(tester), + buildPaths3(tester) + ) + checkChangedClassloaders(tester, null, true, false, false) modifyFile(workspacePath / "foo" / "src" / "Example.scala", _.replace("?", "!")) runAssertSuccess(tester, "

hello

world

0.8.2

!") - checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) - checkChangedClassloaders(tester,null, false, false, false) + checkWatchedFiles( + tester, + fooPaths(tester), + buildPaths(tester), + buildPaths2(tester), + buildPaths3(tester) + ) + checkChangedClassloaders(tester, null, false, false, false) } - test("parseErrorEdits") - integrationTest { tester => import tester._ + test("parseErrorEdits") - integrationTest { tester => + import tester._ def causeParseError(p: os.Path) = modifyFile(p, _.replace("extends", "extendx")) @@ -192,64 +253,66 @@ object MultiLevelBuildTests extends IntegrationTestSuite { modifyFile(p, _.replace("extendx", "extends")) runAssertSuccess(tester, "

hello

world

0.8.2

!") - checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) - checkChangedClassloaders(tester,null, true, true, true) + checkWatchedFiles( + tester, + fooPaths(tester), + buildPaths(tester), + buildPaths2(tester), + buildPaths3(tester) + ) + checkChangedClassloaders(tester, null, true, true, true) causeParseError(workspacePath / "build.mill") - evalCheckErr(tester, - "\n1 targets failed", - "\ngenerateScriptSources build.mill" - ) - checkWatchedFiles(tester,Nil, buildPaths(tester), Nil, Nil) + evalCheckErr(tester, "\n1 targets failed", "\ngenerateScriptSources build.mill") + checkWatchedFiles(tester, Nil, buildPaths(tester), Nil, Nil) // When one of the meta-builds still has parse errors, all classloaders // remain null, because none of the meta-builds can evaluate. Only once // all of them parse successfully do we get a new set of classloaders for // every level of the meta-build - checkChangedClassloaders(tester,null, null, null, null) + checkChangedClassloaders(tester, null, null, null, null) fixParseError(workspacePath / "build.mill") causeParseError(workspacePath / "mill-build" / "build.mill") - evalCheckErr(tester, - "\n1 targets failed", - "\ngenerateScriptSources mill-build/build.mill" - ) - checkWatchedFiles(tester,Nil, Nil, buildPaths2(tester), Nil) - checkChangedClassloaders(tester,null, null, null, null) + evalCheckErr(tester, "\n1 targets failed", "\ngenerateScriptSources mill-build/build.mill") + checkWatchedFiles(tester, Nil, Nil, buildPaths2(tester), Nil) + checkChangedClassloaders(tester, null, null, null, null) fixParseError(workspacePath / "mill-build" / "build.mill") causeParseError(workspacePath / "mill-build" / "mill-build" / "build.mill") - evalCheckErr(tester, + evalCheckErr( + tester, "\n1 targets failed", "\ngenerateScriptSources mill-build/mill-build/build.mill" ) - checkWatchedFiles(tester,Nil, Nil, Nil, buildPaths3(tester)) - checkChangedClassloaders(tester,null, null, null, null) + checkWatchedFiles(tester, Nil, Nil, Nil, buildPaths3(tester)) + checkChangedClassloaders(tester, null, null, null, null) fixParseError(workspacePath / "mill-build" / "mill-build" / "build.mill") causeParseError(workspacePath / "mill-build" / "build.mill") - evalCheckErr(tester, - "\n1 targets failed", - "\ngenerateScriptSources mill-build/build.mill" - ) - checkWatchedFiles(tester,Nil, Nil, buildPaths2(tester), Nil) - checkChangedClassloaders(tester,null, null, null, null) + evalCheckErr(tester, "\n1 targets failed", "\ngenerateScriptSources mill-build/build.mill") + checkWatchedFiles(tester, Nil, Nil, buildPaths2(tester), Nil) + checkChangedClassloaders(tester, null, null, null, null) fixParseError(workspacePath / "mill-build" / "build.mill") causeParseError(workspacePath / "build.mill") - evalCheckErr(tester, - "\n1 targets failed", - "\ngenerateScriptSources build.mill" - ) - checkWatchedFiles(tester,Nil, buildPaths(tester), Nil, Nil) - checkChangedClassloaders(tester,null, null, null, null) + evalCheckErr(tester, "\n1 targets failed", "\ngenerateScriptSources build.mill") + checkWatchedFiles(tester, Nil, buildPaths(tester), Nil, Nil) + checkChangedClassloaders(tester, null, null, null, null) fixParseError(workspacePath / "build.mill") runAssertSuccess(tester, "

hello

world

0.8.2

!") - checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) - checkChangedClassloaders(tester,null, true, true, true) + checkWatchedFiles( + tester, + fooPaths(tester), + buildPaths(tester), + buildPaths2(tester), + buildPaths3(tester) + ) + checkChangedClassloaders(tester, null, true, true, true) } - test("compileErrorEdits") - integrationTest { tester => import tester._ + test("compileErrorEdits") - integrationTest { tester => + import tester._ def causeCompileError(p: os.Path) = modifyFile(p, _ + "\nimport doesnt.exist") @@ -257,63 +320,81 @@ object MultiLevelBuildTests extends IntegrationTestSuite { modifyFile(p, _.replace("import doesnt.exist", "")) runAssertSuccess(tester, "

hello

world

0.8.2

!") - checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) - checkChangedClassloaders(tester,null, true, true, true) + checkWatchedFiles( + tester, + fooPaths(tester), + buildPaths(tester), + buildPaths2(tester), + buildPaths3(tester) + ) + checkChangedClassloaders(tester, null, true, true, true) causeCompileError(workspacePath / "build.mill") - evalCheckErr(tester, + evalCheckErr( + tester, "\n1 targets failed", // Ensure the file path in the compile error is properly adjusted to point // at the original source file and not the generated file (workspacePath / "build.mill").toString, "not found: value doesnt" ) - checkWatchedFiles(tester,Nil, buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) - checkChangedClassloaders(tester,null, null, false, false) + checkWatchedFiles(tester, Nil, buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester, null, null, false, false) causeCompileError(workspacePath / "mill-build" / "build.mill") - evalCheckErr(tester, + evalCheckErr( + tester, "\n1 targets failed", (workspacePath / "mill-build" / "build.mill").toString, "not found: object doesnt" ) - checkWatchedFiles(tester,Nil, Nil, buildPaths2(tester), buildPaths3(tester)) - checkChangedClassloaders(tester,null, null, null, false) + checkWatchedFiles(tester, Nil, Nil, buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester, null, null, null, false) causeCompileError(workspacePath / "mill-build" / "mill-build" / "build.mill") - evalCheckErr(tester, + evalCheckErr( + tester, "\n1 targets failed", (workspacePath / "mill-build" / "mill-build" / "build.mill").toString, "not found: object doesnt" ) - checkWatchedFiles(tester,Nil, Nil, Nil, buildPaths3(tester)) - checkChangedClassloaders(tester,null, null, null, null) + checkWatchedFiles(tester, Nil, Nil, Nil, buildPaths3(tester)) + checkChangedClassloaders(tester, null, null, null, null) fixCompileError(workspacePath / "mill-build" / "mill-build" / "build.mill") - evalCheckErr(tester, + evalCheckErr( + tester, "\n1 targets failed", (workspacePath / "mill-build" / "build.mill").toString, "not found: object doesnt" ) - checkWatchedFiles(tester,Nil, Nil, buildPaths2(tester), buildPaths3(tester)) - checkChangedClassloaders(tester,null, null, null, true) + checkWatchedFiles(tester, Nil, Nil, buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester, null, null, null, true) fixCompileError(workspacePath / "mill-build" / "build.mill") - evalCheckErr(tester, + evalCheckErr( + tester, "\n1 targets failed", (workspacePath / "build.mill").toString, "not found: value doesnt" ) - checkWatchedFiles(tester,Nil, buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) - checkChangedClassloaders(tester,null, null, true, false) + checkWatchedFiles(tester, Nil, buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester, null, null, true, false) fixCompileError(workspacePath / "build.mill") runAssertSuccess(tester, "

hello

world

0.8.2

!") - checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) - checkChangedClassloaders(tester,null, true, false, false) + checkWatchedFiles( + tester, + fooPaths(tester), + buildPaths(tester), + buildPaths2(tester), + buildPaths3(tester) + ) + checkChangedClassloaders(tester, null, true, false, false) } - test("runtimeErrorEdits") - integrationTest { tester => import tester._ + test("runtimeErrorEdits") - integrationTest { tester => + import tester._ val runErrorSnippet = """{ |override def runClasspath = T{ | throw new Exception("boom") @@ -327,57 +408,82 @@ object MultiLevelBuildTests extends IntegrationTestSuite { modifyFile(p, _.replaceFirst(Regex.quote(runErrorSnippet), "\\{")) runAssertSuccess(tester, "

hello

world

0.8.2

!") - checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) - checkChangedClassloaders(tester,null, true, true, true) + checkWatchedFiles( + tester, + fooPaths(tester), + buildPaths(tester), + buildPaths2(tester), + buildPaths3(tester) + ) + checkChangedClassloaders(tester, null, true, true, true) causeRuntimeError(workspacePath / "build.mill") - evalCheckErr(tester, - "\n1 targets failed", - "foo.runClasspath java.lang.Exception: boom" + evalCheckErr(tester, "\n1 targets failed", "foo.runClasspath java.lang.Exception: boom") + checkWatchedFiles( + tester, + fooPaths(tester), + buildPaths(tester), + buildPaths2(tester), + buildPaths3(tester) ) - checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) - checkChangedClassloaders(tester,null, true, false, false) + checkChangedClassloaders(tester, null, true, false, false) causeRuntimeError(workspacePath / "mill-build" / "build.mill") - evalCheckErr(tester, + evalCheckErr( + tester, "\n1 targets failed", "build.mill", "runClasspath java.lang.Exception: boom" ) - checkWatchedFiles(tester,Nil, buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) - checkChangedClassloaders(tester,null, null, true, false) + checkWatchedFiles(tester, Nil, buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester, null, null, true, false) causeRuntimeError(workspacePath / "mill-build" / "mill-build" / "build.mill") - evalCheckErr(tester, + evalCheckErr( + tester, "\n1 targets failed", "build.mill", "runClasspath java.lang.Exception: boom" ) - checkWatchedFiles(tester,Nil, Nil, buildPaths2(tester), buildPaths3(tester)) - checkChangedClassloaders(tester,null, null, null, true) + checkWatchedFiles(tester, Nil, Nil, buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester, null, null, null, true) fixRuntimeError(workspacePath / "mill-build" / "mill-build" / "build.mill") - evalCheckErr(tester, + evalCheckErr( + tester, "\n1 targets failed", "build.mill", "runClasspath java.lang.Exception: boom" ) - checkWatchedFiles(tester,Nil, buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) - checkChangedClassloaders(tester,null, null, true, true) + checkWatchedFiles(tester, Nil, buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) + checkChangedClassloaders(tester, null, null, true, true) fixRuntimeError(workspacePath / "mill-build" / "build.mill") - evalCheckErr(tester, + evalCheckErr( + tester, "\n1 targets failed", "build.mill", "foo.runClasspath java.lang.Exception: boom" ) - checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) - checkChangedClassloaders(tester,null, true, true, false) + checkWatchedFiles( + tester, + fooPaths(tester), + buildPaths(tester), + buildPaths2(tester), + buildPaths3(tester) + ) + checkChangedClassloaders(tester, null, true, true, false) fixRuntimeError(workspacePath / "build.mill") runAssertSuccess(tester, "

hello

world

0.8.2

!") - checkWatchedFiles(tester,fooPaths(tester), buildPaths(tester), buildPaths2(tester), buildPaths3(tester)) - checkChangedClassloaders(tester,null, true, false, false) + checkWatchedFiles( + tester, + fooPaths(tester), + buildPaths(tester), + buildPaths2(tester), + buildPaths3(tester) + ) + checkChangedClassloaders(tester, null, true, false, false) } } diff --git a/integration/invalidation/watch-source-input/src/WatchSourceInputTests.scala b/integration/invalidation/watch-source-input/src/WatchSourceInputTests.scala index 103b2c5075a..7b41f214a1e 100644 --- a/integration/invalidation/watch-source-input/src/WatchSourceInputTests.scala +++ b/integration/invalidation/watch-source-input/src/WatchSourceInputTests.scala @@ -133,14 +133,16 @@ object WatchSourceInputTests extends IntegrationTestSuite { test("sources") { // Make sure we clean up the workspace between retries - test("noshow") - integrationTest { tester => import tester._ + test("noshow") - integrationTest { tester => + import tester._ retry(3) { if (!Util.isWindows) { testWatchSource(tester, false) } } } - test("show") - integrationTest { tester => import tester._ + test("show") - integrationTest { tester => + import tester._ retry(3) { if (!Util.isWindows) { testWatchSource(tester, true) @@ -185,14 +187,16 @@ object WatchSourceInputTests extends IntegrationTestSuite { test("input") { // Make sure we clean up the workspace between retries - test("noshow") - integrationTest { tester => import tester._ + test("noshow") - integrationTest { tester => + import tester._ retry(3) { if (!Util.isWindows) { testWatchInput(tester, false) } } } - test("show") - integrationTest { tester => import tester._ + test("show") - integrationTest { tester => + import tester._ retry(3) { if (!Util.isWindows) { testWatchInput(tester, true) diff --git a/integration/invalidation/zinc-incremental-compilation/src/ZincIncrementalCompilationTests.scala b/integration/invalidation/zinc-incremental-compilation/src/ZincIncrementalCompilationTests.scala index 11ec9fa9db9..a8b7719d472 100644 --- a/integration/invalidation/zinc-incremental-compilation/src/ZincIncrementalCompilationTests.scala +++ b/integration/invalidation/zinc-incremental-compilation/src/ZincIncrementalCompilationTests.scala @@ -7,7 +7,8 @@ import utest._ // Regress test for issue https://github.com/com-lihaoyi/mill/issues/1901 object ZincIncrementalCompilationTests extends IntegrationTestSuite { val tests: Tests = Tests { - test("incremental compilation only compiles changed files") - integrationTest { tester => import tester._ + test("incremental compilation only compiles changed files") - integrationTest { tester => + import tester._ val successful = tester.eval("app.compile") assert(successful.isSuccess) diff --git a/scalalib/src/mill/scalalib/JavaModule.scala b/scalalib/src/mill/scalalib/JavaModule.scala index 297ba05b190..508793a2664 100644 --- a/scalalib/src/mill/scalalib/JavaModule.scala +++ b/scalalib/src/mill/scalalib/JavaModule.scala @@ -533,10 +533,12 @@ trait JavaModule * Resolved dependencies based on [[transitiveIvyDeps]] and [[transitiveCompileIvyDeps]]. */ def resolvedIvyDeps: T[Agg[PathRef]] = T { - def resolvedIvyDeps0() = defaultResolver().resolveDeps(transitiveCompileIvyDeps() ++ transitiveIvyDeps()) + def resolvedIvyDeps0() = + defaultResolver().resolveDeps(transitiveCompileIvyDeps() ++ transitiveIvyDeps()) try resolvedIvyDeps0() - catch{case e: java.nio.file.AccessDeniedException => - resolvedIvyDeps0() // this is caused by a coursier race condition on windows, just retry + catch { + case e: java.nio.file.AccessDeniedException => + resolvedIvyDeps0() // this is caused by a coursier race condition on windows, just retry } } diff --git a/testkit/src/mill/testkit/IntegrationTestSuite.scala b/testkit/src/mill/testkit/IntegrationTestSuite.scala index 0fead3f9097..975295127c8 100644 --- a/testkit/src/mill/testkit/IntegrationTestSuite.scala +++ b/testkit/src/mill/testkit/IntegrationTestSuite.scala @@ -3,7 +3,8 @@ package mill.testkit abstract class IntegrationTestSuite extends IntegrationTestSuiteBase { def debugLog: Boolean = false def integrationTest[T](t: IntegrationTester => T) = { - val tester = new IntegrationTester(clientServerMode, workspaceSourcePath, millExecutable, debugLog) + val tester = + new IntegrationTester(clientServerMode, workspaceSourcePath, millExecutable, debugLog) try t(tester) finally tester.close() } diff --git a/testkit/src/mill/testkit/IntegrationTester.scala b/testkit/src/mill/testkit/IntegrationTester.scala index a1cb878ea5a..9ddc8350f88 100644 --- a/testkit/src/mill/testkit/IntegrationTester.scala +++ b/testkit/src/mill/testkit/IntegrationTester.scala @@ -30,6 +30,7 @@ class IntegrationTester( } object IntegrationTester { + /** * A very simplified version of `os.CommandResult` meant for easily * performing assertions against. From 7fa79bbffb8e4f61a96a51b20658e3a62412e0c4 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 21:22:10 +0800 Subject: [PATCH 52/60] . --- .../src/BuildFileInSubfolderTests.scala | 4 +-- .../compile-error/src/CompileErrorTests.scala | 4 +-- .../src/CrossCollisionsTests.scala | 4 +-- .../src/InvalidMetaModuleTests.scala | 4 +-- .../src/InvalidPackageDeclaration.scala | 4 +-- .../src/InvalidRootModuleTests.scala | 4 +-- .../src/InvalidSubfolderRootModuleTests.scala | 4 +-- .../src/MisnamedRootModuleTests.scala | 4 +-- .../src/MissingBuildFileTests.scala | 4 +-- .../src/ModuleInitErrorTests.scala | 4 +-- .../ModuleOutsideTopLevelModuleTests.scala | 4 +-- .../src/NoModulesInHelperFileTests.scala | 4 +-- .../src/PackageFileInRootTests.scala | 4 +-- .../parse-error/src/ParseErrorTests.scala | 4 +-- .../src/RootModuleCompileErrorTests.scala | 4 +-- .../RootSubfolderModuleCollisionTests.scala | 4 +-- .../SubfolderHelperModuleCollisionTests.scala | 4 +-- .../src/SubfolderMissingBuildPrefix.scala | 4 +-- .../ThingsOutsideTopLevelModuleTests.scala | 4 +-- .../src/AuxiliaryClassFilesTests.scala | 4 +-- .../src/DocAnnotationsTests.scala | 4 +-- .../feature/hygiene/src/HygieneTests.scala | 4 +-- .../src/ImportIvyWorkerInvalidation.scala | 4 +-- .../feature/init/src/MillInitTests.scala | 4 +-- .../large-project/src/LargeProjectTests.scala | 4 +-- .../mill-jvm-opts/src/MillJvmOptsTests.scala | 4 +-- .../src/NonIdentifierImport.scala | 4 +-- .../src/MillPluginClasspathTest.scala | 4 +-- .../src/PrivateMethodsTests.scala | 4 +-- .../src/ImportRepoTests.scala | 4 +-- .../scoverage/src/ScoverageTests.scala | 4 +-- .../src/SubprocessStdoutTests.scala | 4 +-- integration/ide/bloop/src/BloopTests.scala | 4 +-- .../src/BspInstallDebugTests.scala | 4 +-- .../ide/bsp-install/src/BspInstallTests.scala | 4 +-- .../ide/bsp-modules/src/BspModulesTests.scala | 4 +-- .../gen-idea/src/GenIdeaExtendedTests.scala | 4 +-- .../ide/gen-idea/src/GenIdeaTests.scala | 4 +-- .../codesig-hello/src/CodeSigHelloTests.scala | 4 +-- .../src/CodeSigNestedTests.scala | 4 +-- .../src/CodeSigScalaModuleTests.scala | 4 +-- .../src/ScriptsInvalidationTests.scala | 4 +-- .../src/MultiLevelBuildTests.scala | 4 +-- .../src/WatchSourceInputTests.scala | 4 +-- .../src/ZincIncrementalCompilationTests.scala | 4 +-- .../src/mill/testkit/ExampleTestSuite.scala | 6 +++- .../mill/testkit/IntegrationTestSuite.scala | 14 ++++----- .../testkit/IntegrationTestSuiteBase.scala | 16 +++++++--- .../mill/testkit/IntegrationTesterTests.scala | 31 +++++++++---------- 49 files changed, 128 insertions(+), 119 deletions(-) diff --git a/integration/failure/build-file-in-subfolder/src/BuildFileInSubfolderTests.scala b/integration/failure/build-file-in-subfolder/src/BuildFileInSubfolderTests.scala index bdfd5eef507..39f5c8725d5 100644 --- a/integration/failure/build-file-in-subfolder/src/BuildFileInSubfolderTests.scala +++ b/integration/failure/build-file-in-subfolder/src/BuildFileInSubfolderTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object BuildFileInSubfolderTests extends IntegrationTestSuite { +object BuildFileInSubfolderTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("success") - integrationTest { tester => import tester._ diff --git a/integration/failure/compile-error/src/CompileErrorTests.scala b/integration/failure/compile-error/src/CompileErrorTests.scala index ecca74105eb..a55e21e3f46 100644 --- a/integration/failure/compile-error/src/CompileErrorTests.scala +++ b/integration/failure/compile-error/src/CompileErrorTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object CompileErrorTests extends IntegrationTestSuite { +object CompileErrorTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test - integrationTest { tester => import tester._ diff --git a/integration/failure/cross-collisions/src/CrossCollisionsTests.scala b/integration/failure/cross-collisions/src/CrossCollisionsTests.scala index 86e8fa4852d..29c50592832 100644 --- a/integration/failure/cross-collisions/src/CrossCollisionsTests.scala +++ b/integration/failure/cross-collisions/src/CrossCollisionsTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object CrossCollisionsTests extends IntegrationTestSuite { +object CrossCollisionsTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("detect-collision") - integrationTest { tester => import tester._ diff --git a/integration/failure/invalid-meta-module/src/InvalidMetaModuleTests.scala b/integration/failure/invalid-meta-module/src/InvalidMetaModuleTests.scala index 1411f3b8931..fc7d3705435 100644 --- a/integration/failure/invalid-meta-module/src/InvalidMetaModuleTests.scala +++ b/integration/failure/invalid-meta-module/src/InvalidMetaModuleTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object InvalidMetaModuleTests extends IntegrationTestSuite { +object InvalidMetaModuleTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("success") - integrationTest { tester => import tester._ diff --git a/integration/failure/invalid-package-declaration/src/InvalidPackageDeclaration.scala b/integration/failure/invalid-package-declaration/src/InvalidPackageDeclaration.scala index 102579301fc..91393ac7c5c 100644 --- a/integration/failure/invalid-package-declaration/src/InvalidPackageDeclaration.scala +++ b/integration/failure/invalid-package-declaration/src/InvalidPackageDeclaration.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object InvalidPackageDeclaration extends IntegrationTestSuite { +object InvalidPackageDeclaration extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("success") - integrationTest { tester => import tester._ diff --git a/integration/failure/invalid-root-module/src/InvalidRootModuleTests.scala b/integration/failure/invalid-root-module/src/InvalidRootModuleTests.scala index 8d04578b9e3..bf7eb81ff24 100644 --- a/integration/failure/invalid-root-module/src/InvalidRootModuleTests.scala +++ b/integration/failure/invalid-root-module/src/InvalidRootModuleTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object InvalidRootModuleTests extends IntegrationTestSuite { +object InvalidRootModuleTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("success") - integrationTest { tester => import tester._ diff --git a/integration/failure/invalid-subfolder-root-module/src/InvalidSubfolderRootModuleTests.scala b/integration/failure/invalid-subfolder-root-module/src/InvalidSubfolderRootModuleTests.scala index 1e611a70802..fc45ec4b3af 100644 --- a/integration/failure/invalid-subfolder-root-module/src/InvalidSubfolderRootModuleTests.scala +++ b/integration/failure/invalid-subfolder-root-module/src/InvalidSubfolderRootModuleTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object InvalidSubfolderRootModuleTests extends IntegrationTestSuite { +object InvalidSubfolderRootModuleTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("success") - integrationTest { tester => import tester._ diff --git a/integration/failure/misnamed-root-module/src/MisnamedRootModuleTests.scala b/integration/failure/misnamed-root-module/src/MisnamedRootModuleTests.scala index 96ae3c3ef25..62dfb7169d5 100644 --- a/integration/failure/misnamed-root-module/src/MisnamedRootModuleTests.scala +++ b/integration/failure/misnamed-root-module/src/MisnamedRootModuleTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object MisnamedRootModuleTests extends IntegrationTestSuite { +object MisnamedRootModuleTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("success") - integrationTest { tester => import tester._ diff --git a/integration/failure/missing-build-file/src/MissingBuildFileTests.scala b/integration/failure/missing-build-file/src/MissingBuildFileTests.scala index 44011513372..56356623695 100644 --- a/integration/failure/missing-build-file/src/MissingBuildFileTests.scala +++ b/integration/failure/missing-build-file/src/MissingBuildFileTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object MissingBuildFileTests extends IntegrationTestSuite { +object MissingBuildFileTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test - integrationTest { tester => import tester._ diff --git a/integration/failure/module-init-error/src/ModuleInitErrorTests.scala b/integration/failure/module-init-error/src/ModuleInitErrorTests.scala index 29e74302364..1f8ecb34d45 100644 --- a/integration/failure/module-init-error/src/ModuleInitErrorTests.scala +++ b/integration/failure/module-init-error/src/ModuleInitErrorTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object ModuleInitErrorTests extends IntegrationTestSuite { +object ModuleInitErrorTests extends UtestIntegrationTestSuite { def captureOutErr = true val tests: Tests = Tests { test("resolve") - integrationTest { tester => diff --git a/integration/failure/module-outside-top-level-module/src/ModuleOutsideTopLevelModuleTests.scala b/integration/failure/module-outside-top-level-module/src/ModuleOutsideTopLevelModuleTests.scala index bbd7c6abbe8..28aac9aea3a 100644 --- a/integration/failure/module-outside-top-level-module/src/ModuleOutsideTopLevelModuleTests.scala +++ b/integration/failure/module-outside-top-level-module/src/ModuleOutsideTopLevelModuleTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object ModuleOutsideTopLevelModuleTests extends IntegrationTestSuite { +object ModuleOutsideTopLevelModuleTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("success") - integrationTest { tester => import tester._ diff --git a/integration/failure/no-modules-in-helper-file/src/NoModulesInHelperFileTests.scala b/integration/failure/no-modules-in-helper-file/src/NoModulesInHelperFileTests.scala index 6ebbc82b0a8..f68f2b874c3 100644 --- a/integration/failure/no-modules-in-helper-file/src/NoModulesInHelperFileTests.scala +++ b/integration/failure/no-modules-in-helper-file/src/NoModulesInHelperFileTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object NoModulesInHelperFileTests extends IntegrationTestSuite { +object NoModulesInHelperFileTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("success") - integrationTest { tester => import tester._ diff --git a/integration/failure/package-file-in-root/src/PackageFileInRootTests.scala b/integration/failure/package-file-in-root/src/PackageFileInRootTests.scala index df185f893d3..e193c0534fa 100644 --- a/integration/failure/package-file-in-root/src/PackageFileInRootTests.scala +++ b/integration/failure/package-file-in-root/src/PackageFileInRootTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object PackageFileInRootTests extends IntegrationTestSuite { +object PackageFileInRootTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("success") - integrationTest { tester => import tester._ diff --git a/integration/failure/parse-error/src/ParseErrorTests.scala b/integration/failure/parse-error/src/ParseErrorTests.scala index e3e9272da61..8206a60ad60 100644 --- a/integration/failure/parse-error/src/ParseErrorTests.scala +++ b/integration/failure/parse-error/src/ParseErrorTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object ParseErrorTests extends IntegrationTestSuite { +object ParseErrorTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test - integrationTest { tester => import tester._ diff --git a/integration/failure/root-module-compile-error/src/RootModuleCompileErrorTests.scala b/integration/failure/root-module-compile-error/src/RootModuleCompileErrorTests.scala index b78dfdc470a..d84b9483a14 100644 --- a/integration/failure/root-module-compile-error/src/RootModuleCompileErrorTests.scala +++ b/integration/failure/root-module-compile-error/src/RootModuleCompileErrorTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object RootModuleCompileErrorTests extends IntegrationTestSuite { +object RootModuleCompileErrorTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test - integrationTest { tester => import tester._ diff --git a/integration/failure/root-subfolder-module-collision/src/RootSubfolderModuleCollisionTests.scala b/integration/failure/root-subfolder-module-collision/src/RootSubfolderModuleCollisionTests.scala index a43ab449975..2becba29e17 100644 --- a/integration/failure/root-subfolder-module-collision/src/RootSubfolderModuleCollisionTests.scala +++ b/integration/failure/root-subfolder-module-collision/src/RootSubfolderModuleCollisionTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object RootSubfolderModuleCollisionTests extends IntegrationTestSuite { +object RootSubfolderModuleCollisionTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("success") - integrationTest { tester => import tester._ diff --git a/integration/failure/subfolder-helper-module-collision/src/SubfolderHelperModuleCollisionTests.scala b/integration/failure/subfolder-helper-module-collision/src/SubfolderHelperModuleCollisionTests.scala index c8e86115eff..fde047ca517 100644 --- a/integration/failure/subfolder-helper-module-collision/src/SubfolderHelperModuleCollisionTests.scala +++ b/integration/failure/subfolder-helper-module-collision/src/SubfolderHelperModuleCollisionTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object SubfolderHelperModuleCollisionTests extends IntegrationTestSuite { +object SubfolderHelperModuleCollisionTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("success") - integrationTest { tester => import tester._ diff --git a/integration/failure/subfolder-missing-build-prefix/src/SubfolderMissingBuildPrefix.scala b/integration/failure/subfolder-missing-build-prefix/src/SubfolderMissingBuildPrefix.scala index e4d62b88ba1..02e744e219d 100644 --- a/integration/failure/subfolder-missing-build-prefix/src/SubfolderMissingBuildPrefix.scala +++ b/integration/failure/subfolder-missing-build-prefix/src/SubfolderMissingBuildPrefix.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object SubfolderMissingBuildPrefix extends IntegrationTestSuite { +object SubfolderMissingBuildPrefix extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("success") - integrationTest { tester => import tester._ diff --git a/integration/failure/things-outside-top-level-module/src/ThingsOutsideTopLevelModuleTests.scala b/integration/failure/things-outside-top-level-module/src/ThingsOutsideTopLevelModuleTests.scala index 684a8503a0f..cf71ac33e5c 100644 --- a/integration/failure/things-outside-top-level-module/src/ThingsOutsideTopLevelModuleTests.scala +++ b/integration/failure/things-outside-top-level-module/src/ThingsOutsideTopLevelModuleTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object ThingsOutsideTopLevelModuleTests extends IntegrationTestSuite { +object ThingsOutsideTopLevelModuleTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("success") - integrationTest { tester => import tester._ diff --git a/integration/feature/auxiliary-class-files/src/AuxiliaryClassFilesTests.scala b/integration/feature/auxiliary-class-files/src/AuxiliaryClassFilesTests.scala index 88dbb7322d8..e481db1bff9 100644 --- a/integration/feature/auxiliary-class-files/src/AuxiliaryClassFilesTests.scala +++ b/integration/feature/auxiliary-class-files/src/AuxiliaryClassFilesTests.scala @@ -1,11 +1,11 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ // Regress test for issue https://github.com/com-lihaoyi/mill/issues/1901 -object AuxiliaryClassFilesTests extends IntegrationTestSuite { +object AuxiliaryClassFilesTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("tasty files are deleted together with companion class files") - integrationTest { tester => diff --git a/integration/feature/docannotations/src/DocAnnotationsTests.scala b/integration/feature/docannotations/src/DocAnnotationsTests.scala index 31128bf670e..b23fdeb9b36 100644 --- a/integration/feature/docannotations/src/DocAnnotationsTests.scala +++ b/integration/feature/docannotations/src/DocAnnotationsTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object DocAnnotationsTests extends IntegrationTestSuite { +object DocAnnotationsTests extends UtestIntegrationTestSuite { def globMatches(glob: String, input: String): Boolean = { StringContext .glob( diff --git a/integration/feature/hygiene/src/HygieneTests.scala b/integration/feature/hygiene/src/HygieneTests.scala index 24f8a292cea..c6094f5f421 100644 --- a/integration/feature/hygiene/src/HygieneTests.scala +++ b/integration/feature/hygiene/src/HygieneTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object HygieneTests extends IntegrationTestSuite { +object HygieneTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test - integrationTest { tester => import tester._ diff --git a/integration/feature/import-ivy-worker-invalidation/src/ImportIvyWorkerInvalidation.scala b/integration/feature/import-ivy-worker-invalidation/src/ImportIvyWorkerInvalidation.scala index f8b462dfabf..41c1ec01022 100644 --- a/integration/feature/import-ivy-worker-invalidation/src/ImportIvyWorkerInvalidation.scala +++ b/integration/feature/import-ivy-worker-invalidation/src/ImportIvyWorkerInvalidation.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object ImportIvyWorkerInvalidation extends IntegrationTestSuite { +object ImportIvyWorkerInvalidation extends UtestIntegrationTestSuite { val tests: Tests = Tests { test - integrationTest { tester => diff --git a/integration/feature/init/src/MillInitTests.scala b/integration/feature/init/src/MillInitTests.scala index dc1738afcdd..7305917fe21 100644 --- a/integration/feature/init/src/MillInitTests.scala +++ b/integration/feature/init/src/MillInitTests.scala @@ -1,9 +1,9 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object MillInitTests extends IntegrationTestSuite { +object MillInitTests extends UtestIntegrationTestSuite { def tests: Tests = Tests { test("Mill init works") - integrationTest { tester => diff --git a/integration/feature/large-project/src/LargeProjectTests.scala b/integration/feature/large-project/src/LargeProjectTests.scala index bd808b6a4a7..ad3bba0a3e1 100644 --- a/integration/feature/large-project/src/LargeProjectTests.scala +++ b/integration/feature/large-project/src/LargeProjectTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object LargeProjectTests extends IntegrationTestSuite { +object LargeProjectTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("test") - integrationTest { tester => import tester._ diff --git a/integration/feature/mill-jvm-opts/src/MillJvmOptsTests.scala b/integration/feature/mill-jvm-opts/src/MillJvmOptsTests.scala index cbcd7ea48fd..4391a7d1322 100644 --- a/integration/feature/mill-jvm-opts/src/MillJvmOptsTests.scala +++ b/integration/feature/mill-jvm-opts/src/MillJvmOptsTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object MillJvmOptsTests extends IntegrationTestSuite { +object MillJvmOptsTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("JVM options from file .mill-jvm-opts are properly read") - integrationTest { tester => import tester._ diff --git a/integration/feature/non-identifier-import/src/NonIdentifierImport.scala b/integration/feature/non-identifier-import/src/NonIdentifierImport.scala index 8a1cf72fa30..daec95905ab 100644 --- a/integration/feature/non-identifier-import/src/NonIdentifierImport.scala +++ b/integration/feature/non-identifier-import/src/NonIdentifierImport.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object NonIdentifierImport extends IntegrationTestSuite { +object NonIdentifierImport extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("test") - integrationTest { tester => import tester._ diff --git a/integration/feature/plugin-classpath/src/MillPluginClasspathTest.scala b/integration/feature/plugin-classpath/src/MillPluginClasspathTest.scala index 65f0ca2fb2d..e6589c451a3 100644 --- a/integration/feature/plugin-classpath/src/MillPluginClasspathTest.scala +++ b/integration/feature/plugin-classpath/src/MillPluginClasspathTest.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object MillPluginClasspathTest extends IntegrationTestSuite { +object MillPluginClasspathTest extends UtestIntegrationTestSuite { val embeddedModules: Seq[(String, String)] = Seq( ("com.lihaoyi", "mill-main-client"), diff --git a/integration/feature/private-methods/src/PrivateMethodsTests.scala b/integration/feature/private-methods/src/PrivateMethodsTests.scala index 458866a09e5..51e1ff35374 100644 --- a/integration/feature/private-methods/src/PrivateMethodsTests.scala +++ b/integration/feature/private-methods/src/PrivateMethodsTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object PrivateMethodsTests extends IntegrationTestSuite { +object PrivateMethodsTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("simple") - integrationTest { tester => import tester._ diff --git a/integration/feature/repo-config-via-import/src/ImportRepoTests.scala b/integration/feature/repo-config-via-import/src/ImportRepoTests.scala index 103ef1ba791..99b89760b29 100644 --- a/integration/feature/repo-config-via-import/src/ImportRepoTests.scala +++ b/integration/feature/repo-config-via-import/src/ImportRepoTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object ImportRepoTests extends IntegrationTestSuite { +object ImportRepoTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("test") - integrationTest { tester => import tester._ diff --git a/integration/feature/scoverage/src/ScoverageTests.scala b/integration/feature/scoverage/src/ScoverageTests.scala index 9f4a50ec5ae..75c78521f9c 100644 --- a/integration/feature/scoverage/src/ScoverageTests.scala +++ b/integration/feature/scoverage/src/ScoverageTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object ScoverageTests extends IntegrationTestSuite { +object ScoverageTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("test") - integrationTest { tester => import tester._ diff --git a/integration/feature/subprocess-stdout/src/SubprocessStdoutTests.scala b/integration/feature/subprocess-stdout/src/SubprocessStdoutTests.scala index 1afd096811f..bfdb7219ef4 100644 --- a/integration/feature/subprocess-stdout/src/SubprocessStdoutTests.scala +++ b/integration/feature/subprocess-stdout/src/SubprocessStdoutTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object SubprocessStdoutTests extends IntegrationTestSuite { +object SubprocessStdoutTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test - integrationTest { tester => import tester._ diff --git a/integration/ide/bloop/src/BloopTests.scala b/integration/ide/bloop/src/BloopTests.scala index 08ae4814932..710b5a5c9cd 100644 --- a/integration/ide/bloop/src/BloopTests.scala +++ b/integration/ide/bloop/src/BloopTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object BloopTests extends IntegrationTestSuite { +object BloopTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("test") - { diff --git a/integration/ide/bsp-install/src/BspInstallDebugTests.scala b/integration/ide/bsp-install/src/BspInstallDebugTests.scala index cf831fabfb3..2294dab3571 100644 --- a/integration/ide/bsp-install/src/BspInstallDebugTests.scala +++ b/integration/ide/bsp-install/src/BspInstallDebugTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import mill.bsp.Constants import utest._ -object BspInstallDebugTests extends IntegrationTestSuite { +object BspInstallDebugTests extends UtestIntegrationTestSuite { val bsp4jVersion: String = sys.props.getOrElse("BSP4J_VERSION", ???) // we purposely enable debugging in this simulated test env diff --git a/integration/ide/bsp-install/src/BspInstallTests.scala b/integration/ide/bsp-install/src/BspInstallTests.scala index cc0206789c9..40f9547da61 100644 --- a/integration/ide/bsp-install/src/BspInstallTests.scala +++ b/integration/ide/bsp-install/src/BspInstallTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import mill.bsp.Constants import utest._ -object BspInstallTests extends IntegrationTestSuite { +object BspInstallTests extends UtestIntegrationTestSuite { val bsp4jVersion: String = sys.props.getOrElse("BSP4J_VERSION", ???) def tests: Tests = Tests { diff --git a/integration/ide/bsp-modules/src/BspModulesTests.scala b/integration/ide/bsp-modules/src/BspModulesTests.scala index 02ca46dda99..cadc7e31e98 100644 --- a/integration/ide/bsp-modules/src/BspModulesTests.scala +++ b/integration/ide/bsp-modules/src/BspModulesTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import mill.bsp.Constants import utest._ -object BspModulesTests extends IntegrationTestSuite { +object BspModulesTests extends UtestIntegrationTestSuite { val bsp4jVersion: String = sys.props.getOrElse("BSP4J_VERSION", ???) def tests: Tests = Tests { diff --git a/integration/ide/gen-idea/src/GenIdeaExtendedTests.scala b/integration/ide/gen-idea/src/GenIdeaExtendedTests.scala index 8a78aef6f16..ec4d78de0b3 100644 --- a/integration/ide/gen-idea/src/GenIdeaExtendedTests.scala +++ b/integration/ide/gen-idea/src/GenIdeaExtendedTests.scala @@ -1,12 +1,12 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ import scala.util.Try import os.Path -object GenIdeaExtendedTests extends IntegrationTestSuite { +object GenIdeaExtendedTests extends UtestIntegrationTestSuite { override def workspaceSourcePath: Path = super.workspaceSourcePath / "extended" diff --git a/integration/ide/gen-idea/src/GenIdeaTests.scala b/integration/ide/gen-idea/src/GenIdeaTests.scala index 209f5dcdbc5..3bf9985d149 100644 --- a/integration/ide/gen-idea/src/GenIdeaTests.scala +++ b/integration/ide/gen-idea/src/GenIdeaTests.scala @@ -3,11 +3,11 @@ package mill.integration import utest.{Tests, assert, _} import scala.util.Try -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import GenIdeaUtils._ import os.Path -object GenIdeaTests extends IntegrationTestSuite { +object GenIdeaTests extends UtestIntegrationTestSuite { override def workspaceSourcePath: Path = super.workspaceSourcePath / "hello-idea" diff --git a/integration/invalidation/codesig-hello/src/CodeSigHelloTests.scala b/integration/invalidation/codesig-hello/src/CodeSigHelloTests.scala index 592c88a00b4..38ff50c4a79 100644 --- a/integration/invalidation/codesig-hello/src/CodeSigHelloTests.scala +++ b/integration/invalidation/codesig-hello/src/CodeSigHelloTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object CodeSigHelloTests extends IntegrationTestSuite { +object CodeSigHelloTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("simple") - integrationTest { tester => import tester._ diff --git a/integration/invalidation/codesig-nested/src/CodeSigNestedTests.scala b/integration/invalidation/codesig-nested/src/CodeSigNestedTests.scala index 7f478c0101e..3e973af3cb8 100644 --- a/integration/invalidation/codesig-nested/src/CodeSigNestedTests.scala +++ b/integration/invalidation/codesig-nested/src/CodeSigNestedTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object CodeSigNestedTests extends IntegrationTestSuite { +object CodeSigNestedTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("nested") - integrationTest { tester => import tester._ diff --git a/integration/invalidation/codesig-scalamodule/src/CodeSigScalaModuleTests.scala b/integration/invalidation/codesig-scalamodule/src/CodeSigScalaModuleTests.scala index 99b6e2081a4..05e8c68a3dd 100644 --- a/integration/invalidation/codesig-scalamodule/src/CodeSigScalaModuleTests.scala +++ b/integration/invalidation/codesig-scalamodule/src/CodeSigScalaModuleTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ -object CodeSigScalaModuleTests extends IntegrationTestSuite { +object CodeSigScalaModuleTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { def filterLines(out: String) = { out.linesIterator.filter(!_.contains("[info]")).toSet diff --git a/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala b/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala index 8e669c02435..37bc34523cf 100644 --- a/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala +++ b/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala @@ -1,10 +1,10 @@ package mill.integration -import mill.testkit.{IntegrationTestSuite, IntegrationTester} +import mill.testkit.{UtestIntegrationTestSuite, IntegrationTester} import utest._ -object ScriptsInvalidationTests extends IntegrationTestSuite { +object ScriptsInvalidationTests extends UtestIntegrationTestSuite { def runTask(tester: IntegrationTester, task: String): Set[String] = { val res = tester.eval(task) diff --git a/integration/invalidation/multi-level-editing/src/MultiLevelBuildTests.scala b/integration/invalidation/multi-level-editing/src/MultiLevelBuildTests.scala index 8a0741bee8b..954223c7068 100644 --- a/integration/invalidation/multi-level-editing/src/MultiLevelBuildTests.scala +++ b/integration/invalidation/multi-level-editing/src/MultiLevelBuildTests.scala @@ -1,6 +1,6 @@ package mill.integration -import mill.testkit.{IntegrationTestSuite, IntegrationTester} +import mill.testkit.{UtestIntegrationTestSuite, IntegrationTester} import mill.main.client.OutFiles._ import mill.runner.RunnerState @@ -13,7 +13,7 @@ import scala.util.matching.Regex // that the proper messages are reported, proper build classloaders are // re-used or invalidated, and the proper files end up getting watched // in all cases. -object MultiLevelBuildTests extends IntegrationTestSuite { +object MultiLevelBuildTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { def runAssertSuccess(tester: IntegrationTester, expected: String) = { diff --git a/integration/invalidation/watch-source-input/src/WatchSourceInputTests.scala b/integration/invalidation/watch-source-input/src/WatchSourceInputTests.scala index 7b41f214a1e..0b1060ccde5 100644 --- a/integration/invalidation/watch-source-input/src/WatchSourceInputTests.scala +++ b/integration/invalidation/watch-source-input/src/WatchSourceInputTests.scala @@ -1,6 +1,6 @@ package mill.integration -import mill.testkit.{IntegrationTestSuite, IntegrationTester} +import mill.testkit.{UtestIntegrationTestSuite, IntegrationTester} import mill.main.client.Util import utest._ @@ -20,7 +20,7 @@ import scala.concurrent.ExecutionContext.Implicits.global * 4. `interp.watchValue` * 5. Implicitly watched files, like `build.mill` */ -object WatchSourceInputTests extends IntegrationTestSuite { +object WatchSourceInputTests extends UtestIntegrationTestSuite { val maxDuration = 60000 val tests: Tests = Tests { diff --git a/integration/invalidation/zinc-incremental-compilation/src/ZincIncrementalCompilationTests.scala b/integration/invalidation/zinc-incremental-compilation/src/ZincIncrementalCompilationTests.scala index a8b7719d472..a0f902721e2 100644 --- a/integration/invalidation/zinc-incremental-compilation/src/ZincIncrementalCompilationTests.scala +++ b/integration/invalidation/zinc-incremental-compilation/src/ZincIncrementalCompilationTests.scala @@ -1,11 +1,11 @@ package mill.integration -import mill.testkit.IntegrationTestSuite +import mill.testkit.UtestIntegrationTestSuite import utest._ // Regress test for issue https://github.com/com-lihaoyi/mill/issues/1901 -object ZincIncrementalCompilationTests extends IntegrationTestSuite { +object ZincIncrementalCompilationTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("incremental compilation only compiles changed files") - integrationTest { tester => import tester._ diff --git a/testkit/src/mill/testkit/ExampleTestSuite.scala b/testkit/src/mill/testkit/ExampleTestSuite.scala index 7d15b65d553..8ea0234bb15 100644 --- a/testkit/src/mill/testkit/ExampleTestSuite.scala +++ b/testkit/src/mill/testkit/ExampleTestSuite.scala @@ -1,7 +1,11 @@ package mill.testkit import utest._ -object ExampleTestSuite extends IntegrationTestSuiteBase { +object ExampleTestSuite extends TestSuite { + val workspaceSourcePath: os.Path = os.Path(sys.env("MILL_TEST_RESOURCE_FOLDER")) + val clientServerMode: Boolean = sys.env("MILL_INTEGRATION_SERVER_MODE").toBoolean + + val millExecutable: os.Path = os.Path(System.getenv("MILL_INTEGRATION_LAUNCHER"), os.pwd) val tests: Tests = Tests { test("exampleTest") { diff --git a/testkit/src/mill/testkit/IntegrationTestSuite.scala b/testkit/src/mill/testkit/IntegrationTestSuite.scala index 975295127c8..ad4aa63d678 100644 --- a/testkit/src/mill/testkit/IntegrationTestSuite.scala +++ b/testkit/src/mill/testkit/IntegrationTestSuite.scala @@ -1,11 +1,9 @@ package mill.testkit -abstract class IntegrationTestSuite extends IntegrationTestSuiteBase { - def debugLog: Boolean = false - def integrationTest[T](t: IntegrationTester => T) = { - val tester = - new IntegrationTester(clientServerMode, workspaceSourcePath, millExecutable, debugLog) - try t(tester) - finally tester.close() - } +import os.Path + +abstract class UtestIntegrationTestSuite extends utest.TestSuite with IntegrationTestSuite{ + protected def workspaceSourcePath: os.Path = os.Path(sys.env("MILL_TEST_RESOURCE_FOLDER")) + protected def clientServerMode: Boolean = sys.env("MILL_INTEGRATION_SERVER_MODE").toBoolean + protected def millExecutable: os.Path = os.Path(System.getenv("MILL_INTEGRATION_LAUNCHER"), os.pwd) } diff --git a/testkit/src/mill/testkit/IntegrationTestSuiteBase.scala b/testkit/src/mill/testkit/IntegrationTestSuiteBase.scala index 95399abb9d3..3d53958e179 100644 --- a/testkit/src/mill/testkit/IntegrationTestSuiteBase.scala +++ b/testkit/src/mill/testkit/IntegrationTestSuiteBase.scala @@ -3,9 +3,17 @@ package mill.testkit import os.Path import utest._ -abstract class IntegrationTestSuiteBase extends TestSuite { - protected def workspaceSourcePath: os.Path = os.Path(sys.env("MILL_TEST_RESOURCE_FOLDER")) - protected val clientServerMode: Boolean = sys.env("MILL_INTEGRATION_SERVER_MODE").toBoolean +trait IntegrationTestSuite { + protected def workspaceSourcePath: os.Path + protected def clientServerMode: Boolean - protected def millExecutable: Path = os.Path(System.getenv("MILL_INTEGRATION_LAUNCHER"), os.pwd) + protected def millExecutable: Path + + def debugLog: Boolean = false + def integrationTest[T](t: IntegrationTester => T) = { + val tester = + new IntegrationTester(clientServerMode, workspaceSourcePath, millExecutable, debugLog) + try t(tester) + finally tester.close() + } } diff --git a/testkit/test/src/mill/testkit/IntegrationTesterTests.scala b/testkit/test/src/mill/testkit/IntegrationTesterTests.scala index 13ed31e1a3e..e254822cd66 100644 --- a/testkit/test/src/mill/testkit/IntegrationTesterTests.scala +++ b/testkit/test/src/mill/testkit/IntegrationTesterTests.scala @@ -2,28 +2,27 @@ package mill.testkit import utest._ -object IntegrationTesterTests extends TestSuite { - +object IntegrationTesterTests extends TestSuite with IntegrationTestSuite { + def clientServerMode = true + def workspaceSourcePath = + os.Path(sys.env("MILL_TEST_RESOURCE_FOLDER")) / "integration-test-example-project" + def millExecutable = os.Path(sys.env("MILL_EXECUTABLE_PATH")) def tests: Tests = Tests { test("integration") { - val tester = new IntegrationTester( - clientServerMode = true, - workspaceSourcePath = - os.Path(sys.env("MILL_TEST_RESOURCE_FOLDER")) / "integration-test-example-project", - millExecutable = os.Path(sys.env("MILL_EXECUTABLE_PATH")) - ) + integrationTest{ tester => + val res1 = tester.eval("testTask") + assert(res1.isSuccess) + assert(res1.err.contains("compiling 1 Scala source")) // compiling the `build.mill` + assert(tester.out("testTask").value[String] == "HELLO WORLD SOURCE FILE") - val res1 = tester.eval("testTask") - assert(res1.isSuccess) - assert(res1.err.contains("compiling 1 Scala source")) // compiling the `build.mill` - assert(tester.out("testTask").value[String] == "HELLO WORLD SOURCE FILE") + tester.modifyFile(tester.workspacePath / "source-file.txt", _ + "!!!") - tester.modifyFile(tester.workspacePath / "source-file.txt", _ + "!!!") + val res2 = tester.eval("testTask") + assert(!res2.err.contains("compiling 1 Scala source")) // no need to re-compile `build.mill` + assert(tester.out("testTask").value[String] == "HELLO WORLD SOURCE FILE!!!") + } - val res2 = tester.eval("testTask") - assert(!res2.err.contains("compiling 1 Scala source")) // no need to re-compile `build.mill` - assert(tester.out("testTask").value[String] == "HELLO WORLD SOURCE FILE!!!") } } } From 48ea1cfc3040c7fc4d2e971f900f0ea7cbe833ca Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 21:22:48 +0800 Subject: [PATCH 53/60] . --- testkit/src/mill/testkit/IntegrationTestSuite.scala | 5 +++-- .../{ExampleTestSuite.scala => UtestExampleTestSuite.scala} | 2 +- testkit/test/src/mill/testkit/IntegrationTesterTests.scala | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) rename testkit/src/mill/testkit/{ExampleTestSuite.scala => UtestExampleTestSuite.scala} (90%) diff --git a/testkit/src/mill/testkit/IntegrationTestSuite.scala b/testkit/src/mill/testkit/IntegrationTestSuite.scala index ad4aa63d678..967eb2d8d03 100644 --- a/testkit/src/mill/testkit/IntegrationTestSuite.scala +++ b/testkit/src/mill/testkit/IntegrationTestSuite.scala @@ -2,8 +2,9 @@ package mill.testkit import os.Path -abstract class UtestIntegrationTestSuite extends utest.TestSuite with IntegrationTestSuite{ +abstract class UtestIntegrationTestSuite extends utest.TestSuite with IntegrationTestSuite { protected def workspaceSourcePath: os.Path = os.Path(sys.env("MILL_TEST_RESOURCE_FOLDER")) protected def clientServerMode: Boolean = sys.env("MILL_INTEGRATION_SERVER_MODE").toBoolean - protected def millExecutable: os.Path = os.Path(System.getenv("MILL_INTEGRATION_LAUNCHER"), os.pwd) + protected def millExecutable: os.Path = + os.Path(System.getenv("MILL_INTEGRATION_LAUNCHER"), os.pwd) } diff --git a/testkit/src/mill/testkit/ExampleTestSuite.scala b/testkit/src/mill/testkit/UtestExampleTestSuite.scala similarity index 90% rename from testkit/src/mill/testkit/ExampleTestSuite.scala rename to testkit/src/mill/testkit/UtestExampleTestSuite.scala index 8ea0234bb15..994a4995a04 100644 --- a/testkit/src/mill/testkit/ExampleTestSuite.scala +++ b/testkit/src/mill/testkit/UtestExampleTestSuite.scala @@ -1,7 +1,7 @@ package mill.testkit import utest._ -object ExampleTestSuite extends TestSuite { +object UtestExampleTestSuite extends TestSuite { val workspaceSourcePath: os.Path = os.Path(sys.env("MILL_TEST_RESOURCE_FOLDER")) val clientServerMode: Boolean = sys.env("MILL_INTEGRATION_SERVER_MODE").toBoolean diff --git a/testkit/test/src/mill/testkit/IntegrationTesterTests.scala b/testkit/test/src/mill/testkit/IntegrationTesterTests.scala index e254822cd66..9172a036427 100644 --- a/testkit/test/src/mill/testkit/IntegrationTesterTests.scala +++ b/testkit/test/src/mill/testkit/IntegrationTesterTests.scala @@ -10,7 +10,7 @@ object IntegrationTesterTests extends TestSuite with IntegrationTestSuite { def tests: Tests = Tests { test("integration") { - integrationTest{ tester => + integrationTest { tester => val res1 = tester.eval("testTask") assert(res1.isSuccess) assert(res1.err.contains("compiling 1 Scala source")) // compiling the `build.mill` From 5c510a96cf6917eadf83068fc2940655ac223987 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 21:32:39 +0800 Subject: [PATCH 54/60] . --- .../src/BuildFileInSubfolderTests.scala | 1 - integration/failure/compile-error/src/CompileErrorTests.scala | 1 - .../failure/cross-collisions/src/CrossCollisionsTests.scala | 1 - .../invalid-meta-module/src/InvalidMetaModuleTests.scala | 1 - .../src/InvalidPackageDeclaration.scala | 1 - .../invalid-root-module/src/InvalidRootModuleTests.scala | 1 - .../src/InvalidSubfolderRootModuleTests.scala | 1 - .../misnamed-root-module/src/MisnamedRootModuleTests.scala | 1 - .../missing-build-file/src/MissingBuildFileTests.scala | 1 - .../failure/module-init-error/src/ModuleInitErrorTests.scala | 1 - integration/ide/gen-idea/src/GenIdeaTests.scala | 1 - .../invalidation/src/ScriptsInvalidationTests.scala | 2 -- .../watch-source-input/src/WatchSourceInputTests.scala | 4 ---- testkit/src/mill/testkit/IntegrationTestSuite.scala | 1 - testkit/src/mill/testkit/IntegrationTestSuiteBase.scala | 3 +-- 15 files changed, 1 insertion(+), 20 deletions(-) diff --git a/integration/failure/build-file-in-subfolder/src/BuildFileInSubfolderTests.scala b/integration/failure/build-file-in-subfolder/src/BuildFileInSubfolderTests.scala index 39f5c8725d5..ea464c3864c 100644 --- a/integration/failure/build-file-in-subfolder/src/BuildFileInSubfolderTests.scala +++ b/integration/failure/build-file-in-subfolder/src/BuildFileInSubfolderTests.scala @@ -7,7 +7,6 @@ import utest._ object BuildFileInSubfolderTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("success") - integrationTest { tester => - import tester._ val res = tester.eval(("resolve", "_")) assert(res.isSuccess == false) assert(res.err.contains("Mill build.mill files can only be in the project root")) diff --git a/integration/failure/compile-error/src/CompileErrorTests.scala b/integration/failure/compile-error/src/CompileErrorTests.scala index a55e21e3f46..999c258a9e9 100644 --- a/integration/failure/compile-error/src/CompileErrorTests.scala +++ b/integration/failure/compile-error/src/CompileErrorTests.scala @@ -7,7 +7,6 @@ import utest._ object CompileErrorTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test - integrationTest { tester => - import tester._ val res = tester.eval("foo.scalaVersion") assert(res.isSuccess == false) diff --git a/integration/failure/cross-collisions/src/CrossCollisionsTests.scala b/integration/failure/cross-collisions/src/CrossCollisionsTests.scala index 29c50592832..04805609ab5 100644 --- a/integration/failure/cross-collisions/src/CrossCollisionsTests.scala +++ b/integration/failure/cross-collisions/src/CrossCollisionsTests.scala @@ -7,7 +7,6 @@ import utest._ object CrossCollisionsTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("detect-collision") - integrationTest { tester => - import tester._ val res = tester.eval(("resolve", "foo._")) assert(!res.isSuccess) assert(res.err.contains("Cross module ")) diff --git a/integration/failure/invalid-meta-module/src/InvalidMetaModuleTests.scala b/integration/failure/invalid-meta-module/src/InvalidMetaModuleTests.scala index fc7d3705435..429d22a44c5 100644 --- a/integration/failure/invalid-meta-module/src/InvalidMetaModuleTests.scala +++ b/integration/failure/invalid-meta-module/src/InvalidMetaModuleTests.scala @@ -7,7 +7,6 @@ import utest._ object InvalidMetaModuleTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("success") - integrationTest { tester => - import tester._ val res = tester.eval(("resolve", "_")) assert(res.isSuccess == false) assert(res.err.contains("object `package` ")) diff --git a/integration/failure/invalid-package-declaration/src/InvalidPackageDeclaration.scala b/integration/failure/invalid-package-declaration/src/InvalidPackageDeclaration.scala index 91393ac7c5c..f2806779c65 100644 --- a/integration/failure/invalid-package-declaration/src/InvalidPackageDeclaration.scala +++ b/integration/failure/invalid-package-declaration/src/InvalidPackageDeclaration.scala @@ -7,7 +7,6 @@ import utest._ object InvalidPackageDeclaration extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("success") - integrationTest { tester => - import tester._ val res = tester.eval(("resolve", "_")) assert(res.isSuccess == false) assert(res.err.contains( diff --git a/integration/failure/invalid-root-module/src/InvalidRootModuleTests.scala b/integration/failure/invalid-root-module/src/InvalidRootModuleTests.scala index bf7eb81ff24..fc0831494c9 100644 --- a/integration/failure/invalid-root-module/src/InvalidRootModuleTests.scala +++ b/integration/failure/invalid-root-module/src/InvalidRootModuleTests.scala @@ -7,7 +7,6 @@ import utest._ object InvalidRootModuleTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("success") - integrationTest { tester => - import tester._ val res = tester.eval(("resolve", "_")) assert(res.isSuccess == false) assert(res.err.contains("object `package` in ")) diff --git a/integration/failure/invalid-subfolder-root-module/src/InvalidSubfolderRootModuleTests.scala b/integration/failure/invalid-subfolder-root-module/src/InvalidSubfolderRootModuleTests.scala index fc45ec4b3af..8d9c8b11ddc 100644 --- a/integration/failure/invalid-subfolder-root-module/src/InvalidSubfolderRootModuleTests.scala +++ b/integration/failure/invalid-subfolder-root-module/src/InvalidSubfolderRootModuleTests.scala @@ -7,7 +7,6 @@ import utest._ object InvalidSubfolderRootModuleTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("success") - integrationTest { tester => - import tester._ val res = tester.eval(("resolve", "_")) assert(res.isSuccess == false) assert(res.err.contains("object `package` ")) diff --git a/integration/failure/misnamed-root-module/src/MisnamedRootModuleTests.scala b/integration/failure/misnamed-root-module/src/MisnamedRootModuleTests.scala index 62dfb7169d5..c21e8da6a32 100644 --- a/integration/failure/misnamed-root-module/src/MisnamedRootModuleTests.scala +++ b/integration/failure/misnamed-root-module/src/MisnamedRootModuleTests.scala @@ -7,7 +7,6 @@ import utest._ object MisnamedRootModuleTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test("success") - integrationTest { tester => - import tester._ val res = tester.eval(("resolve", "_")) assert(!res.isSuccess) assert(res.err.contains( diff --git a/integration/failure/missing-build-file/src/MissingBuildFileTests.scala b/integration/failure/missing-build-file/src/MissingBuildFileTests.scala index 56356623695..2b6f625d991 100644 --- a/integration/failure/missing-build-file/src/MissingBuildFileTests.scala +++ b/integration/failure/missing-build-file/src/MissingBuildFileTests.scala @@ -7,7 +7,6 @@ import utest._ object MissingBuildFileTests extends UtestIntegrationTestSuite { val tests: Tests = Tests { test - integrationTest { tester => - import tester._ val res = tester.eval(("resolve", "_")) assert(!res.isSuccess) val s"build.mill file not found in $msg. Are you in a Mill project folder?" = res.err diff --git a/integration/failure/module-init-error/src/ModuleInitErrorTests.scala b/integration/failure/module-init-error/src/ModuleInitErrorTests.scala index 1f8ecb34d45..c06cffab877 100644 --- a/integration/failure/module-init-error/src/ModuleInitErrorTests.scala +++ b/integration/failure/module-init-error/src/ModuleInitErrorTests.scala @@ -8,7 +8,6 @@ object ModuleInitErrorTests extends UtestIntegrationTestSuite { def captureOutErr = true val tests: Tests = Tests { test("resolve") - integrationTest { tester => - import tester._ // Ensure that resolve works even of the modules containing the resolved // tasks are broken val res1 = tester.eval(("resolve", "foo.fooTarget")) diff --git a/integration/ide/gen-idea/src/GenIdeaTests.scala b/integration/ide/gen-idea/src/GenIdeaTests.scala index 3bf9985d149..fa128c045ad 100644 --- a/integration/ide/gen-idea/src/GenIdeaTests.scala +++ b/integration/ide/gen-idea/src/GenIdeaTests.scala @@ -13,7 +13,6 @@ object GenIdeaTests extends UtestIntegrationTestSuite { def tests: Tests = Tests { test("helper assertPartialContentMatches works") - integrationTest { tester => - import tester._ val testContent = s"""line 1 |line 2 diff --git a/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala b/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala index 37bc34523cf..4b53ea3d8ce 100644 --- a/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala +++ b/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala @@ -96,7 +96,6 @@ object ScriptsInvalidationTests extends UtestIntegrationTestSuite { } } test("should handle ammonite paths with symbols") - integrationTest { tester => - import tester._ val result = runTask(tester, "taskSymbols") val expected = Set("taskSymbols") @@ -104,7 +103,6 @@ object ScriptsInvalidationTests extends UtestIntegrationTestSuite { assert(result == expected) } test("should handle ammonite files with symbols") - integrationTest { tester => - import tester._ val result = runTask(tester, "taskSymbolsInFile") val expected = Set("taskSymbolsInFile") diff --git a/integration/invalidation/watch-source-input/src/WatchSourceInputTests.scala b/integration/invalidation/watch-source-input/src/WatchSourceInputTests.scala index 0b1060ccde5..7631b725184 100644 --- a/integration/invalidation/watch-source-input/src/WatchSourceInputTests.scala +++ b/integration/invalidation/watch-source-input/src/WatchSourceInputTests.scala @@ -134,7 +134,6 @@ object WatchSourceInputTests extends UtestIntegrationTestSuite { // Make sure we clean up the workspace between retries test("noshow") - integrationTest { tester => - import tester._ retry(3) { if (!Util.isWindows) { testWatchSource(tester, false) @@ -142,7 +141,6 @@ object WatchSourceInputTests extends UtestIntegrationTestSuite { } } test("show") - integrationTest { tester => - import tester._ retry(3) { if (!Util.isWindows) { testWatchSource(tester, true) @@ -188,7 +186,6 @@ object WatchSourceInputTests extends UtestIntegrationTestSuite { // Make sure we clean up the workspace between retries test("noshow") - integrationTest { tester => - import tester._ retry(3) { if (!Util.isWindows) { testWatchInput(tester, false) @@ -196,7 +193,6 @@ object WatchSourceInputTests extends UtestIntegrationTestSuite { } } test("show") - integrationTest { tester => - import tester._ retry(3) { if (!Util.isWindows) { testWatchInput(tester, true) diff --git a/testkit/src/mill/testkit/IntegrationTestSuite.scala b/testkit/src/mill/testkit/IntegrationTestSuite.scala index 967eb2d8d03..b9be1d664db 100644 --- a/testkit/src/mill/testkit/IntegrationTestSuite.scala +++ b/testkit/src/mill/testkit/IntegrationTestSuite.scala @@ -1,6 +1,5 @@ package mill.testkit -import os.Path abstract class UtestIntegrationTestSuite extends utest.TestSuite with IntegrationTestSuite { protected def workspaceSourcePath: os.Path = os.Path(sys.env("MILL_TEST_RESOURCE_FOLDER")) diff --git a/testkit/src/mill/testkit/IntegrationTestSuiteBase.scala b/testkit/src/mill/testkit/IntegrationTestSuiteBase.scala index 3d53958e179..24abc745b62 100644 --- a/testkit/src/mill/testkit/IntegrationTestSuiteBase.scala +++ b/testkit/src/mill/testkit/IntegrationTestSuiteBase.scala @@ -1,7 +1,6 @@ package mill.testkit import os.Path -import utest._ trait IntegrationTestSuite { protected def workspaceSourcePath: os.Path @@ -10,7 +9,7 @@ trait IntegrationTestSuite { protected def millExecutable: Path def debugLog: Boolean = false - def integrationTest[T](t: IntegrationTester => T) = { + def integrationTest[T](t: IntegrationTester => T): T = { val tester = new IntegrationTester(clientServerMode, workspaceSourcePath, millExecutable, debugLog) try t(tester) From f9c827499a222e0c8b6672dce694f2fc517b3d19 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 21:37:16 +0800 Subject: [PATCH 55/60] . --- .github/workflows/run-mill-action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index ce0b267a15c..9a913fa09ef 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -73,7 +73,7 @@ jobs: if: inputs.millargs != '' && !startsWith(inputs.os, 'windows') - name: Run Mill (on Windows) '${{ inputs.millargs }}' - run: cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -ij1 __.resolvedIvyDeps; cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -i -d -k ${{ inputs.millargs }} + run: cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -ij1 __.resolvedIvyDeps; cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -i -k ${{ inputs.millargs }} if: inputs.millargs != '' && startsWith(inputs.os, 'windows') - name: Run Mill (on Windows) Worker Cleanup From 319055d612b3a34a31a60df0b2d317a1c3dd7fb7 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 21:46:59 +0800 Subject: [PATCH 56/60] . --- .../invalidation/src/ScriptsInvalidationTests.scala | 2 -- testkit/src/mill/testkit/IntegrationTestSuite.scala | 1 - 2 files changed, 3 deletions(-) diff --git a/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala b/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala index 4b53ea3d8ce..895ec42b096 100644 --- a/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala +++ b/integration/invalidation/invalidation/src/ScriptsInvalidationTests.scala @@ -96,14 +96,12 @@ object ScriptsInvalidationTests extends UtestIntegrationTestSuite { } } test("should handle ammonite paths with symbols") - integrationTest { tester => - val result = runTask(tester, "taskSymbols") val expected = Set("taskSymbols") assert(result == expected) } test("should handle ammonite files with symbols") - integrationTest { tester => - val result = runTask(tester, "taskSymbolsInFile") val expected = Set("taskSymbolsInFile") diff --git a/testkit/src/mill/testkit/IntegrationTestSuite.scala b/testkit/src/mill/testkit/IntegrationTestSuite.scala index b9be1d664db..e488a51542f 100644 --- a/testkit/src/mill/testkit/IntegrationTestSuite.scala +++ b/testkit/src/mill/testkit/IntegrationTestSuite.scala @@ -1,6 +1,5 @@ package mill.testkit - abstract class UtestIntegrationTestSuite extends utest.TestSuite with IntegrationTestSuite { protected def workspaceSourcePath: os.Path = os.Path(sys.env("MILL_TEST_RESOURCE_FOLDER")) protected def clientServerMode: Boolean = sys.env("MILL_INTEGRATION_SERVER_MODE").toBoolean From cf33fcba285310b7540cb3a929295d95150cd0a2 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 22:08:35 +0800 Subject: [PATCH 57/60] . --- .github/workflows/run-mill-action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-mill-action.yml b/.github/workflows/run-mill-action.yml index 9a913fa09ef..6d7d9266992 100644 --- a/.github/workflows/run-mill-action.yml +++ b/.github/workflows/run-mill-action.yml @@ -73,7 +73,7 @@ jobs: if: inputs.millargs != '' && !startsWith(inputs.os, 'windows') - name: Run Mill (on Windows) '${{ inputs.millargs }}' - run: cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -ij1 __.resolvedIvyDeps; cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -i -k ${{ inputs.millargs }} + run: cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -ij1 __.resolvedIvyDeps; cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -i -j1 -k ${{ inputs.millargs }} if: inputs.millargs != '' && startsWith(inputs.os, 'windows') - name: Run Mill (on Windows) Worker Cleanup From e8642c363ee81e64f70597d3a1b42c35f6552c39 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 22:12:20 +0800 Subject: [PATCH 58/60] . --- integration/ide/bloop/src/BloopTests.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/ide/bloop/src/BloopTests.scala b/integration/ide/bloop/src/BloopTests.scala index 710b5a5c9cd..6b342f93453 100644 --- a/integration/ide/bloop/src/BloopTests.scala +++ b/integration/ide/bloop/src/BloopTests.scala @@ -26,8 +26,8 @@ object BloopTests extends UtestIntegrationTestSuite { test("mill-build config should contain build.mill source") - integrationTest { tester => import tester._ val millBuildJsonFile = workspacePath / ".bloop" / "mill-build-.json" - val config = ujson.read(os.read.stream(millBuildJsonFile)) val installResult: Boolean = eval("mill.contrib.bloop.Bloop/install").isSuccess + val config = ujson.read(os.read.stream(millBuildJsonFile)) assert(installResult) assert(config("project")("sources").arr.exists(path => os.Path(path.str).last == "build.mill" From cdc0d360ef3bfdf8376e968a59a550d80f9a9a00 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 22:42:27 +0800 Subject: [PATCH 59/60] . --- .../src/WatchSourceInputTests.scala | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/integration/invalidation/watch-source-input/src/WatchSourceInputTests.scala b/integration/invalidation/watch-source-input/src/WatchSourceInputTests.scala index 7631b725184..09a2205fb05 100644 --- a/integration/invalidation/watch-source-input/src/WatchSourceInputTests.scala +++ b/integration/invalidation/watch-source-input/src/WatchSourceInputTests.scala @@ -133,15 +133,15 @@ object WatchSourceInputTests extends UtestIntegrationTestSuite { test("sources") { // Make sure we clean up the workspace between retries - test("noshow") - integrationTest { tester => - retry(3) { + test("noshow") - retry(3) { + integrationTest { tester => if (!Util.isWindows) { testWatchSource(tester, false) } } } - test("show") - integrationTest { tester => - retry(3) { + test("show") - retry(3) { + integrationTest { tester => if (!Util.isWindows) { testWatchSource(tester, true) } @@ -185,15 +185,15 @@ object WatchSourceInputTests extends UtestIntegrationTestSuite { test("input") { // Make sure we clean up the workspace between retries - test("noshow") - integrationTest { tester => - retry(3) { + test("noshow") - retry(3) { + integrationTest { tester => if (!Util.isWindows) { testWatchInput(tester, false) } } } - test("show") - integrationTest { tester => - retry(3) { + test("show") - retry(3) { + integrationTest { tester => if (!Util.isWindows) { testWatchInput(tester, true) } From fa551c556b4b22b58fa0556f835c8e65de1d4949 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 5 Sep 2024 23:14:26 +0800 Subject: [PATCH 60/60] . --- .github/workflows/actions.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index b0d307557e7..1d05e7d3e14 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -77,7 +77,9 @@ jobs: millargs: "contrib.__.testCached" - java-version: 17 - millargs: "'example.{javalib,scalalib}.__.local.testCached'" + millargs: "'example.javalib.__.local.testCached'" + - java-version: 17 + millargs: "'example.scalalib.__.local.testCached'" - java-version: 11 millargs: "'example.thirdparty[{mockito,acyclic,commons-io}].local.testCached'" - java-version: 17 @@ -88,12 +90,14 @@ jobs: # Most of these integration tests should not depend on which mode they # are run in, so just run them in `local` - java-version: 11 - millargs: "'integration.{failure,feature,ide}[_].local.testCached'" + millargs: "'integration.{failure,feature,ide}.__.local.testCached'" # These invalidation tests need to be exercised in both execution modes # to make sure they work with and without -i/--no-server being passed - java-version: 17 - millargs: "'integration.invalidation[_].{fork,server}.testCached'" + millargs: "'integration.invalidation.__.fork.testCached'" + - java-version: 17 + millargs: "'integration.invalidation.__.server.testCached'" # Check docsite compiles - java-version: 11