Skip to content

Commit d9c84b9

Browse files
committed
Allow cross compilation tests with Scala 2 compiler
1 parent fdf8de3 commit d9c84b9

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

compiler/test/dotty/tools/vulpix/ParallelTesting.scala

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -610,17 +610,38 @@ trait ParallelTesting extends RunnerOrchestration { self =>
610610
.run()
611611
.mkString(JFile.pathSeparator)
612612

613-
val stdlibClasspath = artifactClasspath("org.scala-lang", "scala3-library_3")
614-
val scalacClasspath = artifactClasspath("org.scala-lang", "scala3-compiler_3")
615-
616613
val pageWidth = TestConfiguration.pageWidth - 20
617-
val flags1 = flags.copy(defaultClassPath = stdlibClasspath)
618-
.withClasspath(targetDir.getPath)
619-
.and("-d", targetDir.getPath)
620-
.and("-pagewidth", pageWidth.toString)
621614

622-
val scalacCommand = Array("java", "-cp", scalacClasspath, "dotty.tools.dotc.Main")
623-
val command = scalacCommand ++ flags1.all ++ files.map(_.getAbsolutePath)
615+
val fileArgs = files.map(_.getAbsolutePath)
616+
617+
def scala2Command(): Array[String] = {
618+
assert(!flags.options.contains("-scalajs"),
619+
"Compilation tests with Scala.js on Scala 2 are not supported.\nThis test can be blacklisted in compiler/test/dotc/*-scala-js.blacklist")
620+
val stdlibClasspath = artifactClasspath("org.scala-lang", "scala-library")
621+
val scalacClasspath = artifactClasspath("org.scala-lang", "scala-compiler")
622+
val flagsArgs = flags
623+
.copy(options = Array.empty, defaultClassPath = stdlibClasspath)
624+
.withClasspath(targetDir.getPath)
625+
.and("-d", targetDir.getPath)
626+
.all
627+
val scalacCommand = Array("java", "-cp", scalacClasspath, "scala.tools.nsc.Main")
628+
scalacCommand ++ flagsArgs ++ fileArgs
629+
}
630+
631+
def scala3Command(): Array[String] = {
632+
val stdlibClasspath = artifactClasspath("org.scala-lang", "scala3-library_3")
633+
val scalacClasspath = artifactClasspath("org.scala-lang", "scala3-compiler_3")
634+
val flagsArgs = flags
635+
.copy(defaultClassPath = stdlibClasspath)
636+
.withClasspath(targetDir.getPath)
637+
.and("-d", targetDir.getPath)
638+
.and("-pagewidth", pageWidth.toString)
639+
.all
640+
val scalacCommand = Array("java", "-cp", scalacClasspath, "dotty.tools.dotc.Main")
641+
scalacCommand ++ flagsArgs ++ fileArgs
642+
}
643+
644+
val command = if compiler.startsWith("2") then scala2Command() else scala3Command()
624645
val process = Runtime.getRuntime.exec(command)
625646

626647
val reporter = mkReporter

0 commit comments

Comments
 (0)