@@ -520,30 +520,50 @@ trait ParallelTesting extends RunnerOrchestration { self =>
520
520
}
521
521
522
522
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)
524
537
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" )
530
540
531
- val flags1 = flags.copy(defaultClassPath = substituteClasspath(flags.defaultClassPath) )
541
+ val flags1 = flags.copy(defaultClassPath = stdlibClasspath )
532
542
.withClasspath(targetDir.getPath)
533
543
.and(" -d" , targetDir.getPath)
534
544
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
+
535
549
val dummyStream = new PrintStream (new ByteArrayOutputStream ())
536
550
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)
540
551
val errorsText = Source .fromInputStream(process.getErrorStream).mkString
541
552
if process.waitFor() != 0 then
542
553
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()
547
567
548
568
reporter
549
569
@@ -1418,22 +1438,4 @@ object ParallelTesting {
1418
1438
def isTastyFile (f : JFile ): Boolean =
1419
1439
f.getName.endsWith(" .tasty" )
1420
1440
1421
- def getCompiler (version : String ): JFile =
1422
- val dir = cache.resolve(s " scala3- ${version}" ).toFile
1423
- synchronized {
1424
- if dir.exists then
1425
- dir
1426
- else
1427
- import scala .sys .process ._
1428
- val archivePath = cache.resolve(s " scala3- $version.tar.gz " )
1429
- val compilerDownloadUrl = s " https://github.com/lampepfl/dotty/releases/download/ $version/scala3- $version.tar.gz "
1430
- (URL (compilerDownloadUrl) #>> archivePath.toFile #&& s " tar -xf $archivePath -C $cache" ).!!
1431
- archivePath.toFile.delete()
1432
- dir
1433
- }
1434
-
1435
- private lazy val cache =
1436
- val dir = Properties .testCache.resolve(" compilers" )
1437
- dir.toFile.mkdirs()
1438
- dir
1439
1441
}
0 commit comments