diff --git a/.travis.yml b/.travis.yml index 49e39685..c733bd86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,8 +9,8 @@ jdk: scala: - 2.10.7 - 2.11.12 - - 2.12.4 - - 2.13.0-M3 + - 2.12.6 + - 2.13.0-M4 before_cache: - find "$HOME/.sbt/" -name '*.lock' -print0 | xargs -0 rm diff --git a/build.sbt b/build.sbt index 5c2bca59..61ed60a9 100644 --- a/build.sbt +++ b/build.sbt @@ -7,12 +7,12 @@ import sbtcrossproject.CrossType val Org = "org.scoverage" val MockitoVersion = "2.19.0" -val ScalatestVersion = "3.0.5-M1" +val ScalatestVersion = "3.0.6-SNAP1" val appSettings = Seq( organization := Org, - scalaVersion := "2.12.4", - crossScalaVersions := Seq("2.10.7", "2.11.12", "2.12.4", "2.13.0-M3"), + scalaVersion := "2.12.6", + crossScalaVersions := Seq("2.10.7", "2.11.12", "2.12.6", "2.13.0-M4"), fork in Test := false, publishMavenStyle := true, publishArtifact in Test := false, @@ -91,7 +91,7 @@ lazy val plugin = Project("scalac-scoverage-plugin", file("scalac-scoverage-plug )).settings(libraryDependencies ++= { CrossVersion.partialVersion(scalaVersion.value) match { case Some((2, scalaMajor)) if scalaMajor > 10 => Seq( - "org.scala-lang.modules" %% "scala-xml" % "1.0.6", + "org.scala-lang.modules" %% "scala-xml" % "1.1.0", "com.typesafe.scala-logging" %% "scala-logging" % "3.9.0" % "test" ) case _ => Seq( diff --git a/scalac-scoverage-plugin/src/main/scala/scoverage/plugin.scala b/scalac-scoverage-plugin/src/main/scala/scoverage/plugin.scala index fa9bd3ea..609dcebc 100644 --- a/scalac-scoverage-plugin/src/main/scala/scoverage/plugin.scala +++ b/scalac-scoverage-plugin/src/main/scala/scoverage/plugin.scala @@ -18,15 +18,19 @@ class ScoveragePlugin(val global: Global) extends Plugin { val instrumentationComponent = new ScoverageInstrumentationComponent(global, extraAfterPhase, extraBeforePhase) override val components: List[PluginComponent] = List(instrumentationComponent) + private def parseExclusionEntry(entryName: String, inOption: String): Seq[String] = + inOption.substring(entryName.length).split(";").map(_.trim).toIndexedSeq.filterNot(_.isEmpty) + override def processOptions(opts: List[String], error: String => Unit): Unit = { val options = new ScoverageOptions + for (opt <- opts) { if (opt.startsWith("excludedPackages:")) { - options.excludedPackages = opt.substring("excludedPackages:".length).split(";").map(_.trim).filterNot(_.isEmpty) + options.excludedPackages = parseExclusionEntry("excludedPackages", opt) } else if (opt.startsWith("excludedFiles:")) { - options.excludedFiles = opt.substring("excludedFiles:".length).split(";").map(_.trim).filterNot(_.isEmpty) + options.excludedFiles = parseExclusionEntry("excludedFiles", opt) } else if (opt.startsWith("excludedSymbols:")) { - options.excludedSymbols = opt.substring("excludedSymbols:".length).split(";").map(_.trim).filterNot(_.isEmpty) + options.excludedSymbols = parseExclusionEntry("excludedSymbols", opt) } else if (opt.startsWith("dataDir:")) { options.dataDir = opt.substring("dataDir:".length) } else if (opt.startsWith("extraAfterPhase:") || opt.startsWith("extraBeforePhase:")) { diff --git a/scalac-scoverage-plugin/src/test/scala/scoverage/IOUtilsTest.scala b/scalac-scoverage-plugin/src/test/scala/scoverage/IOUtilsTest.scala index f653b835..720b5139 100644 --- a/scalac-scoverage-plugin/src/test/scala/scoverage/IOUtilsTest.scala +++ b/scalac-scoverage-plugin/src/test/scala/scoverage/IOUtilsTest.scala @@ -16,7 +16,7 @@ class IOUtilsTest extends FreeSpec with MockitoSugar with OneInstancePerTest wit writer.write("1\n5\n9\n\n10\n") writer.close() val invoked = IOUtils.invoked(Seq(file)) - assert(invoked.toSet === Set(1, 5, 9, 10)) + assert(invoked === Set(1, 5, 9, 10)) file.delete() } @@ -36,8 +36,8 @@ class IOUtilsTest extends FreeSpec with MockitoSugar with OneInstancePerTest wit writer2.close() val files = IOUtils.findMeasurementFiles(file1.getParent) - val invoked = IOUtils.invoked(files) - assert(invoked.toSet === Set(1, 2, 5, 7, 9, 10, 14)) + val invoked = IOUtils.invoked(files.toIndexedSeq) + assert(invoked === Set(1, 2, 5, 7, 9, 10, 14)) file1.delete() file2.delete() @@ -66,7 +66,7 @@ class IOUtilsTest extends FreeSpec with MockitoSugar with OneInstancePerTest wit val files = IOUtils.reportFileSearch(base, IOUtils.isReportFile) val invoked = IOUtils.invoked(files) - assert(invoked.toSet === Set(1, 2, 3, 4, 5, 6, 7, 8, 11, 20, 30, 44)) + assert(invoked === Set(1, 2, 3, 4, 5, 6, 7, 8, 11, 20, 30, 44)) file1.delete() file2.delete() diff --git a/scalac-scoverage-plugin/src/test/scala/scoverage/PluginCoverageTest.scala b/scalac-scoverage-plugin/src/test/scala/scoverage/PluginCoverageTest.scala index 20c9b895..2c292f61 100644 --- a/scalac-scoverage-plugin/src/test/scala/scoverage/PluginCoverageTest.scala +++ b/scalac-scoverage-plugin/src/test/scala/scoverage/PluginCoverageTest.scala @@ -263,9 +263,10 @@ class PluginCoverageTest | } | }""".stripMargin) assert(!compiler.reporter.hasErrors) - // 2 statements for the two applies in Seq, one for each literal which is 6, one for the flat map, - // one for the map, one for the yield op. - compiler.assertNMeasuredStatements(11) + // 2 statements for the two applies in Seq, one for each literal which is 6, one for the operation passed to yield. + // Depending on the collections api version, there can be additional implicit canBuildFrom statements. + val expectedStatementsCount = if (ScoverageCompiler.ShortScalaVersion < "2.13") 11 else 9 + compiler.assertNMeasuredStatements(expectedStatementsCount) } test("plugin should not instrument local macro implementation") { diff --git a/scalac-scoverage-plugin/src/test/scala/scoverage/ScoverageCompiler.scala b/scalac-scoverage-plugin/src/test/scala/scoverage/ScoverageCompiler.scala index 75abedbf..16c3f31a 100644 --- a/scalac-scoverage-plugin/src/test/scala/scoverage/ScoverageCompiler.scala +++ b/scalac-scoverage-plugin/src/test/scala/scoverage/ScoverageCompiler.scala @@ -103,7 +103,7 @@ class ScoverageCompiler(settings: scala.tools.nsc.Settings, reporter: scala.tool def assertNoCoverage() = assert(!testStore.sources.mkString(" ").contains(s"scoverage.Invoker.invoked")) def assertNMeasuredStatements(n: Int): Unit = { - for ( k <- 1 to n ) { + for (k <- 1 to n) { assert(testStore.sources.mkString(" ").contains(s"scoverage.Invoker.invoked($k,"), s"Should be $n invoked statements but missing #$k") } @@ -139,7 +139,7 @@ class ScoverageCompiler(settings: scala.tools.nsc.Settings, reporter: scala.tool class Transformer(unit: global.CompilationUnit) extends TypingTransformer(unit) { override def transform(tree: global.Tree) = { - sources append tree.toString + sources += tree.toString tree } } diff --git a/scalac-scoverage-runtime/jvm/src/test/scala/scoverage/InvokerConcurrencyTest.scala b/scalac-scoverage-runtime/jvm/src/test/scala/scoverage/InvokerConcurrencyTest.scala index 7943db95..d07e233d 100644 --- a/scalac-scoverage-runtime/jvm/src/test/scala/scoverage/InvokerConcurrencyTest.scala +++ b/scalac-scoverage-runtime/jvm/src/test/scala/scoverage/InvokerConcurrencyTest.scala @@ -5,7 +5,6 @@ import java.util.concurrent.Executors import org.scalatest.{BeforeAndAfter, FunSuite} -import scala.collection.breakOut import scala.concurrent._ import scala.concurrent.duration._ @@ -29,17 +28,17 @@ class InvokerConcurrencyTest extends FunSuite with BeforeAndAfter { // Create 1k "invoked" calls on the common thread pool, to stress test // the method - val futures: List[Future[Unit]] = testIds.map { i: Int => + val futures: Set[Future[Unit]] = testIds.map { i: Int => Future { Invoker.invoked(i, measurementDir.toString) } - }(breakOut) + } futures.foreach(Await.result(_, 1.second)) // Now verify that the measurement file is not corrupted by loading it val measurementFiles = Invoker.findMeasurementFiles(measurementDir) - val idsFromFile = Invoker.invoked(measurementFiles).toSet + val idsFromFile = Invoker.invoked(measurementFiles.toIndexedSeq) idsFromFile === testIds } diff --git a/scalac-scoverage-runtime/shared/src/test/scala/scoverage/InvokerMultiModuleTest.scala b/scalac-scoverage-runtime/shared/src/test/scala/scoverage/InvokerMultiModuleTest.scala index 013153dd..2baa5822 100644 --- a/scalac-scoverage-runtime/shared/src/test/scala/scoverage/InvokerMultiModuleTest.scala +++ b/scalac-scoverage-runtime/shared/src/test/scala/scoverage/InvokerMultiModuleTest.scala @@ -27,12 +27,12 @@ class InvokerMultiModuleTest extends FunSuite with BeforeAndAfter { // Verify measurements went to correct directory val measurementFiles0 = Invoker.findMeasurementFiles(measurementDir(0)) - val idsFromFile0 = Invoker.invoked(measurementFiles0).toSet + val idsFromFile0 = Invoker.invoked(measurementFiles0.toIndexedSeq) idsFromFile0 === testIds.filter { i: Int => i % 2 == 0 } val measurementFiles1 = Invoker.findMeasurementFiles(measurementDir(0)) - val idsFromFile1 = Invoker.invoked(measurementFiles1).toSet + val idsFromFile1 = Invoker.invoked(measurementFiles1.toIndexedSeq) idsFromFile1 === testIds.filter { i: Int => i % 2 == 1 } }