Skip to content
This repository has been archived by the owner on Dec 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #23 from codacy/bugfix/FT-6145-coverage-report-gen…
Browse files Browse the repository at this point in the history
…eration

Fix file path comparison
  • Loading branch information
rtfpessoa authored Nov 7, 2018
2 parents dc57f52 + cc01f07 commit ce42b87
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class CoberturaParser(val language: Language.Value, val rootProject: File, val c
key -> value
}

allFiles.find(f => f.endsWith(sourceFilename)).map {
allFiles.find(f => f.endsWith(sanitiseFilename(sourceFilename))).map {
filename =>
CoverageFileReport(stripRoot(filename), fileHit, lineHitMap)
}
Expand Down
32 changes: 32 additions & 0 deletions src/test/resources/windows_paths_cobertura.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<coverage line-rate="0.87">
<packages>
<package line-rate="0.87" name="com.github.theon.coveralls">
<classes>
<class line-rate="0.87" name="TestSourceFile" filename="src\test\resources\TestSourceFile.scala">
<methods/>
<lines>
<line number="3" hits="0"/>
<line number="4" hits="1"/>
<line number="5" hits="1"/>
<line number="6" hits="2"/>
</lines>
</class>
<class line-rate="0.87" name="TestSourceFile" filename="src\test\resources\TestSourceFile.scala">
<methods/>
<lines>
<line number="9" hits="1"/>
<line number="10" hits="1"/>
</lines>
</class>
<class line-rate="0.87" name="TestSourceFile2" filename="src\test\resources\TestSourceFile2.scala">
<methods/>
<lines>
<line number="1" hits="1"/>
<line number="2" hits="1"/>
<line number="3" hits="1"/>
</lines>
</class>
</classes>
</package>
</packages>
</coverage>
12 changes: 12 additions & 0 deletions src/test/scala/com/codacy/parsers/CoberturaParserTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ class CoberturaParserTest extends WordSpec with BeforeAndAfterAll with Matchers
reader.generateReport() shouldEqual testReport
}

"return a valid report with windows file path separator" in {
val reader = new CoberturaParser(Language.Scala, new File("."), new File("src/test/resources/windows_paths_cobertura.xml"))

val testReport = CoverageReport(87, List(
CoverageFileReport("src/test/resources/TestSourceFile.scala", 87,
Map(5 -> 1, 10 -> 1, 6 -> 2, 9 -> 1, 3 -> 0, 4 -> 1)),
CoverageFileReport("src/test/resources/TestSourceFile2.scala", 87,
Map(1 -> 1, 2 -> 1, 3 -> 1))))

reader.generateReport() shouldEqual testReport
}

}

}

0 comments on commit ce42b87

Please sign in to comment.