Skip to content

Commit 29f29f3

Browse files
committed
Fixed failing test.
1 parent 60a260d commit 29f29f3

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

scalac-scoverage-plugin/src/main/scala/scoverage/IOUtils.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ object IOUtils {
5555
override def accept(pathname: File): Boolean = pathname.getName.startsWith(Constants.MeasurementsPrefix)
5656
})
5757

58-
def reportFileSearch(baseDir: File): Seq[File] = {
58+
def reportFileSearch(baseDir: File, condition: File => Boolean): Seq[File] = {
5959
def search(file: File): Seq[File] = file match {
6060
case dir if dir.isDirectory => dir.listFiles().toSeq.map(search).flatten
6161
case f if isReportFile(f) => Seq(f)
@@ -66,6 +66,7 @@ object IOUtils {
6666

6767
val isMeasurementFile = (file: File) => file.getName.startsWith(Constants.MeasurementsPrefix)
6868
val isReportFile = (file: File) => file.getName == Constants.XMLReportFilename
69+
val isDebugReportFile = (file: File) => file.getName == Constants.XMLReportFilenameWithDebug
6970

7071
// loads all the invoked statement ids from the given files
7172
def invoked(files: Seq[File]): Set[Int] = {

scalac-scoverage-plugin/src/main/scala/scoverage/report/CoverageAggregator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import scoverage.{Coverage, IOUtils}
77
object CoverageAggregator {
88

99
def aggregate(baseDir: File, targetDir: File): Option[Coverage] = {
10-
val files = IOUtils.reportFileSearch(baseDir)
10+
val files = IOUtils.reportFileSearch(baseDir, IOUtils.isReportFile)
1111
println(s"[info] Found ${files.size} subproject report files [${files.mkString(",")}]")
1212
if (files.size > 0) {
1313
val coverage = aggregatedCoverage(files)

scalac-scoverage-plugin/src/main/scala/scoverage/report/ScoverageXmlReader.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ object ScoverageXmlReader {
1414
def read(file: File): Coverage = {
1515
val xml = XML.loadFile(file)
1616

17+
var id = 0
1718
val coverage = Coverage()
1819
(xml \\ "statement") foreach { node => {
1920

@@ -38,10 +39,12 @@ object ScoverageXmlReader {
3839
method.text,
3940
source.text)
4041

42+
id = id + 1
43+
4144
coverage add Statement(
4245
source.text,
4346
location,
44-
0, // ids are irrelevant in the XML form
47+
id,
4548
start.text.toInt,
4649
end.text.toInt,
4750
line.text.toInt,

scalac-scoverage-plugin/src/test/scala/scoverage/ScoverageXmlReaderTest.scala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class ScoverageXmlReaderTest extends FreeSpec with Matchers {
2525
176,
2626
4,
2727
"",
28-
"sym",
29-
"tree",
28+
"",
29+
"",
3030
true,
3131
2))
3232

@@ -42,18 +42,20 @@ class ScoverageXmlReaderTest extends FreeSpec with Matchers {
4242
105,
4343
19,
4444
"",
45-
"sym2",
46-
"tree2",
45+
"",
46+
"",
4747
false,
4848
0))
4949

5050
val temp = new File(IOUtils.getTempPath, UUID.randomUUID.toString)
5151
temp.mkdir()
52-
new ScoverageXmlWriter(new File("/home/sam"), temp, true).write(coverage)
52+
temp.deleteOnExit()
53+
new ScoverageXmlWriter(new File("/home/sam"), temp, false).write(coverage)
5354

54-
val actual = ScoverageXmlReader.read(IOUtils.reportFile(temp, true))
55+
val actual = ScoverageXmlReader.read(IOUtils.reportFile(temp, false))
5556
// we don't care about the statement ids as the will change on reading back in
5657
actual.statements.map(_.copy(id = 0)).toSet shouldEqual coverage.statements.map(_.copy(id = 0)).toSet
58+
5759
}
5860
}
5961
}

0 commit comments

Comments
 (0)