Skip to content

Commit 28337aa

Browse files
authored
Merge pull request #377 from ckipp01/disabled
Ensure reporting and aggregation still works when disabling modules.
2 parents c190f3d + bb99b2c commit 28337aa

File tree

11 files changed

+101
-3
lines changed

11 files changed

+101
-3
lines changed

Diff for: src/main/scala/scoverage/ScoverageSbtPlugin.scala

+6-3
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,12 @@ object ScoverageSbtPlugin extends AutoPlugin {
170170
implicit val log = streams.value.log
171171
log.info(s"Aggregating coverage from subprojects...")
172172

173-
val dataDirs = coverageDataDir
174-
.all(aggregateFilter)
175-
.value map (_ / Constants.DataDir) filter (_.isDirectory)
173+
val dataDirs = coverageDataDir.?.all(aggregateFilter).value
174+
.collect {
175+
case Some(file) if (file / Constants.DataDir).isDirectory =>
176+
file / Constants.DataDir
177+
}
178+
176179
CoverageAggregator.aggregate(dataDirs) match {
177180
case Some(cov) =>
178181
writeReports(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package a
2+
3+
object AdderScala {
4+
5+
def add(x: Int, y: Int) = x + y
6+
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import munit.FunSuite
2+
import a.AdderScala
3+
4+
class AdderTestSuite extends FunSuite {
5+
test("Adder should sum two numbers") {
6+
assertEquals(AdderScala.add(1, 2), 3)
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package b
2+
3+
object AdderScala {
4+
5+
def add(x: Int, y: Int) = x + y
6+
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import munit.FunSuite
2+
import b.AdderScala
3+
4+
class AdderTestSuite extends FunSuite {
5+
test("Adder should sum two numbers") {
6+
assertEquals(AdderScala.add(1, 2), 3)
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
inThisBuild(
2+
List(
3+
organization := "org.scoverage",
4+
scalaVersion := "2.13.6",
5+
libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test
6+
)
7+
)
8+
9+
lazy val a = project
10+
lazy val b = project
11+
lazy val c = project.disablePlugins(ScoverageSbtPlugin)
12+
13+
ThisBuild / resolvers ++= {
14+
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT")))
15+
Seq(Resolver.sonatypeRepo("snapshots"))
16+
else Seq.empty
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package c
2+
3+
object AdderScala {
4+
5+
def add(x: Int, y: Int) = x + y
6+
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import munit.FunSuite
2+
import c.AdderScala
3+
4+
class AdderTestSuite extends FunSuite {
5+
test("Adder should sum two numbers") {
6+
assertEquals(AdderScala.add(1, 2), 3)
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=1.5.5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
val pluginVersion = sys.props.getOrElse(
2+
"plugin.version",
3+
throw new RuntimeException(
4+
"""|The system property 'plugin.version' is not defined.
5+
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin
6+
)
7+
)
8+
9+
addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion)
10+
11+
resolvers ++= {
12+
if (pluginVersion.endsWith("-SNAPSHOT"))
13+
Seq(Resolver.sonatypeRepo("snapshots"))
14+
else
15+
Seq.empty
16+
}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# run scoverage using the coverage task
2+
> clean
3+
> coverage
4+
> test
5+
# There should be scoverage-data directory
6+
$ exists a/target/scala-2.13/scoverage-data
7+
$ exists b/target/scala-2.13/scoverage-data
8+
$ absent c/target/scala-2.13/scoverage-data
9+
> coverageReport
10+
# There should be scoverage-report directory
11+
$ exists a/target/scala-2.13/scoverage-report
12+
$ exists b/target/scala-2.13/scoverage-report
13+
$ absent c/target/scala-2.13/scoverage-report
14+
> coverageAggregate
15+
# There should be a root scoverage-report directory
16+
$ exists target/scala-2.13/scoverage-report

0 commit comments

Comments
 (0)