Skip to content

Commit bf6f33f

Browse files
Use alphabetic sort by default
1 parent f693ba7 commit bf6f33f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,8 +1011,11 @@ trait ParallelTesting { self =>
10111011
/** Compiles a directory `f` using the supplied `flags`. This method does
10121012
* deep compilation, that is - it compiles all files and subdirectories
10131013
* contained within the directory `f`.
1014+
*
1015+
* By default, files are compiled in alphabetical order. An optional seed
1016+
* can be used for randomization.
10141017
*/
1015-
def compileDir(f: String, flags: Array[String], seed: Int = 42)(implicit outDirectory: String): CompilationTest = {
1018+
def compileDir(f: String, flags: Array[String], randomOrder: Option[Int] = None)(implicit outDirectory: String): CompilationTest = {
10161019
val callingMethod = getCallingMethod
10171020
val outDir = outDirectory + callingMethod + "/"
10181021
val sourceDir = new JFile(f)
@@ -1022,14 +1025,18 @@ trait ParallelTesting { self =>
10221025
if (f.isDirectory) f.listFiles.flatMap(flatten)
10231026
else Array(f)
10241027

1025-
// Deterministically randomises compilation order
1026-
val files = new Random(seed).shuffle(flatten(sourceDir).toList).toArray
1028+
// Sort files either alphabetically or randomly using the provided seed:
1029+
val sortedFiles = flatten(sourceDir).sorted
1030+
val randomised = randomOrder match {
1031+
case None => sortedFiles
1032+
case Some(seed) => new Random(seed).shuffle(sortedFiles.toList).toArray
1033+
}
10271034

10281035
// Directories in which to compile all containing files with `flags`:
10291036
val targetDir = new JFile(outDir + "/" + sourceDir.getName + "/")
10301037
targetDir.mkdirs()
10311038

1032-
val target = JointCompilationSource(callingMethod, files, flags, targetDir)
1039+
val target = JointCompilationSource(callingMethod, randomised, flags, targetDir)
10331040
new CompilationTest(target)
10341041
}
10351042

0 commit comments

Comments
 (0)