Skip to content

Commit 3518d2f

Browse files
authored
Merge pull request #229 from scoverage/scala-2-13-0-M4
Add Scala 2.13.0-M4 support
2 parents b45d34b + d01eb77 commit 3518d2f

File tree

8 files changed

+28
-24
lines changed

8 files changed

+28
-24
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ jdk:
99
scala:
1010
- 2.10.7
1111
- 2.11.12
12-
- 2.12.4
13-
- 2.13.0-M3
12+
- 2.12.6
13+
- 2.13.0-M4
1414

1515
before_cache:
1616
- find "$HOME/.sbt/" -name '*.lock' -print0 | xargs -0 rm

build.sbt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import sbtcrossproject.CrossType
77

88
val Org = "org.scoverage"
99
val MockitoVersion = "2.19.0"
10-
val ScalatestVersion = "3.0.5-M1"
10+
val ScalatestVersion = "3.0.6-SNAP1"
1111

1212
val appSettings = Seq(
1313
organization := Org,
14-
scalaVersion := "2.12.4",
15-
crossScalaVersions := Seq("2.10.7", "2.11.12", "2.12.4", "2.13.0-M3"),
14+
scalaVersion := "2.12.6",
15+
crossScalaVersions := Seq("2.10.7", "2.11.12", "2.12.6", "2.13.0-M4"),
1616
fork in Test := false,
1717
publishMavenStyle := true,
1818
publishArtifact in Test := false,
@@ -91,7 +91,7 @@ lazy val plugin = Project("scalac-scoverage-plugin", file("scalac-scoverage-plug
9191
)).settings(libraryDependencies ++= {
9292
CrossVersion.partialVersion(scalaVersion.value) match {
9393
case Some((2, scalaMajor)) if scalaMajor > 10 => Seq(
94-
"org.scala-lang.modules" %% "scala-xml" % "1.0.6",
94+
"org.scala-lang.modules" %% "scala-xml" % "1.1.0",
9595
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.0" % "test"
9696
)
9797
case _ => Seq(

scalac-scoverage-plugin/src/main/scala/scoverage/plugin.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,19 @@ class ScoveragePlugin(val global: Global) extends Plugin {
1818
val instrumentationComponent = new ScoverageInstrumentationComponent(global, extraAfterPhase, extraBeforePhase)
1919
override val components: List[PluginComponent] = List(instrumentationComponent)
2020

21+
private def parseExclusionEntry(entryName: String, inOption: String): Seq[String] =
22+
inOption.substring(entryName.length).split(";").map(_.trim).toIndexedSeq.filterNot(_.isEmpty)
23+
2124
override def processOptions(opts: List[String], error: String => Unit): Unit = {
2225
val options = new ScoverageOptions
26+
2327
for (opt <- opts) {
2428
if (opt.startsWith("excludedPackages:")) {
25-
options.excludedPackages = opt.substring("excludedPackages:".length).split(";").map(_.trim).filterNot(_.isEmpty)
29+
options.excludedPackages = parseExclusionEntry("excludedPackages", opt)
2630
} else if (opt.startsWith("excludedFiles:")) {
27-
options.excludedFiles = opt.substring("excludedFiles:".length).split(";").map(_.trim).filterNot(_.isEmpty)
31+
options.excludedFiles = parseExclusionEntry("excludedFiles", opt)
2832
} else if (opt.startsWith("excludedSymbols:")) {
29-
options.excludedSymbols = opt.substring("excludedSymbols:".length).split(";").map(_.trim).filterNot(_.isEmpty)
33+
options.excludedSymbols = parseExclusionEntry("excludedSymbols", opt)
3034
} else if (opt.startsWith("dataDir:")) {
3135
options.dataDir = opt.substring("dataDir:".length)
3236
} else if (opt.startsWith("extraAfterPhase:") || opt.startsWith("extraBeforePhase:")) {

scalac-scoverage-plugin/src/test/scala/scoverage/IOUtilsTest.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class IOUtilsTest extends FreeSpec with MockitoSugar with OneInstancePerTest wit
1616
writer.write("1\n5\n9\n\n10\n")
1717
writer.close()
1818
val invoked = IOUtils.invoked(Seq(file))
19-
assert(invoked.toSet === Set(1, 5, 9, 10))
19+
assert(invoked === Set(1, 5, 9, 10))
2020

2121
file.delete()
2222
}
@@ -36,8 +36,8 @@ class IOUtilsTest extends FreeSpec with MockitoSugar with OneInstancePerTest wit
3636
writer2.close()
3737

3838
val files = IOUtils.findMeasurementFiles(file1.getParent)
39-
val invoked = IOUtils.invoked(files)
40-
assert(invoked.toSet === Set(1, 2, 5, 7, 9, 10, 14))
39+
val invoked = IOUtils.invoked(files.toIndexedSeq)
40+
assert(invoked === Set(1, 2, 5, 7, 9, 10, 14))
4141

4242
file1.delete()
4343
file2.delete()
@@ -66,7 +66,7 @@ class IOUtilsTest extends FreeSpec with MockitoSugar with OneInstancePerTest wit
6666

6767
val files = IOUtils.reportFileSearch(base, IOUtils.isReportFile)
6868
val invoked = IOUtils.invoked(files)
69-
assert(invoked.toSet === Set(1, 2, 3, 4, 5, 6, 7, 8, 11, 20, 30, 44))
69+
assert(invoked === Set(1, 2, 3, 4, 5, 6, 7, 8, 11, 20, 30, 44))
7070

7171
file1.delete()
7272
file2.delete()

scalac-scoverage-plugin/src/test/scala/scoverage/PluginCoverageTest.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,10 @@ class PluginCoverageTest
263263
| }
264264
| }""".stripMargin)
265265
assert(!compiler.reporter.hasErrors)
266-
// 2 statements for the two applies in Seq, one for each literal which is 6, one for the flat map,
267-
// one for the map, one for the yield op.
268-
compiler.assertNMeasuredStatements(11)
266+
// 2 statements for the two applies in Seq, one for each literal which is 6, one for the operation passed to yield.
267+
// Depending on the collections api version, there can be additional implicit canBuildFrom statements.
268+
val expectedStatementsCount = if (ScoverageCompiler.ShortScalaVersion < "2.13") 11 else 9
269+
compiler.assertNMeasuredStatements(expectedStatementsCount)
269270
}
270271

271272
test("plugin should not instrument local macro implementation") {

scalac-scoverage-plugin/src/test/scala/scoverage/ScoverageCompiler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class ScoverageCompiler(settings: scala.tools.nsc.Settings, reporter: scala.tool
103103
def assertNoCoverage() = assert(!testStore.sources.mkString(" ").contains(s"scoverage.Invoker.invoked"))
104104

105105
def assertNMeasuredStatements(n: Int): Unit = {
106-
for ( k <- 1 to n ) {
106+
for (k <- 1 to n) {
107107
assert(testStore.sources.mkString(" ").contains(s"scoverage.Invoker.invoked($k,"),
108108
s"Should be $n invoked statements but missing #$k")
109109
}
@@ -139,7 +139,7 @@ class ScoverageCompiler(settings: scala.tools.nsc.Settings, reporter: scala.tool
139139
class Transformer(unit: global.CompilationUnit) extends TypingTransformer(unit) {
140140

141141
override def transform(tree: global.Tree) = {
142-
sources append tree.toString
142+
sources += tree.toString
143143
tree
144144
}
145145
}

scalac-scoverage-runtime/jvm/src/test/scala/scoverage/InvokerConcurrencyTest.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import java.util.concurrent.Executors
55

66
import org.scalatest.{BeforeAndAfter, FunSuite}
77

8-
import scala.collection.breakOut
98
import scala.concurrent._
109
import scala.concurrent.duration._
1110

@@ -29,17 +28,17 @@ class InvokerConcurrencyTest extends FunSuite with BeforeAndAfter {
2928

3029
// Create 1k "invoked" calls on the common thread pool, to stress test
3130
// the method
32-
val futures: List[Future[Unit]] = testIds.map { i: Int =>
31+
val futures: Set[Future[Unit]] = testIds.map { i: Int =>
3332
Future {
3433
Invoker.invoked(i, measurementDir.toString)
3534
}
36-
}(breakOut)
35+
}
3736

3837
futures.foreach(Await.result(_, 1.second))
3938

4039
// Now verify that the measurement file is not corrupted by loading it
4140
val measurementFiles = Invoker.findMeasurementFiles(measurementDir)
42-
val idsFromFile = Invoker.invoked(measurementFiles).toSet
41+
val idsFromFile = Invoker.invoked(measurementFiles.toIndexedSeq)
4342

4443
idsFromFile === testIds
4544
}

scalac-scoverage-runtime/shared/src/test/scala/scoverage/InvokerMultiModuleTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ class InvokerMultiModuleTest extends FunSuite with BeforeAndAfter {
2727

2828
// Verify measurements went to correct directory
2929
val measurementFiles0 = Invoker.findMeasurementFiles(measurementDir(0))
30-
val idsFromFile0 = Invoker.invoked(measurementFiles0).toSet
30+
val idsFromFile0 = Invoker.invoked(measurementFiles0.toIndexedSeq)
3131

3232
idsFromFile0 === testIds.filter { i: Int => i % 2 == 0 }
3333

3434
val measurementFiles1 = Invoker.findMeasurementFiles(measurementDir(0))
35-
val idsFromFile1 = Invoker.invoked(measurementFiles1).toSet
35+
val idsFromFile1 = Invoker.invoked(measurementFiles1.toIndexedSeq)
3636
idsFromFile1 === testIds.filter { i: Int => i % 2 == 1 }
3737
}
3838

0 commit comments

Comments
 (0)