Skip to content

Commit 48cbfd9

Browse files
Separate compilation enabled in the test framework for compileDir
`compileDir` ignores the `A_1.scala` `B_2.scala` syntax intended to specify the order of sources compilation when we want to compile them in several separate runs. This commit leaves the default behavior unchanged but provides for an option to explicitly specify the separate compilation mode.
1 parent baff603 commit 48cbfd9

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ class CompilationTests extends ParallelTesting {
9696
"tests/neg-custom-args/fatal-warnings/xfatalWarnings.scala",
9797
defaultOptions.and("-nowarn", "-Xfatal-warnings")
9898
) +
99-
compileFile("tests/pos-special/typeclass-scaling.scala", defaultOptions.and("-Xmax-inlines", "40"))
99+
compileFile("tests/pos-special/typeclass-scaling.scala", defaultOptions.and("-Xmax-inlines", "40")) +
100+
compileDir("tests/pos-special/i6152", defaultOptions, separateCompilation = true)
100101
}.checkCompile()
101102

102103
@Test def posTwice: Unit = {

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

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,30 +1257,34 @@ trait ParallelTesting extends RunnerOrchestration { self =>
12571257
* By default, files are compiled in alphabetical order. An optional seed
12581258
* can be used for randomization.
12591259
*/
1260-
def compileDir(f: String, flags: TestFlags, randomOrder: Option[Int] = None, recursive: Boolean = true)(implicit testGroup: TestGroup): CompilationTest = {
1260+
def compileDir(f: String, flags: TestFlags, randomOrder: Option[Int] = None, recursive: Boolean = true, separateCompilation: Boolean = false)(implicit testGroup: TestGroup): CompilationTest = {
12611261
val outDir = defaultOutputDir + testGroup + JFile.separator
12621262
val sourceDir = new JFile(f)
1263+
val name = s"compiling '$f' in test '$testGroup'"
12631264
checkRequirements(f, sourceDir, outDir)
12641265

1265-
def flatten(f: JFile): Array[JFile] =
1266-
if (f.isDirectory) {
1267-
val files = f.listFiles
1268-
if (recursive) files.flatMap(flatten) else files
1269-
}
1270-
else Array(f)
1271-
1272-
// Sort files either alphabetically or randomly using the provided seed:
1273-
val sortedFiles = flatten(sourceDir).sorted
1274-
val randomized = randomOrder match {
1275-
case None => sortedFiles
1276-
case Some(seed) => new Random(seed).shuffle(sortedFiles.toList).toArray
1277-
}
1278-
12791266
// Directories in which to compile all containing files with `flags`:
12801267
val targetDir = new JFile(outDir + JFile.separator + sourceDir.getName + JFile.separator)
12811268
targetDir.mkdirs()
12821269

1283-
val target = JointCompilationSource(s"compiling '$f' in test '$testGroup'", randomized, flags, targetDir)
1270+
val target =
1271+
if (separateCompilation) SeparateCompilationSource(name, sourceDir, flags, targetDir) else {
1272+
def flatten(f: JFile): Array[JFile] =
1273+
if (f.isDirectory) {
1274+
val files = f.listFiles
1275+
if (recursive) files.flatMap(flatten) else files
1276+
}
1277+
else Array(f)
1278+
1279+
// Sort files either alphabetically or randomly using the provided seed:
1280+
val sortedFiles = flatten(sourceDir).sorted
1281+
val randomized = randomOrder match {
1282+
case None => sortedFiles
1283+
case Some(seed) => new Random(seed).shuffle(sortedFiles.toList).toArray
1284+
}
1285+
1286+
JointCompilationSource(name, randomized, flags, targetDir)
1287+
}
12841288
new CompilationTest(target)
12851289
}
12861290

0 commit comments

Comments
 (0)