Skip to content

Commit fe4eb1e

Browse files
committed
Fix tasty bootstrap
1 parent 9a4a5b6 commit fe4eb1e

File tree

3 files changed

+52
-26
lines changed

3 files changed

+52
-26
lines changed

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -197,23 +197,42 @@ class CompilationTests extends ParallelTesting {
197197
* version of Dotty
198198
*/
199199
@Test def tastyBootstrap: Unit = {
200-
def dotty1 =
201-
compileDir("../compiler/src/dotty", allowDeepSubtypes.and("-Ycheck-reentrant", "-strict"))
202-
def lib =
203-
compileDir("../library/src", defaultOptions)
204-
def dotty2 =
205-
compileDir("../compiler/src/dotty", defaultOptions.and("-priorityclasspath", defaultOutputDir))
200+
val opt = Array(
201+
"-classpath",
202+
// compile with bootstrapped library on cp:
203+
defaultOutputDir + "lib$1/src/:" +
204+
// as well as bootstrapped compiler:
205+
defaultOutputDir + "dotty1$1/dotty/:" +
206+
Jars.dottyInterfaces
207+
)
206208

207-
List(dotty1, lib, dotty2).map(_.keepOutput.pos).foreach(_.delete())
208-
}
209+
def lib =
210+
compileDir("../library/src",
211+
allowDeepSubtypes.and("-Ycheck-reentrant", "-strict", "-priorityclasspath", defaultOutputDir))
209212

210-
@Test def dotty = {
211-
def bootedLib =
212-
compileDir("../library/src", allowDeepSubtypes.and("-Ycheck-reentrant", "-strict"))
213-
def dottyDependsOnBootedLib =
214-
compileDir("../compiler/src/dotty", allowDeepSubtypes.and("-Ycheck-reentrant", "-strict"))
213+
def dotty1 =
214+
compileDir("../compiler/src/dotty", opt)
215215

216-
List(bootedLib, dottyDependsOnBootedLib).map(_.keepOutput.pos).foreach(_.delete())
216+
def dotty2 =
217+
compileShallowFilesInDir("../compiler/src/dotty", opt)
218+
219+
{
220+
lib.keepOutput :: dotty1.keepOutput :: {
221+
dotty2 +
222+
compileShallowFilesInDir("../compiler/src/dotty/tools", opt) +
223+
compileShallowFilesInDir("../compiler/src/dotty/tools/dotc", opt) +
224+
compileShallowFilesInDir("../compiler/src/dotty/tools/dotc/ast", opt) +
225+
compileShallowFilesInDir("../compiler/src/dotty/tools/dotc/config", opt) +
226+
compileShallowFilesInDir("../compiler/src/dotty/tools/dotc/parsing", opt) +
227+
compileShallowFilesInDir("../compiler/src/dotty/tools/dotc/printing", opt) +
228+
compileShallowFilesInDir("../compiler/src/dotty/tools/dotc/repl", opt) +
229+
compileShallowFilesInDir("../compiler/src/dotty/tools/dotc/reporting", opt) +
230+
compileShallowFilesInDir("../compiler/src/dotty/tools/dotc/rewrite", opt) +
231+
compileShallowFilesInDir("../compiler/src/dotty/tools/dotc/transform", opt) +
232+
compileShallowFilesInDir("../compiler/src/dotty/tools/dotc/typer", opt) +
233+
compileShallowFilesInDir("../compiler/src/dotty/tools/dotc/util", opt)
234+
} :: Nil
235+
}.map(_.pos()).foreach(_.delete())
217236
}
218237
}
219238

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

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@ trait ParallelTesting {
2424
def outDir: JFile
2525
def flags: Array[String]
2626

27-
def withFlags(newFlags: Array[String]) = self match {
28-
case self: ConcurrentCompilationTarget =>
29-
self.copy(flags = newFlags)
30-
case self: SeparateCompilationTarget =>
31-
self.copy(flags = newFlags)
32-
}
27+
def withFlags(newFlags: Array[String]) =
28+
if (!flags.containsSlice(newFlags)) self match {
29+
case self: ConcurrentCompilationTarget =>
30+
self.copy(flags = newFlags)
31+
case self: SeparateCompilationTarget =>
32+
self.copy(flags = newFlags)
33+
}
34+
else self
3335
}
36+
3437
private final case class ConcurrentCompilationTarget(
3538
files: Array[JFile],
3639
flags: Array[String],
@@ -387,8 +390,12 @@ trait ParallelTesting {
387390
}
388391

389392
def addOutDir(xs: Array[String]): Array[String] = {
390-
val (beforeCp, cp :: cpArg :: rest) = xs.toList.span(_ != "-classpath")
391-
(beforeCp ++ (cp :: (cpArg + s":${targetDir.getAbsolutePath}") :: rest)).toArray
393+
val (beforeCp, cpAndAfter) = xs.toList.span(_ != "-classpath")
394+
if (cpAndAfter.nonEmpty) {
395+
val (cp :: cpArg :: rest) = cpAndAfter
396+
(beforeCp ++ (cp :: (cpArg + s":${targetDir.getAbsolutePath}") :: rest)).toArray
397+
}
398+
else (beforeCp ++ ("-classpath" :: targetDir.getAbsolutePath :: Nil)).toArray
392399
}
393400

394401
def compileWithJavac(fs: Array[String]) = if (fs.nonEmpty) {
@@ -538,7 +545,7 @@ trait ParallelTesting {
538545
targetDir
539546
}
540547

541-
private def requirements(f: String, sourceDir: JFile, outDir: String): Unit = {
548+
private def checkRequirements(f: String, sourceDir: JFile, outDir: String): Unit = {
542549
require(sourceDir.isDirectory && sourceDir.exists, "passed non-directory to `compileFilesInDir`")
543550
require(outDir.last == '/', "please specify an `outDir` with a trailing slash")
544551
}
@@ -593,7 +600,7 @@ trait ParallelTesting {
593600
def compileDir(f: String, flags: Array[String])(implicit outDirectory: String): CompilationTest = {
594601
val outDir = outDirectory + getCallingMethod + "/"
595602
val sourceDir = new JFile(f)
596-
requirements(f, sourceDir, outDir)
603+
checkRequirements(f, sourceDir, outDir)
597604

598605
def flatten(f: JFile): Array[JFile] =
599606
if (f.isDirectory) f.listFiles.flatMap(flatten)
@@ -624,7 +631,7 @@ trait ParallelTesting {
624631
def compileFilesInDir(f: String, flags: Array[String])(implicit outDirectory: String): CompilationTest = {
625632
val outDir = outDirectory + getCallingMethod + "/"
626633
val sourceDir = new JFile(f)
627-
requirements(f, sourceDir, outDir)
634+
checkRequirements(f, sourceDir, outDir)
628635

629636
val (dirs, files) = compilationTargets(sourceDir)
630637

@@ -639,7 +646,7 @@ trait ParallelTesting {
639646
def compileShallowFilesInDir(f: String, flags: Array[String])(implicit outDirectory: String): CompilationTest = {
640647
val outDir = outDirectory + getCallingMethod + "/"
641648
val sourceDir = new JFile(f)
642-
requirements(f, sourceDir, outDir)
649+
checkRequirements(f, sourceDir, outDir)
643650

644651
val (_, files) = compilationTargets(sourceDir)
645652

out/.keep

Whitespace-only changes.

0 commit comments

Comments
 (0)