Skip to content

Commit

Permalink
fixed issue #1
Browse files Browse the repository at this point in the history
  • Loading branch information
renep committed Oct 20, 2016
1 parent 4bb1dcd commit 58168fa
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
1 change: 1 addition & 0 deletions source/main/groovy/org/openbakery/coverage/Report.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ class Report implements OutputAppender {

def getReportData() {
if (sourceFiles != null) {
logger.debug("create report data with source files: {}", sourceFiles)
return new ReportData(getFilteredSourceFiles(), title)
}
return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ class SourceFile {
}


if (index == 0) {
filename = parseFilename(value, baseDirectory)
if (filename == null) {
File file = new File(parseFilename(value))
// make sure that the given path is a file path, because the value is a absolute path test if it is really, otherwise the string is not a file
if (file.isAbsolute()) {
filename = file.absolutePath - baseDirectory
}
} else {
SourceLine sourceLine = new SourceLine(value)
if (currentMethod == null && sourceLine.hits != SourceLine.NOT_A_NUMBER) {
Expand All @@ -43,11 +47,11 @@ class SourceFile {

}

String parseFilename(String line, String baseDirectory) {
String parseFilename(String line) {
if (line.endsWith(":")) {
return line[0..-2] - baseDirectory
return line[0..-2]
}
return line - baseDirectory
return line
}

String getFileBasename() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,24 @@ class SourceFileSpecification extends Specification {

then:
data.fileBasename == "Core_Source_OBTableViewSection"
}


def "data is not a file"() {
given:
def reportData = getReportLines("OBTableViewSection.txt");
def wrongInputLines = [
"^[[0;31mwarning...",
"^[[0;31mwarning...",
"foobar"
]
wrongInputLines.addAll(reportData)

when:
SourceFile data = new SourceFile(wrongInputLines, "/Users/rene/workspace/openbakery/OBTableViewController/");

then:
data.filename == "Core/Source/OBTableViewSection.m"

}

Expand Down

0 comments on commit 58168fa

Please sign in to comment.