Skip to content

Commit ebece44

Browse files
committed
Must set dataDir
1 parent d94cbc4 commit ebece44

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/scala/scoverage/plugin.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class ScoveragePlugin(val global: Global) extends Plugin {
2828
error("Unknown option: " + opt)
2929
}
3030
}
31+
if (!opts.exists(_.startsWith("dataDir:")))
32+
throw new RuntimeException("Cannot invoke plugin without specifiying <dataDir>")
3133
instrumentationComponent.setOptions(options)
3234
}
3335

@@ -41,7 +43,7 @@ class ScoveragePlugin(val global: Global) extends Plugin {
4143

4244
class ScoverageOptions {
4345
var excludedPackages: Seq[String] = Nil
44-
var dataDir: String = File.createTempFile("scoverage_find_temp_dir", ".tmp").getParent
46+
var dataDir: String = File.createTempFile("scoverage_datadir_not_defined", ".tmp").getParent
4547
}
4648

4749
class ScoveragePreComponent(val global: Global) extends PluginComponent with TypingTransformers with Transform {
@@ -99,6 +101,7 @@ class ScoverageInstrumentationComponent(val global: Global)
99101
def setOptions(options: ScoverageOptions): Unit = {
100102
this.options = options
101103
coverageFilter = new RegexCoverageFilter(options.excludedPackages)
104+
new File(options.dataDir).mkdirs()
102105
}
103106

104107
override def newPhase(prev: scala.tools.nsc.Phase): Phase = new Phase(prev) {
@@ -288,7 +291,7 @@ class ScoverageInstrumentationComponent(val global: Global)
288291
tree match {
289292

290293
// ignore synthetic trees that contain non-syths. Probably macros. Either way breaks due to range validation
291-
case t if isSynthetic(t) && containsNonSynthetic(t) => super.transform(t)
294+
case t if isSynthetic(t) && containsNonSynthetic(t) && !t.pos.isDefined => super.transform(t)
292295

293296
/**
294297
* Object creation from new.

0 commit comments

Comments
 (0)