Skip to content

Issue #17 - windows issues #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name := "scalac-scoverage-plugin"

organization := "com.sksamuel.scoverage"

version := "0.95.8"
version := "0.95.9"

scalaVersion := "2.10.3"

Expand Down
9 changes: 7 additions & 2 deletions src/main/scala/scoverage/report/CodeGrid.scala
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ import scala.xml.{Unparsed, Node}
class CodeGrid(mfile: MeasuredFile) {
case class Cell(char: Char, var status: StatementStatus)

val sep = System.getProperty("line.separator").charAt(0)
/**
* Regardless of whether the source is Unix (\n) or DOS (\r\n), the lines will end
* with \n. We split on \n and allow an optional trailing \r on the line.
* This lets us split on lines while keep the source positions matching up.
*/
val lineBreak = '\n'

// note: we must reinclude the line sep to keep source positions correct.
val lines = source(mfile).split(sep).map(line => (line.toCharArray :+ '\n').map(Cell(_, NoData)))
val lines = source(mfile).split(lineBreak).map(line => (line.toCharArray :+ lineBreak).map(Cell(_, NoData)))
val cells = lines.flatten

mfile.statements.foreach(highlight)
Expand Down
30 changes: 17 additions & 13 deletions src/main/scala/scoverage/report/ScoverageHtmlWriter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,22 @@ class ScoverageHtmlWriter(sourceDirectory: File, outputDir: File) {

def _class(klass: MeasuredClass, addPath: Boolean): Node = {

val filename = {
val Match = "(.*/)?([^/]+.scala.html)$".r
klass.source.replace(sourceDirectory.getAbsolutePath + "/", "") + ".html" match {
case Match(path, value) => {
if (addPath && path.eq(null)) {
"<empty>/" + value
} else if (addPath && path.ne("")) {
path + value
} else {
value
}
}
val filename: String = {

val fileRelativeToSource = new File(
klass.source.replace(
sourceDirectory.getAbsolutePath + File.separator,
"") + ".html")
val path = fileRelativeToSource.getParent
val value = fileRelativeToSource.getName

if (addPath && path.eq(null)) {
"<empty>/" + value
} else if (addPath && path.ne("")) {
// (Normalise the pathSeparator to "/" in case we are running on Windows)
fileRelativeToSource.toString.replace(File.separator, "/")
} else {
value
}
}

Expand All @@ -223,7 +227,7 @@ class ScoverageHtmlWriter(sourceDirectory: File, outputDir: File) {
</a>
</td>
<td>
{klass.statements.headOption.map(_.source.split('/').last).getOrElse("")}
{klass.statements.headOption.map(_.source.split(File.separatorChar).last).getOrElse("")}
</td>
<td>
{klass.loc.toString}
Expand Down