aboutsummaryrefslogtreecommitdiff
path: root/compiler/test
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
parentf7e3b7002d1eefbeaac3970be4ac729843d6a939 (diff)
downloaddotty-fd37852c0499cf0ca3dcc71333e2ab1f638d8f68.tar.gz
dotty-fd37852c0499cf0ca3dcc71333e2ab1f638d8f68.tar.bz2
dotty-fd37852c0499cf0ca3dcc71333e2ab1f638d8f68.zip
Add test filtering via `filterTest <regex>`
Diffstat (limited to 'compiler/test')
-rw-r--r--compiler/test/dotc/comptest.scala1
-rw-r--r--compiler/test/dotty/tools/dotc/CompilationTests.scala3
-rw-r--r--compiler/test/dotty/tools/dotc/ParallelTestTests.scala2
-rw-r--r--compiler/test/dotty/tools/dotc/ParallelTesting.scala66
4 files changed, 49 insertions, 23 deletions
diff --git a/compiler/test/dotc/comptest.scala b/compiler/test/dotc/comptest.scala
index c2c88abb3..279660eef 100644
--- a/compiler/test/dotc/comptest.scala
+++ b/compiler/test/dotc/comptest.scala
@@ -5,6 +5,7 @@ import dotty.tools.dotc.ParallelTesting
object comptest extends ParallelTesting {
def interactive: Boolean = true
+ def regex: Option[String] = None
implicit val defaultOutputDir: String = "."
diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala
index 83713748c..93ddab057 100644
--- a/compiler/test/dotty/tools/dotc/CompilationTests.scala
+++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala
@@ -7,13 +7,14 @@ import java.io.{ File => JFile }
import org.junit.experimental.categories.Category
-
@Category(Array(classOf[ParallelTesting]))
class CompilationTests extends ParallelTesting {
import CompilationTests._
def interactive: Boolean = !sys.env.contains("DRONE")
+ def regex: Option[String] = sys.props.get("dotty.partest.filter")
+
// Positive tests ------------------------------------------------------------
@Test def compilePos: Unit = {
diff --git a/compiler/test/dotty/tools/dotc/ParallelTestTests.scala b/compiler/test/dotty/tools/dotc/ParallelTestTests.scala
index 572f63410..a22df0ace 100644
--- a/compiler/test/dotty/tools/dotc/ParallelTestTests.scala
+++ b/compiler/test/dotty/tools/dotc/ParallelTestTests.scala
@@ -12,6 +12,8 @@ class ParallelTestTests extends ParallelTesting {
def interactive: Boolean = !sys.env.contains("DRONE")
+ def regex: Option[String] = None
+
@Test def missingFile: Unit =
try {
compileFile("../tests/partest-test/i-dont-exist.scala", defaultOptions).expectFailure.neg()
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