Skip to content

Commit

Permalink
Updating isChild method to use sbt.IO.relativize to avoid issue scove…
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewWhitaker committed Jan 6, 2016
1 parent 531547e commit ddbe423
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.scoverage.coveralls
import xml.{ Node, XML }
import scala.io.{ Codec, Source }
import java.io.File
import sbt.IO
/**
* The file will replace the original CoberturaReader
*/
Expand All @@ -25,12 +26,7 @@ class CoberturaMultiSourceReader(coberturaFile: File, sourceDirs: Seq[File], enc
* the file tree rooted at parent.
* It returns true if child and parent points to the same directory
*/
def isChild(child: File, parent: File): Boolean = {
child != null && parent != null && parent.isDirectory && {
child.getCanonicalPath == parent.getCanonicalPath ||
isChild(child.getParentFile, parent)
}
}
def isChild(child: File, parent: File): Boolean = IO.relativize(parent, child).isDefined

val reportXML = XML.loadFile(coberturaFile)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CoberturaMultiSourceReaderTest extends WordSpec with BeforeAndAfterAll wit

"CoberturaMultiSourceReader" should {
"correctly determine who is parent file and who is child file" in {
reader.isChild(srcFoo, srcFoo) shouldBe true
reader.isChild(srcFoo, srcFoo) shouldBe false
reader.isChild(srcBarFoo, srcFoo) shouldBe false
reader.isChild(srcFoo, srcBarFoo) shouldBe false
reader.isChild(srcFoo, root) shouldBe true
Expand Down

0 comments on commit ddbe423

Please sign in to comment.