@@ -848,6 +848,10 @@ trait Cli extends SbtModule with ProtoBuildModule with CliLaunchers
848
848
super .runClasspath() ++ Seq (localRepoJar())
849
849
}
850
850
851
+ def compileIvyDeps = super .ivyDeps() ++ Agg (
852
+ Deps .jsoniterMacros
853
+ )
854
+
851
855
// Required by the reflection usage in modules/cli/src/test/scala/cli/tests/SetupScalaCLITests.scala
852
856
override def forkArgs : T [Seq [String ]] = T {
853
857
super .forkArgs() ++ Seq (" --add-opens=java.base/java.util=ALL-UNNAMED" )
@@ -949,46 +953,32 @@ trait CliIntegration extends SbtModule with ScalaCliPublishModule with HasTests
949
953
}
950
954
def generatedSources = super .generatedSources() ++ Seq (constantsFile())
951
955
952
- private final class TestHelper (
953
- launcherTask : T [PathRef ],
954
- cliKind : String
955
- ) {
956
- def test (args : String * ) = {
957
- val argsTask = T .task {
958
- val launcher = launcherTask().path
959
- val debugReg = " ^--debug$|^--debug:([0-9]+)$" .r
960
- val debugPortOpt = args.find(debugReg.matches).flatMap {
961
- case debugReg(port) => Option (port).orElse(Some (" 5005" ))
962
- case _ => None
963
- }
964
- val debugArgs = debugPortOpt match {
965
- case Some (port) =>
966
- System .err.println(
967
- s " --debug option has been passed. Listening for transport dt_socket at address: $port"
968
- )
969
- Seq (s " -Dtest.scala-cli.debug.port= $port" )
970
- case _ => Seq .empty
971
- }
972
- val extraArgs = Seq (
973
- s " -Dtest.scala-cli.path= $launcher" ,
974
- s " -Dtest.scala-cli.kind= $cliKind"
975
- )
976
- args ++ extraArgs ++ debugArgs
956
+ def runTests (launcherTask : T [PathRef ], cliKind : String , args : String * ) = {
957
+ val argsTask = T .task {
958
+ val launcher = launcherTask().path
959
+ val debugReg = " ^--debug$|^--debug:([0-9]+)$" .r
960
+ val debugPortOpt = args.find(debugReg.matches).flatMap {
961
+ case debugReg(port) => Option (port).orElse(Some (" 5005" ))
962
+ case _ => None
977
963
}
978
- T .command {
979
- val res = testTask(argsTask, T .task(Seq .empty[String ]))()
980
- val dotScalaInRoot = os.pwd / workspaceDirName
981
- assert(
982
- ! os.isDir(dotScalaInRoot),
983
- s " Expected $workspaceDirName ( $dotScalaInRoot) not to have been created "
984
- )
985
- res
964
+ val debugArgs = debugPortOpt match {
965
+ case Some (port) =>
966
+ System .err.println(
967
+ s " --debug option has been passed. Listening for transport dt_socket at address: $port"
968
+ )
969
+ Seq (s " -Dtest.scala-cli.debug.port= $port" )
970
+ case _ => Seq .empty
986
971
}
972
+ val extraArgs = Seq (
973
+ s " -Dtest.scala-cli.path= $launcher" ,
974
+ s " -Dtest.scala-cli.kind= $cliKind"
975
+ )
976
+ args ++ extraArgs ++ debugArgs
987
977
}
978
+ testTask(argsTask, T .task(Seq .empty[String ]))
988
979
}
989
980
990
- def test (args : String * ) =
991
- jvm(args : _* )
981
+ override def test (args : String * ) = jvm(args : _* )
992
982
993
983
def forcedLauncher = T .persistent {
994
984
val ext = if (Properties .isWin) " .exe" else " "
@@ -1033,36 +1023,38 @@ trait CliIntegration extends SbtModule with ScalaCliPublishModule with HasTests
1033
1023
PathRef (launcher)
1034
1024
}
1035
1025
1036
- def jvm (args : String * ) =
1037
- new TestHelper (
1038
- cli.standaloneLauncher,
1039
- " jvm"
1040
- ).test(args : _* )
1026
+ private object Launchers {
1027
+ def jvm = cli.standaloneLauncher
1028
+
1029
+ def jvmBootstrapped = cliBootstrapped.jar
1030
+
1031
+ def native =
1032
+ Option (System .getenv(" SCALA_CLI_IT_FORCED_LAUNCHER_DIRECTORY" )) match {
1033
+ case Some (_) => forcedLauncher
1034
+ case None => cli.nativeImage
1035
+ }
1036
+
1037
+ def nativeStatic =
1038
+ Option (System .getenv(" SCALA_CLI_IT_FORCED_STATIC_LAUNCHER_DIRECTORY" )) match {
1039
+ case Some (_) => forcedStaticLauncher
1040
+ case None => cli.nativeImageStatic
1041
+ }
1042
+
1043
+ def nativeMostlyStatic =
1044
+ Option (System .getenv(" SCALA_CLI_IT_FORCED_MOSTLY_STATIC_LAUNCHER_DIRECTORY" )) match {
1045
+ case Some (_) => forcedMostlyStaticLauncher
1046
+ case None => cli.nativeImageMostlyStatic
1047
+ }
1048
+ }
1049
+
1050
+ def jvm (args : String * ) = T .command(runTests(Launchers .jvm, " jvm" , args : _* ))
1041
1051
def jvmBootstrapped (args : String * ) =
1042
- new TestHelper (
1043
- cliBootstrapped.jar,
1044
- " jvmBootstrapped"
1045
- ).test(args : _* )
1046
- def native (args : String * ) =
1047
- new TestHelper (
1048
- if (System .getenv(" SCALA_CLI_IT_FORCED_LAUNCHER_DIRECTORY" ) == null ) cli.nativeImage
1049
- else forcedLauncher,
1050
- " native"
1051
- ).test(args : _* )
1052
+ T .command(runTests(Launchers .jvmBootstrapped, " jvmBootstrapped" , args : _* ))
1053
+ def native (args : String * ) = T .command(runTests(Launchers .native, " native" , args : _* ))
1052
1054
def nativeStatic (args : String * ) =
1053
- new TestHelper (
1054
- if (System .getenv(" SCALA_CLI_IT_FORCED_STATIC_LAUNCHER_DIRECTORY" ) == null )
1055
- cli.nativeImageStatic
1056
- else forcedStaticLauncher,
1057
- " native-static"
1058
- ).test(args : _* )
1055
+ T .command(runTests(Launchers .nativeStatic, " native-static" , args : _* ))
1059
1056
def nativeMostlyStatic (args : String * ) =
1060
- new TestHelper (
1061
- if (System .getenv(" SCALA_CLI_IT_FORCED_MOSTLY_STATIC_LAUNCHER_DIRECTORY" ) == null )
1062
- cli.nativeImageMostlyStatic
1063
- else forcedMostlyStaticLauncher,
1064
- " native-mostly-static"
1065
- ).test(args : _* )
1057
+ T .command(runTests(Launchers .nativeMostlyStatic, " native-mostly-static" , args : _* ))
1066
1058
}
1067
1059
}
1068
1060
0 commit comments