From f693ba744124940e3dc5ebfbf0f0c248c61a84d0 Mon Sep 17 00:00:00 2001 From: Olivier Blanvillain Date: Wed, 5 Apr 2017 09:42:31 +0200 Subject: Deterministically randomises test compilation order The previous implementation would compile tests in different orders from machine to machine, depending on the order in which *.scala files are listed by the operating system. --- compiler/src/dotty/tools/dotc/ast/Trees.scala | 2 +- compiler/src/dotty/tools/dotc/core/Types.scala | 2 +- compiler/test/dotty/tools/dotc/ParallelTesting.scala | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'compiler') diff --git a/compiler/src/dotty/tools/dotc/ast/Trees.scala b/compiler/src/dotty/tools/dotc/ast/Trees.scala index 669e5429c..21cc6a6a3 100644 --- a/compiler/src/dotty/tools/dotc/ast/Trees.scala +++ b/compiler/src/dotty/tools/dotc/ast/Trees.scala @@ -788,7 +788,7 @@ object Trees { def complete(implicit ctx: Context): T } - // ----- Generic Tree Instances, inherited from `tpt` and `untpd`. + // ----- Generic Tree Instances, inherited from `tpt` and `untpd`. abstract class Instance[T >: Untyped <: Type] extends DotClass { inst => diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index c80107f93..3f40f8a06 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -1793,7 +1793,7 @@ object Types { override def newLikeThis(prefix: Type)(implicit ctx: Context): TermRef = fixDenot(TermRef.withSig(prefix, name, sig), prefix) - override def shadowed(implicit ctx: Context): NamedType = + override def shadowed(implicit ctx: Context): NamedType = fixDenot(TermRef.withSig(prefix, name.shadowedName, sig), prefix) override def equals(that: Any) = that match { diff --git a/compiler/test/dotty/tools/dotc/ParallelTesting.scala b/compiler/test/dotty/tools/dotc/ParallelTesting.scala index 2b20887e3..e5068dcd0 100644 --- a/compiler/test/dotty/tools/dotc/ParallelTesting.scala +++ b/compiler/test/dotty/tools/dotc/ParallelTesting.scala @@ -15,6 +15,7 @@ import scala.util.control.NonFatal import scala.util.Try import scala.collection.mutable import scala.util.matching.Regex +import scala.util.Random import core.Contexts._ import reporting.{ Reporter, TestReporter } @@ -1011,7 +1012,7 @@ trait ParallelTesting { self => * deep compilation, that is - it compiles all files and subdirectories * contained within the directory `f`. */ - def compileDir(f: String, flags: Array[String])(implicit outDirectory: String): CompilationTest = { + def compileDir(f: String, flags: Array[String], seed: Int = 42)(implicit outDirectory: String): CompilationTest = { val callingMethod = getCallingMethod val outDir = outDirectory + callingMethod + "/" val sourceDir = new JFile(f) @@ -1021,11 +1022,14 @@ trait ParallelTesting { self => if (f.isDirectory) f.listFiles.flatMap(flatten) else Array(f) + // Deterministically randomises compilation order + val files = new Random(seed).shuffle(flatten(sourceDir).toList).toArray + // Directories in which to compile all containing files with `flags`: val targetDir = new JFile(outDir + "/" + sourceDir.getName + "/") targetDir.mkdirs() - val target = JointCompilationSource(callingMethod, flatten(sourceDir), flags, targetDir) + val target = JointCompilationSource(callingMethod, files, flags, targetDir) new CompilationTest(target) } -- cgit v1.2.3