@@ -520,30 +520,50 @@ trait ParallelTesting extends RunnerOrchestration { self =>
520520 }
521521
522522 protected def compileWithOtherCompiler (compiler : String , files : Array [JFile ], flags : TestFlags , targetDir : JFile ): TestReporter =
523- val compilerDir = getCompiler(compiler).toString
523+ def artifactClasspath (organizationName : String , moduleName : String ) =
524+ import coursier ._
525+ val dep = Dependency (
526+ Module (
527+ Organization (organizationName),
528+ ModuleName (moduleName),
529+ attributes = Map .empty
530+ ),
531+ version = compiler
532+ )
533+ Fetch ()
534+ .addDependencies(dep)
535+ .run()
536+ .mkString(JFile .pathSeparator)
524537
525- def substituteClasspath (old : String ): String =
526- old.split(JFile .pathSeparator).map { o =>
527- if JFile (o) == JFile (Properties .dottyLibrary) then s " $compilerDir/lib/scala3-library_3- $compiler.jar "
528- else o
529- }.mkString(JFile .pathSeparator)
538+ val stdlibClasspath = artifactClasspath(" org.scala-lang" , " scala3-library_3" )
539+ val scalacClasspath = artifactClasspath(" org.scala-lang" , " scala3-compiler_3" )
530540
531- val flags1 = flags.copy(defaultClassPath = substituteClasspath(flags.defaultClassPath) )
541+ val flags1 = flags.copy(defaultClassPath = stdlibClasspath )
532542 .withClasspath(targetDir.getPath)
533543 .and(" -d" , targetDir.getPath)
534544
545+ val scalacCommand = Array (" java" , " -cp" , scalacClasspath, " dotty.tools.dotc.Main" )
546+ val command = scalacCommand ++ flags1.all ++ files.map(_.getAbsolutePath)
547+ val process = Runtime .getRuntime.exec(command)
548+
535549 val dummyStream = new PrintStream (new ByteArrayOutputStream ())
536550 val reporter = TestReporter .reporter(dummyStream, ERROR )
537-
538- val command = Array (compilerDir + " /bin/scalac" ) ++ flags1.all ++ files.map(_.getPath)
539- val process = Runtime .getRuntime.exec(command)
540551 val errorsText = Source .fromInputStream(process.getErrorStream).mkString
541552 if process.waitFor() != 0 then
542553 val diagnostics = parseErrors(errorsText, compiler)
543- diagnostics.foreach { diag =>
544- val context = (new ContextBase ).initialCtx
545- reporter.report(diag)(using context)
546- }
554+ if diagnostics.nonEmpty then
555+ diagnostics.foreach { diag =>
556+ val context = (new ContextBase ).initialCtx
557+ reporter.report(diag)(using context)
558+ }
559+ else
560+ System .err.println(s " The attempt to compile files: ${files.mkString(" , " )} failed unexpectedly. " )
561+ System .err.println(" Invoked command:" )
562+ System .err.println(command.mkString(" " ))
563+ System .err.println()
564+ System .err.println(" Error log:" )
565+ System .err.println(errorsText)
566+ System .err.println()
547567
548568 reporter
549569
@@ -1419,22 +1439,4 @@ object ParallelTesting {
14191439 def isTastyFile (f : JFile ): Boolean =
14201440 f.getName.endsWith(" .tasty" )
14211441
1422- def getCompiler (version : String ): JFile =
1423- val dir = cache.resolve(s " scala3- ${version}" ).toFile
1424- synchronized {
1425- if dir.exists then
1426- dir
1427- else
1428- import scala .sys .process ._
1429- val archivePath = cache.resolve(s " scala3- $version.tar.gz " )
1430- val compilerDownloadUrl = s " https://github.com/lampepfl/dotty/releases/download/ $version/scala3- $version.tar.gz "
1431- (URL (compilerDownloadUrl) #>> archivePath.toFile #&& s " tar -xf $archivePath -C $cache" ).!!
1432- archivePath.toFile.delete()
1433- dir
1434- }
1435-
1436- private lazy val cache =
1437- val dir = Properties .testCache.resolve(" compilers" )
1438- dir.toFile.mkdirs()
1439- dir
14401442}
0 commit comments