@@ -17,7 +17,8 @@ import mill.api.Logger
1717
1818import java .util .concurrent .ConcurrentHashMap
1919import mill .api .BuildCtx
20- import mill .javalib .testrunner .{GetTestTasksMain , TestArgs , TestResult , TestRunnerUtils }
20+ import mill .javalib .api .internal .ZincGetTestTasks
21+ import mill .javalib .testrunner .{TestArgs , TestResult , TestRunnerUtils }
2122import os .Path
2223
2324import scala .annotation .unused
@@ -46,7 +47,8 @@ final class TestModuleUtil(
4647 javaHome : Option [os.Path ],
4748 testParallelism : Boolean ,
4849 testLogLevel : TestReporter .LogLevel ,
49- propagateEnv : Boolean = true
50+ propagateEnv : Boolean = true ,
51+ jvmWorker : mill.javalib.api.JvmWorkerApi
5052)(using ctx : mill.api.TaskCtx ) {
5153
5254 private val (jvmArgs, props) = TestModuleUtil .loadArgsAndProps(useArgsFile, forkArgs)
@@ -78,32 +80,16 @@ final class TestModuleUtil(
7880 // test group requires spawning a JVM which can take 1+ seconds to realize there are no
7981 // tests to run and shut down
8082
81- val discoveredTests = if (javaHome.isDefined) {
82- Jvm .callProcess(
83- mainClass = " mill.javalib.testrunner.GetTestTasksMain" ,
84- classPath = scalalibClasspath.map(_.path).toVector,
85- mainArgs =
86- (runClasspath ++ testrunnerEntrypointClasspath).flatMap(p =>
87- Seq (" --runCp" , p.path.toString)
88- ) ++
89- testClasspath.flatMap(p => Seq (" --testCp" , p.path.toString)) ++
90- Seq (" --framework" , testFramework) ++
91- selectors.flatMap(s => Seq (" --selectors" , s)) ++
92- args.flatMap(s => Seq (" --args" , s)),
93- javaHome = javaHome,
94- stdin = os.Inherit ,
95- stdout = os.Pipe ,
96- cwd = Task .dest
97- ).out.lines().toSet
98- } else {
99- GetTestTasksMain .main0(
83+ val discoveredTests = jvmWorker.getTestTasks(
84+ ZincGetTestTasks (
10085 (runClasspath ++ testrunnerEntrypointClasspath).map(_.path),
10186 testClasspath.map(_.path),
10287 testFramework,
10388 selectors,
10489 args
105- ).toSet
106- }
90+ ),
91+ javaHome
92+ ).toSet
10793
10894 filteredClassLists0.map(_.filter(discoveredTests)).filter(_.nonEmpty)
10995 }
0 commit comments