Skip to content
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
4 changes: 2 additions & 2 deletions plugin/src/test/scala/scoverage/LocationCompiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import scala.tools.nsc.transform.TypingTransformers

import scoverage.reporter.IOUtils

class LocationCompiler(
private[scoverage] class LocationCompiler(
settings: scala.tools.nsc.Settings,
reporter: scala.tools.nsc.reporters.Reporter
) extends scala.tools.nsc.Global(settings, reporter) {
Expand All @@ -26,7 +26,7 @@ class LocationCompiler(

def writeCodeSnippetToTempFile(code: String): File = {
val file = File.createTempFile("code_snippet", ".scala")
IOUtils.writeToFile(file, code)
IOUtils.writeToFile(file, code, None)
file.deleteOnExit()
file
}
Expand Down
4 changes: 2 additions & 2 deletions plugin/src/test/scala/scoverage/ScoverageCompiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import scala.tools.nsc.transform.TypingTransformers

import scoverage.reporter.IOUtils

object ScoverageCompiler {
private[scoverage] object ScoverageCompiler {

val ScalaVersion: String = scala.util.Properties.versionNumberString
val ShortScalaVersion: String = (ScalaVersion split "[.]").toList match {
Expand Down Expand Up @@ -142,7 +142,7 @@ class ScoverageCompiler(

def writeCodeSnippetToTempFile(code: String): File = {
val file = File.createTempFile("scoverage_snippet", ".scala")
IOUtils.writeToFile(file, code)
IOUtils.writeToFile(file, code, None)
file.deleteOnExit()
file
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class CoberturaXmlWriter(
IOUtils.writeToFile(
file,
"<?xml version=\"1.0\"?>\n<!DOCTYPE coverage SYSTEM \"http://cobertura.sourceforge.net/xml/coverage-04.dtd\">\n" +
new PrettyPrinter(120, 4).format(xml(coverage))
new PrettyPrinter(120, 4).format(xml(coverage)),
sourceEncoding
)
}

Expand Down
4 changes: 2 additions & 2 deletions reporter/src/main/scala/scoverage/reporter/IOUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ object IOUtils {
def writeToFile(
file: File,
str: String,
encoding: String = Codec.UTF8.name
encoding: Option[String]
) = {
val writer = new BufferedWriter(
new OutputStreamWriter(
new FileOutputStream(file),
encoding
encoding.getOrElse(Codec.UTF8.name)
)
)
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,18 @@ class ScoverageHtmlWriter(
try IOUtils.readStreamAsString(in)
finally in.close()
}
IOUtils.writeToFile(indexFile, index)
IOUtils.writeToFile(cssFile, css)
IOUtils.writeToFile(packageFile, packageList(coverage).toString())
IOUtils.writeToFile(overviewFile, overview(coverage).toString())
IOUtils.writeToFile(indexFile, index, sourceEncoding)
IOUtils.writeToFile(cssFile, css, sourceEncoding)
IOUtils.writeToFile(
packageFile,
packageList(coverage).toString(),
sourceEncoding
)
IOUtils.writeToFile(
overviewFile,
overview(coverage).toString(),
sourceEncoding
)

coverage.packages.foreach(writePackage)
}
Expand All @@ -67,15 +75,15 @@ class ScoverageHtmlWriter(
// to com.example.html
val file = new File(outputDir, packageOverviewRelativePath(pkg))
file.getParentFile.mkdirs()
IOUtils.writeToFile(file, packageOverview(pkg).toString())
IOUtils.writeToFile(file, packageOverview(pkg).toString(), sourceEncoding)
pkg.files.foreach(writeFile)
}

private def writeFile(mfile: MeasuredFile): Unit = {
// each highlighted file is written out using the same structure as the original file.
val file = new File(outputDir, relativeSource(mfile.source) + ".html")
file.getParentFile.mkdirs()
IOUtils.writeToFile(file, filePage(mfile).toString())
IOUtils.writeToFile(file, filePage(mfile).toString(), sourceEncoding)
}

private def packageOverviewRelativePath(pkg: MeasuredPackage) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ class ScoverageXmlWriter(

def write(coverage: Coverage): Unit = {
val file = IOUtils.reportFile(outputDir, debug)
IOUtils.writeToFile(file, new PrettyPrinter(120, 4).format(xml(coverage)))
IOUtils.writeToFile(
file,
new PrettyPrinter(120, 4).format(xml(coverage)),
sourceEncoding
)
}

private def xml(coverage: Coverage): Node = {
Expand Down