Skip to content

Deterministically randomises test compilation order #2193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/Trees.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 13 additions & 2 deletions compiler/test/dotty/tools/dotc/ParallelTesting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -1010,8 +1011,11 @@ trait ParallelTesting { self =>
/** Compiles a directory `f` using the supplied `flags`. This method does
* deep compilation, that is - it compiles all files and subdirectories
* contained within the directory `f`.
*
* By default, files are compiled in alphabetical order. An optional seed
* can be used for randomization.
*/
def compileDir(f: String, flags: Array[String])(implicit outDirectory: String): CompilationTest = {
def compileDir(f: String, flags: Array[String], randomOrder: Option[Int] = None)(implicit outDirectory: String): CompilationTest = {
val callingMethod = getCallingMethod
val outDir = outDirectory + callingMethod + "/"
val sourceDir = new JFile(f)
Expand All @@ -1021,11 +1025,18 @@ trait ParallelTesting { self =>
if (f.isDirectory) f.listFiles.flatMap(flatten)
else Array(f)

// Sort files either alphabetically or randomly using the provided seed:
val sortedFiles = flatten(sourceDir).sorted
val randomized = randomOrder match {
case None => sortedFiles
case Some(seed) => new Random(seed).shuffle(sortedFiles.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, randomized, flags, targetDir)
new CompilationTest(target)
}

Expand Down