Skip to content

Split dotty.tests.filter by comma, to select multiple #14268

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 1 commit into from
Jan 20, 2022
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/test/dotc/comptest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object comptest extends ParallelTesting {
def numberOfSlaves = 5
def safeMode = false
def isInteractive = true
def testFilter = None
def testFilter = Nil
def updateCheckFiles: Boolean = false

val posDir = "./tests/pos/"
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/dotty/Properties.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object Properties {
/** Filter out tests not matching the regex supplied by "dotty.tests.filter"
* define
*/
val testsFilter: Option[String] = sys.props.get("dotty.tests.filter")
val testsFilter: List[String] = sys.props.get("dotty.tests.filter").fold(Nil)(_.split(',').toList)

/** Tests should override the checkfiles with the current output */
val testsUpdateCheckfile: Boolean =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class PatmatExhaustivityTest {
.filter(f => f.extension == "scala" || f.isDirectory)
.filter { f =>
val path = if f.isDirectory then f.path + "/" else f.path
Properties.testsFilter.getOrElse("").split(',').exists(path.contains)
Properties.testsFilter.isEmpty || Properties.testsFilter.exists(path.contains)
}
.map(f => if f.isDirectory then compileDir(f.jpath) else compileFile(f.jpath))

Expand Down
2 changes: 1 addition & 1 deletion compiler/test/dotty/tools/utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def scripts(path: String): Array[File] = {
assert(dir.exists && dir.isDirectory, "Couldn't load scripts dir")
dir.listFiles.filter { f =>
val path = if f.isDirectory then f.getPath + "/" else f.getPath
path.contains(Properties.testsFilter.getOrElse(""))
Properties.testsFilter.isEmpty || Properties.testsFilter.exists(path.contains)
}
}

Expand Down
25 changes: 12 additions & 13 deletions compiler/test/dotty/tools/vulpix/ParallelTesting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ trait ParallelTesting extends RunnerOrchestration { self =>
*/
def isInteractive: Boolean

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

/** Tests should override the checkfiles with the current output */
def updateCheckFiles: Boolean
Expand Down Expand Up @@ -340,12 +340,12 @@ trait ParallelTesting extends RunnerOrchestration { self =>

/** All testSources left after filtering out */
private val filteredSources =
if (!testFilter.isDefined) testSources
if (testFilter.isEmpty) testSources
else testSources.filter {
case JointCompilationSource(_, files, _, _, _, _) =>
files.exists(file => file.getPath.contains(testFilter.get))
testFilter.exists(filter => files.exists(file => file.getPath.contains(filter)))
case SeparateCompilationSource(_, dir, _, _) =>
dir.getPath.contains(testFilter.get)
testFilter.exists(dir.getPath.contains)
}

/** Total amount of test sources being compiled by this test */
Expand Down Expand Up @@ -581,9 +581,9 @@ trait ParallelTesting extends RunnerOrchestration { self =>
else reportPassed()
}
else echo {
testFilter
.map(r => s"""No files matched "$r" in test""")
.getOrElse("No tests available under target - erroneous test?")
testFilter match
case _ :: _ => s"""No files matched "${testFilter.mkString(",")}" in test"""
case _ => "No tests available under target - erroneous test?"
}

this
Expand Down Expand Up @@ -1269,10 +1269,9 @@ trait ParallelTesting extends RunnerOrchestration { self =>

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

val filteredFiles = testFilter match {
case Some(str) => files.filter(_.getPath.contains(str))
case None => files
}
val filteredFiles = testFilter match
case _ :: _ => files.filter(f => testFilter.exists(f.getPath.contains))
case _ => Nil

class JointCompilationSourceFromTasty(
name: String,
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/dotty/tools/vulpix/VulpixMetaTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ object VulpixMetaTests extends ParallelTesting {
def numberOfSlaves = 1
def safeMode = false // Don't fork a new VM after each run test
def isInteractive = false // Don't beautify output for interactive use.
def testFilter = None // Run all the tests.
def testFilter = Nil // Run all the tests.
def updateCheckFiles: Boolean = false

@AfterClass
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/dotty/tools/vulpix/VulpixUnitTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ object VulpixUnitTests extends ParallelTesting {
def numberOfSlaves = 5
def safeMode = sys.env.get("SAFEMODE").isDefined
def isInteractive = !sys.env.contains("DRONE")
def testFilter = None
def testFilter = Nil
def updateCheckFiles: Boolean = false

@AfterClass
Expand Down