@@ -545,25 +545,36 @@ trait ParallelTesting extends RunnerOrchestration { self =>
545545 diagnostics.reverse
546546
547547 protected def compileWithOtherCompiler (compiler : String , files : Array [JFile ], flags : TestFlags , targetDir : JFile ): TestReporter =
548- val compilerDir = getCompiler(compiler).toString
548+ def artifactClasspath (organizationName : String , moduleName : String ) =
549+ import coursier ._
550+ val dep = Dependency (
551+ Module (
552+ Organization (organizationName),
553+ ModuleName (moduleName),
554+ attributes = Map .empty
555+ ),
556+ version = compiler
557+ )
558+ Fetch ()
559+ .addDependencies(dep)
560+ .run()
561+ .mkString(JFile .pathSeparator)
549562
550- def substituteClasspath (old : String ): String =
551- old.split(JFile .pathSeparator).map { o =>
552- if JFile (o) == JFile (Properties .dottyLibrary) then s " $compilerDir/lib/scala3-library_3- $compiler.jar "
553- else o
554- }.mkString(JFile .pathSeparator)
563+ val stdlibClasspath = artifactClasspath(" org.scala-lang" , " scala3-library_3" )
564+ val scalacClasspath = artifactClasspath(" org.scala-lang" , " scala3-compiler_3" )
555565
556566 val pageWidth = TestConfiguration .pageWidth - 20
557- val flags1 = flags.copy(defaultClassPath = substituteClasspath(flags.defaultClassPath) )
567+ val flags1 = flags.copy(defaultClassPath = stdlibClasspath )
558568 .withClasspath(targetDir.getPath)
559569 .and(" -d" , targetDir.getPath)
560570 .and(" -pagewidth" , pageWidth.toString)
561571
562- val reporter = TestReporter .reporter(realStdout, logLevel =
563- if (suppressErrors || suppressAllOutput) ERROR + 1 else ERROR )
564-
565- val command = Array (compilerDir + " /bin/scalac" ) ++ flags1.all ++ files.map(_.getPath)
572+ val scalacCommand = Array (" java" , " -cp" , scalacClasspath, " dotty.tools.dotc.Main" )
573+ val command = scalacCommand ++ flags1.all ++ files.map(_.getAbsolutePath)
566574 val process = Runtime .getRuntime.exec(command)
575+
576+ val reporter = TestReporter .reporter(realStdout, logLevel =
577+ if (suppressErrors || suppressAllOutput) ERROR + 1 else ERROR )
567578 val errorsText = Source .fromInputStream(process.getErrorStream).mkString
568579 if process.waitFor() != 0 then
569580 val diagnostics = parseErrors(errorsText, compiler, pageWidth)
@@ -1445,22 +1456,4 @@ object ParallelTesting {
14451456 def isTastyFile (f : JFile ): Boolean =
14461457 f.getName.endsWith(" .tasty" )
14471458
1448- def getCompiler (version : String ): JFile =
1449- val dir = cache.resolve(s " scala3- ${version}" ).toFile
1450- synchronized {
1451- if dir.exists then
1452- dir
1453- else
1454- import scala .sys .process ._
1455- val archivePath = cache.resolve(s " scala3- $version.tar.gz " )
1456- val compilerDownloadUrl = s " https://github.com/lampepfl/dotty/releases/download/ $version/scala3- $version.tar.gz "
1457- (URL (compilerDownloadUrl) #>> archivePath.toFile #&& s " tar -xf $archivePath -C $cache" ).!!
1458- archivePath.toFile.delete()
1459- dir
1460- }
1461-
1462- private lazy val cache =
1463- val dir = Properties .testCache.resolve(" compilers" )
1464- dir.toFile.mkdirs()
1465- dir
14661459}
0 commit comments