aboutsummaryrefslogtreecommitdiff
path: root/compiler/test/dotty/tools/dotc/ParallelTesting.scala
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2017-03-27 16:37:45 +0200
committerFelix Mulder <felix.mulder@gmail.com>2017-03-29 10:33:27 +0200
commitfd37852c0499cf0ca3dcc71333e2ab1f638d8f68 (patch)
treecfcee801e63c9c6ce8d8dd2bd52ce546ee025991 /compiler/test/dotty/tools/dotc/ParallelTesting.scala
parentf7e3b7002d1eefbeaac3970be4ac729843d6a939 (diff)
downloaddotty-fd37852c0499cf0ca3dcc71333e2ab1f638d8f68.tar.gz
dotty-fd37852c0499cf0ca3dcc71333e2ab1f638d8f68.tar.bz2
dotty-fd37852c0499cf0ca3dcc71333e2ab1f638d8f68.zip
Add test filtering via `filterTest <regex>`
Diffstat (limited to 'compiler/test/dotty/tools/dotc/ParallelTesting.scala')
-rw-r--r--compiler/test/dotty/tools/dotc/ParallelTesting.scala66
1 files changed, 44 insertions, 22 deletions
diff --git a/compiler/test/dotty/tools/dotc/ParallelTesting.scala b/compiler/test/dotty/tools/dotc/ParallelTesting.scala
index b4452299b..2123e7657 100644
--- a/compiler/test/dotty/tools/dotc/ParallelTesting.scala
+++ b/compiler/test/dotty/tools/dotc/ParallelTesting.scala
@@ -14,6 +14,7 @@ import scala.io.Source
import scala.util.control.NonFatal
import scala.util.Try
import scala.collection.mutable
+import scala.util.matching.Regex
import core.Contexts._
import reporting.{ Reporter, TestReporter }
@@ -25,6 +26,10 @@ trait ParallelTesting {
def interactive: Boolean
+ def regex: Option[String]
+
+ private lazy val filter: Option[Regex] = regex.map(str => new Regex(str))
+
private sealed trait Target { self =>
def outDir: JFile
def flags: Array[String]
@@ -121,7 +126,16 @@ trait ParallelTesting {
/** Actual compilation run logic, the test behaviour is defined here */
protected def compilationRunnable(target: Target): Runnable
- val totalTargets = targets.length
+ private val allTargets =
+ if (!filter.isDefined) targets
+ else targets.filter {
+ case ConcurrentCompilationTarget(files, _, _) =>
+ files.exists(file => filter.get.findFirstIn(file.getAbsolutePath).isDefined)
+ case SeparateCompilationTarget(dir, _, _) =>
+ filter.get.findFirstIn(dir.getAbsolutePath).isDefined
+ }
+
+ val totalTargets = allTargets.length
private[this] var _errors = 0
def errors: Int = synchronized { _errors }
@@ -271,31 +285,39 @@ trait ParallelTesting {
private[ParallelTesting] def execute(): this.type = {
assert(_targetsCompiled == 0, "not allowed to re-use a `CompileRun`")
- val pool = threadLimit match {
- case Some(i) => JExecutors.newWorkStealingPool(i)
- case None => JExecutors.newWorkStealingPool()
- }
- if (interactive && !suppressAllOutput) pool.submit(statusRunner)
+ if (allTargets.nonEmpty) {
+ val pool = threadLimit match {
+ case Some(i) => JExecutors.newWorkStealingPool(i)
+ case None => JExecutors.newWorkStealingPool()
+ }
- targets.foreach { target =>
- pool.submit(compilationRunnable(target))
- }
+ if (interactive && !suppressAllOutput) pool.submit(statusRunner)
- pool.shutdown()
- if (!pool.awaitTermination(10, TimeUnit.MINUTES))
- throw new TimeoutException("Compiling targets timed out")
-
- if (didFail) {
- echo {
- """|
- |================================================================================
- |Test Report
- |================================================================================
- |Failing tests:""".stripMargin
+ allTargets.foreach { target =>
+ pool.submit(compilationRunnable(target))
}
- failedCompilationTargets.toArray.sorted.foreach(echo)
- failureInstructions.iterator.foreach(echo)
+
+ pool.shutdown()
+ if (!pool.awaitTermination(10, TimeUnit.MINUTES))
+ throw new TimeoutException("Compiling targets timed out")
+
+ if (didFail) {
+ echo {
+ """|
+ |================================================================================
+ |Test Report
+ |================================================================================
+ |Failing tests:""".stripMargin
+ }
+ failedCompilationTargets.toArray.sorted.foreach(echo)
+ failureInstructions.iterator.foreach(echo)
+ }
+ }
+ else echo {
+ regex
+ .map(r => s"""No files matched regex "$r" in test""")
+ .getOrElse("No tests available under target - erroneous test?")
}
this