Skip to content

Commit f70050b

Browse files
Merge pull request #14268 from dwijnand/testFilter-plural
Split dotty.tests.filter by comma, to select multiple
2 parents 697e675 + b483fae commit f70050b

File tree

7 files changed

+18
-19
lines changed

7 files changed

+18
-19
lines changed

compiler/test/dotc/comptest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object comptest extends ParallelTesting {
1010
def numberOfSlaves = 5
1111
def safeMode = false
1212
def isInteractive = true
13-
def testFilter = None
13+
def testFilter = Nil
1414
def updateCheckFiles: Boolean = false
1515

1616
val posDir = "./tests/pos/"

compiler/test/dotty/Properties.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ object Properties {
2626
/** Filter out tests not matching the regex supplied by "dotty.tests.filter"
2727
* define
2828
*/
29-
val testsFilter: Option[String] = sys.props.get("dotty.tests.filter")
29+
val testsFilter: List[String] = sys.props.get("dotty.tests.filter").fold(Nil)(_.split(',').toList)
3030

3131
/** Tests should override the checkfiles with the current output */
3232
val testsUpdateCheckfile: Boolean =

compiler/test/dotty/tools/dotc/transform/PatmatExhaustivityTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class PatmatExhaustivityTest {
6565
.filter(f => f.extension == "scala" || f.isDirectory)
6666
.filter { f =>
6767
val path = if f.isDirectory then f.path + "/" else f.path
68-
Properties.testsFilter.getOrElse("").split(',').exists(path.contains)
68+
Properties.testsFilter.isEmpty || Properties.testsFilter.exists(path.contains)
6969
}
7070
.map(f => if f.isDirectory then compileDir(f.jpath) else compileFile(f.jpath))
7171

compiler/test/dotty/tools/utils.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def scripts(path: String): Array[File] = {
1717
assert(dir.exists && dir.isDirectory, "Couldn't load scripts dir")
1818
dir.listFiles.filter { f =>
1919
val path = if f.isDirectory then f.getPath + "/" else f.getPath
20-
path.contains(Properties.testsFilter.getOrElse(""))
20+
Properties.testsFilter.isEmpty || Properties.testsFilter.exists(path.contains)
2121
}
2222
}
2323

compiler/test/dotty/tools/vulpix/ParallelTesting.scala

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ trait ParallelTesting extends RunnerOrchestration { self =>
4545
*/
4646
def isInteractive: Boolean
4747

48-
/** A string which is used to filter which tests to run, if `None` will run
49-
* all tests. All absolute paths that contain the substring `testFilter`
48+
/** A list of strings which is used to filter which tests to run, if `Nil` will run
49+
* all tests. All absolute paths that contain any of the substrings in `testFilter`
5050
* will be run
5151
*/
52-
def testFilter: Option[String]
52+
def testFilter: List[String]
5353

5454
/** Tests should override the checkfiles with the current output */
5555
def updateCheckFiles: Boolean
@@ -344,12 +344,12 @@ trait ParallelTesting extends RunnerOrchestration { self =>
344344

345345
/** All testSources left after filtering out */
346346
private val filteredSources =
347-
if (!testFilter.isDefined) testSources
347+
if (testFilter.isEmpty) testSources
348348
else testSources.filter {
349349
case JointCompilationSource(_, files, _, _, _, _) =>
350-
files.exists(file => file.getPath.contains(testFilter.get))
350+
testFilter.exists(filter => files.exists(file => file.getPath.contains(filter)))
351351
case SeparateCompilationSource(_, dir, _, _) =>
352-
dir.getPath.contains(testFilter.get)
352+
testFilter.exists(dir.getPath.contains)
353353
}
354354

355355
/** Total amount of test sources being compiled by this test */
@@ -628,9 +628,9 @@ trait ParallelTesting extends RunnerOrchestration { self =>
628628
else reportPassed()
629629
}
630630
else echo {
631-
testFilter
632-
.map(r => s"""No files matched "$r" in test""")
633-
.getOrElse("No tests available under target - erroneous test?")
631+
testFilter match
632+
case _ :: _ => s"""No files matched "${testFilter.mkString(",")}" in test"""
633+
case _ => "No tests available under target - erroneous test?"
634634
}
635635

636636
this
@@ -1316,10 +1316,9 @@ trait ParallelTesting extends RunnerOrchestration { self =>
13161316

13171317
val (dirs, files) = compilationTargets(sourceDir, fromTastyFilter)
13181318

1319-
val filteredFiles = testFilter match {
1320-
case Some(str) => files.filter(_.getPath.contains(str))
1321-
case None => files
1322-
}
1319+
val filteredFiles = testFilter match
1320+
case _ :: _ => files.filter(f => testFilter.exists(f.getPath.contains))
1321+
case _ => Nil
13231322

13241323
class JointCompilationSourceFromTasty(
13251324
name: String,

compiler/test/dotty/tools/vulpix/VulpixMetaTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ object VulpixMetaTests extends ParallelTesting {
2828
def numberOfSlaves = 1
2929
def safeMode = false // Don't fork a new VM after each run test
3030
def isInteractive = false // Don't beautify output for interactive use.
31-
def testFilter = None // Run all the tests.
31+
def testFilter = Nil // Run all the tests.
3232
def updateCheckFiles: Boolean = false
3333

3434
@AfterClass

compiler/test/dotty/tools/vulpix/VulpixUnitTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ object VulpixUnitTests extends ParallelTesting {
104104
def numberOfSlaves = 5
105105
def safeMode = sys.env.get("SAFEMODE").isDefined
106106
def isInteractive = !sys.env.contains("DRONE")
107-
def testFilter = None
107+
def testFilter = Nil
108108
def updateCheckFiles: Boolean = false
109109

110110
@AfterClass

0 commit comments

Comments
 (0)