@@ -1011,8 +1011,11 @@ trait ParallelTesting { self =>
1011
1011
/** Compiles a directory `f` using the supplied `flags`. This method does
1012
1012
* deep compilation, that is - it compiles all files and subdirectories
1013
1013
* contained within the directory `f`.
1014
+ *
1015
+ * By default, files are compiled in alphabetical order. An optional seed
1016
+ * can be used for randomization.
1014
1017
*/
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 = {
1016
1019
val callingMethod = getCallingMethod
1017
1020
val outDir = outDirectory + callingMethod + " /"
1018
1021
val sourceDir = new JFile (f)
@@ -1022,14 +1025,18 @@ trait ParallelTesting { self =>
1022
1025
if (f.isDirectory) f.listFiles.flatMap(flatten)
1023
1026
else Array (f)
1024
1027
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
+ }
1027
1034
1028
1035
// Directories in which to compile all containing files with `flags`:
1029
1036
val targetDir = new JFile (outDir + " /" + sourceDir.getName + " /" )
1030
1037
targetDir.mkdirs()
1031
1038
1032
- val target = JointCompilationSource (callingMethod, files , flags, targetDir)
1039
+ val target = JointCompilationSource (callingMethod, randomised , flags, targetDir)
1033
1040
new CompilationTest (target)
1034
1041
}
1035
1042
0 commit comments