Skip to content

Commit 837be45

Browse files
committed
Use filter in coverage tests
Fixes scala#14968
1 parent 7db4121 commit 837be45

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

compiler/test/dotty/tools/dotc/coverage/CoverageTests.scala

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,24 @@ class CoverageTests:
4141
lines
4242
end fixWindowsPaths
4343

44-
Files.walk(dir).filter(scalaFile.matches).forEach(p => {
45-
val path = p
46-
val fileName = path.getFileName.toString.stripSuffix(".scala")
47-
val targetDir = computeCoverageInTmp(path, dir, run)
48-
val targetFile = targetDir.resolve(s"scoverage.coverage")
49-
val expectFile = p.resolveSibling(s"$fileName.scoverage.check")
50-
51-
if updateCheckFiles then
52-
Files.copy(targetFile, expectFile, StandardCopyOption.REPLACE_EXISTING)
53-
else
54-
val expected = fixWindowsPaths(Files.readAllLines(expectFile).asScala)
55-
val obtained = fixWindowsPaths(Files.readAllLines(targetFile).asScala)
56-
if expected != obtained then
57-
for ((exp, actual),i) <- expected.zip(obtained).filter(_ != _).zipWithIndex do
58-
Console.err.println(s"wrong line ${i+1}:")
59-
Console.err.println(s" expected: $exp")
60-
Console.err.println(s" actual : $actual")
61-
fail(s"$targetFile differs from expected $expectFile")
44+
Files.walk(dir).filter(scalaFile.matches).forEach(path => {
45+
if Properties.testsFilter.isEmpty || Properties.testsFilter.exists(path.toString.contains) then
46+
val fileName = path.getFileName.toString.stripSuffix(".scala")
47+
val targetDir = computeCoverageInTmp(path, dir, run)
48+
val targetFile = targetDir.resolve(s"scoverage.coverage")
49+
val expectFile = path.resolveSibling(s"$fileName.scoverage.check")
50+
51+
if updateCheckFiles then
52+
Files.copy(targetFile, expectFile, StandardCopyOption.REPLACE_EXISTING)
53+
else
54+
val expected = fixWindowsPaths(Files.readAllLines(expectFile).asScala)
55+
val obtained = fixWindowsPaths(Files.readAllLines(targetFile).asScala)
56+
if expected != obtained then
57+
for ((exp, actual),i) <- expected.zip(obtained).filter(_ != _).zipWithIndex do
58+
Console.err.println(s"wrong line ${i+1}:")
59+
Console.err.println(s" expected: $exp")
60+
Console.err.println(s" actual : $actual")
61+
fail(s"$targetFile differs from expected $expectFile")
6262

6363
})
6464

0 commit comments

Comments
 (0)