From 19a66738a64304e24f027baae29a796411426ea3 Mon Sep 17 00:00:00 2001 From: Oleksii Nikitchuk Date: Wed, 2 May 2018 21:43:41 +0300 Subject: [PATCH 01/49] added TC branch coverage reporting --- src/main/scala/scoverage/ScoverageSbtPlugin.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/scala/scoverage/ScoverageSbtPlugin.scala b/src/main/scala/scoverage/ScoverageSbtPlugin.scala index e72c346b..0b64fd58 100644 --- a/src/main/scala/scoverage/ScoverageSbtPlugin.scala +++ b/src/main/scala/scoverage/ScoverageSbtPlugin.scala @@ -208,9 +208,11 @@ object ScoverageSbtPlugin extends AutoPlugin { def statsKeyValue(key: String, value: Int): String = s"##teamcity[buildStatisticValue key='$key' value='$value']" - // Log statement coverage as per: https://devnet.jetbrains.com/message/5467985 + // Log statement and branch coverage as per: https://confluence.jetbrains.com/display/TCD10/Custom+Chart#CustomChart-DefaultStatisticsValuesProvidedbyTeamCity log.info(statsKeyValue("CodeCoverageAbsSCovered", coverage.invokedStatementCount)) log.info(statsKeyValue("CodeCoverageAbsSTotal", coverage.statementCount)) + log.info(statsKeyValue("CodeCoverageAbsRCovered", coverage.invokedBranchesCount)) + log.info(statsKeyValue("CodeCoverageAbsRTotal", coverage.branchCount)) // Log branch coverage as a custom metrics (in percent) log.info(statsKeyValue("CodeCoverageBranch", "%.0f".format(coverage.branchCoveragePercent).toInt)) From 9defcea4ae1c9dd47141af9968659525a84389ca Mon Sep 17 00:00:00 2001 From: Patrick Bohan Date: Wed, 29 Jan 2020 09:49:38 -0500 Subject: [PATCH 02/49] Fixed README to say you do not need to run coverageReport before coverageAggregate --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 94454d41..e00dd71a 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ By default, scoverage will generate reports for each project separately. You can (Note, you must do this after all the coverage data is complete as a separate command, so you cannot do `sbt coverage test coverageAggregate` (at least until a way around this is found).) -(You must have first run `sbt coverageReport` for `coverageAggregate` to work. It aggregates over the sub-projects' report xml rather than over the coverage data directly.) +(You do not need to run `coverageReport` before `coverageAggregate`; it aggregates over the sub-projects' coverage data directly, not the report xml.) ## Exclude classes and packages From 78eac8dc6007b89056548b3986a3abd5dcfbf29a Mon Sep 17 00:00:00 2001 From: Devon Stewart Date: Fri, 5 Feb 2021 15:31:46 -0800 Subject: [PATCH 03/49] Typo --- src/main/scala/scoverage/ScoverageSbtPlugin.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/scoverage/ScoverageSbtPlugin.scala b/src/main/scala/scoverage/ScoverageSbtPlugin.scala index 04b4d41f..937983f4 100644 --- a/src/main/scala/scoverage/ScoverageSbtPlugin.scala +++ b/src/main/scala/scoverage/ScoverageSbtPlugin.scala @@ -55,7 +55,7 @@ object ScoverageSbtPlugin extends AutoPlugin { libraryDependencies ++= { if (coverageEnabled.value) Seq( - // We only add for "compile"" because of macros. This setting could be optimed to just "test" if the handling + // We only add for "compile" because of macros. This setting could be optimed to just "test" if the handling // of macro coverage was improved. OrgScoverage %% (scalacRuntime(libraryDependencies.value)) % coverageScalacPluginVersion.value, // We don't want to instrument the test code itself, nor add to a pom when published with coverage enabled. From fb8480eff08c2ab2ddc7179353131049006fe0ff Mon Sep 17 00:00:00 2001 From: Devon Stewart Date: Fri, 5 Feb 2021 15:32:08 -0800 Subject: [PATCH 04/49] Depend on the exact bincompat (patch) version of scalac --- src/main/scala/scoverage/ScoverageSbtPlugin.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/scoverage/ScoverageSbtPlugin.scala b/src/main/scala/scoverage/ScoverageSbtPlugin.scala index 937983f4..bf197e3d 100644 --- a/src/main/scala/scoverage/ScoverageSbtPlugin.scala +++ b/src/main/scala/scoverage/ScoverageSbtPlugin.scala @@ -57,9 +57,9 @@ object ScoverageSbtPlugin extends AutoPlugin { Seq( // We only add for "compile" because of macros. This setting could be optimed to just "test" if the handling // of macro coverage was improved. - OrgScoverage %% (scalacRuntime(libraryDependencies.value)) % coverageScalacPluginVersion.value, + (OrgScoverage %% (scalacRuntime(libraryDependencies.value)) % coverageScalacPluginVersion.value).cross(CrossVersion.full), // We don't want to instrument the test code itself, nor add to a pom when published with coverage enabled. - OrgScoverage %% ScalacPluginArtifact % coverageScalacPluginVersion.value % ScoveragePluginConfig.name + (OrgScoverage %% ScalacPluginArtifact % coverageScalacPluginVersion.value % ScoveragePluginConfig.name).cross(CrossVersion.full) ) else Nil From 192db282a85b09a85b8d3bdf550a6c0be5fae0d1 Mon Sep 17 00:00:00 2001 From: Devon Stewart Date: Fri, 5 Feb 2021 15:37:57 -0800 Subject: [PATCH 05/49] Adding PR workflow --- .github/workflows/pr.yml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/pr.yml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 00000000..0586c18d --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,39 @@ +name: pr + +on: + pull_request: + paths-ignore: + - 'doc/**' + - 'docs/**' + - '*.md' + +jobs: + scala: + runs-on: ubuntu-latest + strategy: + matrix: + java: [ '11' ] + scala: [ + { version: '2.12.13' }, + { version: '2.12.12' }, + { version: '2.12.11' }, + { version: '2.12.10' }, + { version: '2.13.4' }, + { version: '2.13.3' }, + { version: '2.13.2' }, + { version: '2.13.1' }, + { version: '2.13.0' } + ] + steps: + - name: checkout the repo + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + + - name: run tests + run: sbt ++${{ matrix.scala.version }} test scripted From e944e6d5622e43f25004fe278c9bd15fd9c6b4a5 Mon Sep 17 00:00:00 2001 From: Dominik Zeiger Date: Wed, 28 Apr 2021 01:33:06 +0200 Subject: [PATCH 06/49] cleanup build file, js test fix --- .github/workflows/pr.yml | 1 + README.md | 20 +-- build.sbt | 118 +++++++++--------- project/build.properties | 2 +- project/plugins.sbt | 2 +- src/main/scala/scoverage/ScoverageKeys.scala | 2 - .../scala/scoverage/ScoverageSbtPlugin.scala | 25 ++-- .../scoverage/aggregate-only/build.sbt | 6 +- .../aggregate-only/project/plugins.sbt | 2 +- src/sbt-test/scoverage/aggregate/build.sbt | 6 +- .../scoverage/aggregate/project/plugins.sbt | 2 +- src/sbt-test/scoverage/bad-coverage/build.sbt | 4 +- .../bad-coverage/project/plugins.sbt | 2 +- src/sbt-test/scoverage/coverage-off/build.sbt | 4 +- .../coverage-off/project/plugins.sbt | 2 +- .../scoverage/good-coverage/build.sbt | 4 +- src/sbt-test/scoverage/preserve-set/build.sbt | 8 +- src/sbt-test/scoverage/preserve-set/test | 17 +-- .../scoverage/scalac-plugin-version/build.sbt | 8 +- src/sbt-test/scoverage/scalajs/build.sbt | 8 +- .../scoverage/scalajs/project/plugins.sbt | 4 +- .../sjstest/js/src/test/scala/JsTest.scala | 5 +- .../sjstest/jvm/src/test/scala/JvmTest.scala | 5 +- .../shared/src/test/scala/SharedTest.scala | 5 +- version.sbt | 2 +- 25 files changed, 123 insertions(+), 141 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 0586c18d..40deb99c 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -18,6 +18,7 @@ jobs: { version: '2.12.12' }, { version: '2.12.11' }, { version: '2.12.10' }, + { version: '2.13.5' }, { version: '2.13.4' }, { version: '2.13.3' }, { version: '2.13.2' }, diff --git a/README.md b/README.md index e00dd71a..83218ebc 100644 --- a/README.md +++ b/README.md @@ -15,16 +15,12 @@ discussion on scoverage. Make sure your SBT version in project/build.properties: ``` -sbt.version = 0.13.17 -``` -or -``` -sbt.version = 1.1.1 +sbt.version = 1.5.1 ``` Add the plugin in project/plugins.sbt: ```scala -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.2") ``` Run the tests with enabled coverage: @@ -54,6 +50,10 @@ turn it back off when you're done running reports, use the `coverageOff` command Sample project with scoverage in both sbt and maven - [the scoverage samples project](https://github.com/scoverage/sbt-scoverage-samples). +## Notes on upgrading to version 1.6.x +* ´coverageCleanSubprojectFiles´ key has been removed +* scala version 2.12+ is required as a minimum + ## Notes on upgrading to version 1.6.0 * `coverageAggregate` aggregates raw coverage data, not coverage xml reports for modules. @@ -117,14 +117,6 @@ coverageFailOnMinimum := true These settings will be enforced when the reports are generated. If you generate an aggregate report using `coverageAggregate` then these settings will apply to that report. -## Highlighting - -If you are using Scala 2.11.1 or less, then highlighting will not work (due to this bug which was fixed in 2.11.2 https://github.com/scala/scala/pull/3799). In that case you must disable highlighting by adding the following to your build: - -```scala -coverageHighlighting := false -``` - ## Failing tests Scoverage does a lot of file writing behind the scenes in order to track which statements have been executed. If you are running into a scenario where your tests normally pass, but fail when scoverage is enabled, then the culprit can be one of the following: diff --git a/build.sbt b/build.sbt index 47923c9f..576a2deb 100644 --- a/build.sbt +++ b/build.sbt @@ -1,77 +1,79 @@ name := "sbt-scoverage" - organization := "org.scoverage" -enablePlugins(SbtPlugin) - -scalacOptions := Seq("-unchecked", "-deprecation", "-feature", "-encoding", "utf8") - -resolvers ++= { - if (isSnapshot.value) Seq(Resolver.sonatypeRepo("snapshots")) else Nil -} - -libraryDependencies += "org.scoverage" %% "scalac-scoverage-plugin" % "1.4.0" - -publishMavenStyle := true - -publishArtifact in Test := false +import sbt.ScriptedPlugin.autoImport.scriptedLaunchOpts +import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._ -scriptedLaunchOpts ++= Seq( - "-Xmx1024M", - "-Dplugin.version=" + version.value -) - -import ReleaseTransformations._ releaseProcess := Seq[ReleaseStep]( checkSnapshotDependencies, inquireVersions, runClean, releaseStepCommandAndRemaining("^ test"), +// releaseStepCommandAndRemaining("^ scripted"), setReleaseVersion, commitReleaseVersion, tagRelease, - releaseStepCommandAndRemaining("^ publishSigned"), + releaseStepCommandAndRemaining("^ publish"), setNextVersion, commitNextVersion, pushChanges ) -releaseCrossBuild := false - -publishTo := { - if (isSnapshot.value) - Some("snapshots" at "https://oss.sonatype.org/content/repositories/snapshots") - else - Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2") -} - -pomExtra := { - https://github.com/scoverage/sbt-scoverage - - - Apache 2 - http://www.apache.org/licenses/LICENSE-2.0 - repo - - - - git@github.com:scoverage/sbt-scoverage.git - scm:git@github.com:scoverage/sbt-scoverage.git - - - - sksamuel - sksamuel - http://github.com/sksamuel - - - gslowikowski - Grzegorz Slowikowski - http://github.com/gslowikowski - - -} - -crossSbtVersions := Vector("0.13.18", "1.2.8") +lazy val root = Project("sbt-scoverage", file(".")) + .enablePlugins(SbtPlugin) + .settings( + libraryDependencies ++= Seq( + "org.scala-lang" % "scala-compiler" % scalaVersion.value % Compile + ), + libraryDependencies += "org.scoverage" %% "scalac-scoverage-plugin" % "1.4.3-SNAPSHOT" cross(CrossVersion.full), + scalaVersion := "2.12.13", + publishMavenStyle := true, + publishConfiguration := publishConfiguration.value.withOverwrite(true), + publishLocalConfiguration := publishLocalConfiguration.value.withOverwrite(true), + releasePublishArtifactsAction := PgpKeys.publishSigned.value, + Test / fork := false, + Test / publishArtifact := false, + Test / parallelExecution := false, + scalacOptions := Seq("-unchecked", "-deprecation", "-feature", "-encoding", "utf8"), + publishTo := { + if (isSnapshot.value) + Some("snapshots" at "https://oss.sonatype.org/content/repositories/snapshots") + else + Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2") + }, + resolvers ++= { + if (isSnapshot.value) Seq(Resolver.sonatypeRepo("snapshots")) else Nil + }, + scriptedLaunchOpts ++= Seq( + "-Xmx1024M", + "-Dplugin.version=" + version.value + ), + pomExtra := { + https://github.com/scoverage/sbt-scoverage + + + Apache 2 + http://www.apache.org/licenses/LICENSE-2.0 + repo + + + + git@github.com:scoverage/sbt-scoverage.git + scm:git@github.com:scoverage/sbt-scoverage.git + + + + sksamuel + sksamuel + http://github.com/sksamuel + + + gslowikowski + Grzegorz Slowikowski + http://github.com/gslowikowski + + + } + ) scalariformAutoformat := false diff --git a/project/build.properties b/project/build.properties index c0bab049..f0be67b9 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.2.8 +sbt.version=1.5.1 diff --git a/project/plugins.sbt b/project/plugins.sbt index 8652f6d6..2b6a8715 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -4,4 +4,4 @@ addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0") addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.1") -addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.7") +addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13") diff --git a/src/main/scala/scoverage/ScoverageKeys.scala b/src/main/scala/scoverage/ScoverageKeys.scala index b3eec0dc..1b565dbb 100644 --- a/src/main/scala/scoverage/ScoverageKeys.scala +++ b/src/main/scala/scoverage/ScoverageKeys.scala @@ -15,8 +15,6 @@ object ScoverageKeys { lazy val coverageOutputXML = settingKey[Boolean]("enables xml report generation") lazy val coverageOutputHTML = settingKey[Boolean]("enables html report generation") lazy val coverageOutputDebug = settingKey[Boolean]("turn on the debug report") - @deprecated("", "1.6.0") - lazy val coverageCleanSubprojectFiles = settingKey[Boolean]("removes subproject data after an aggregation") lazy val coverageOutputTeamCity = settingKey[Boolean]("turn on teamcity reporting") lazy val coverageScalacPluginVersion = settingKey[String]("version of scalac-scoverage-plugin to use") } diff --git a/src/main/scala/scoverage/ScoverageSbtPlugin.scala b/src/main/scala/scoverage/ScoverageSbtPlugin.scala index bf197e3d..f4b55635 100644 --- a/src/main/scala/scoverage/ScoverageSbtPlugin.scala +++ b/src/main/scala/scoverage/ScoverageSbtPlugin.scala @@ -11,7 +11,7 @@ object ScoverageSbtPlugin extends AutoPlugin { val ScalacRuntimeArtifact = "scalac-scoverage-runtime" val ScalacPluginArtifact = "scalac-scoverage-plugin" // this should match the version defined in build.sbt - val DefaultScoverageVersion = "1.4.1" + val DefaultScoverageVersion = "1.4.3-SNAPSHOT" val autoImport = ScoverageKeys lazy val ScoveragePluginConfig = config("scoveragePlugin").hide @@ -34,26 +34,25 @@ object ScoverageSbtPlugin extends AutoPlugin { coverageOutputHTML := true, coverageOutputCobertura := true, coverageOutputDebug := false, - coverageCleanSubprojectFiles := true, coverageOutputTeamCity := false, coverageScalacPluginVersion := DefaultScoverageVersion ) override def buildSettings: Seq[Setting[_]] = super.buildSettings ++ - addCommandAlias("coverage", ";set coverageEnabled in ThisBuild := true") ++ - addCommandAlias("coverageOn", ";set coverageEnabled in ThisBuild := true") ++ - addCommandAlias("coverageOff", ";set coverageEnabled in ThisBuild := false") + addCommandAlias("coverage", ";set ThisBuild / coverageEnabled := true") ++ + addCommandAlias("coverageOn", ";set ThisBuild / coverageEnabled := true") ++ + addCommandAlias("coverageOff", ";set ThisBuild / coverageEnabled := false") override def projectSettings: Seq[Setting[_]] = Seq( ivyConfigurations += ScoveragePluginConfig, coverageReport := coverageReport0.value, coverageAggregate := coverageAggregate0.value, - aggregate in coverageAggregate := false + coverageAggregate / aggregate := false ) ++ coverageSettings ++ scalacSettings private lazy val coverageSettings = Seq( - libraryDependencies ++= { - if (coverageEnabled.value) + libraryDependencies ++= { + if (coverageEnabled.value) { Seq( // We only add for "compile" because of macros. This setting could be optimed to just "test" if the handling // of macro coverage was improved. @@ -61,13 +60,13 @@ object ScoverageSbtPlugin extends AutoPlugin { // We don't want to instrument the test code itself, nor add to a pom when published with coverage enabled. (OrgScoverage %% ScalacPluginArtifact % coverageScalacPluginVersion.value % ScoveragePluginConfig.name).cross(CrossVersion.full) ) - else + } else Nil } ) private lazy val scalacSettings = Seq( - scalacOptions in(Compile, compile) ++= { + Compile / compile / scalacOptions ++= { val updateReport = update.value if (coverageEnabled.value) { val scoverageDeps: Seq[File] = updateReport matching configurationFilter(ScoveragePluginConfig.name) @@ -113,14 +112,14 @@ object ScoverageSbtPlugin extends AutoPlugin { case Some(cov) => writeReports( target, - (sourceDirectories in Compile).value, + (Compile / sourceDirectories).value, cov, coverageOutputCobertura.value, coverageOutputXML.value, coverageOutputHTML.value, coverageOutputDebug.value, coverageOutputTeamCity.value, - sourceEncoding((scalacOptions in (Compile)).value), + sourceEncoding((Compile / scalacOptions).value), log) checkCoverage(cov, log, coverageMinimum.value, coverageFailOnMinimum.value) @@ -144,7 +143,7 @@ object ScoverageSbtPlugin extends AutoPlugin { coverageOutputHTML.value, coverageOutputDebug.value, coverageOutputTeamCity.value, - sourceEncoding((scalacOptions in (Compile)).value), + sourceEncoding((Compile / scalacOptions).value), log) val cfmt = cov.statementCoverageFormatted log.info(s"Aggregation complete. Coverage was [$cfmt]") diff --git a/src/sbt-test/scoverage/aggregate-only/build.sbt b/src/sbt-test/scoverage/aggregate-only/build.sbt index 9036ce72..3ca537e3 100644 --- a/src/sbt-test/scoverage/aggregate-only/build.sbt +++ b/src/sbt-test/scoverage/aggregate-only/build.sbt @@ -6,7 +6,7 @@ lazy val commonSettings = Seq( organization := "org.scoverage", version := "0.1.0", - scalaVersion := "2.12.8" + scalaVersion := "2.12.13" ) lazy val specs2Lib = "org.specs2" %% "specs2" % "2.5" % "test" @@ -34,7 +34,7 @@ lazy val root = (project in file(".")) partB ) -resolvers in ThisBuild ++= { - if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots")) +ThisBuild / resolvers ++= { + if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots")) else Seq.empty } diff --git a/src/sbt-test/scoverage/aggregate-only/project/plugins.sbt b/src/sbt-test/scoverage/aggregate-only/project/plugins.sbt index 8f2837b3..475b8886 100644 --- a/src/sbt-test/scoverage/aggregate-only/project/plugins.sbt +++ b/src/sbt-test/scoverage/aggregate-only/project/plugins.sbt @@ -4,7 +4,7 @@ val pluginVersion = sys.props.getOrElse( """|The system property 'plugin.version' is not defined. |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) -addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) +addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion withCrossVersion(CrossVersion.full)) resolvers ++= { if (pluginVersion.endsWith("-SNAPSHOT")) diff --git a/src/sbt-test/scoverage/aggregate/build.sbt b/src/sbt-test/scoverage/aggregate/build.sbt index 9036ce72..3ca537e3 100644 --- a/src/sbt-test/scoverage/aggregate/build.sbt +++ b/src/sbt-test/scoverage/aggregate/build.sbt @@ -6,7 +6,7 @@ lazy val commonSettings = Seq( organization := "org.scoverage", version := "0.1.0", - scalaVersion := "2.12.8" + scalaVersion := "2.12.13" ) lazy val specs2Lib = "org.specs2" %% "specs2" % "2.5" % "test" @@ -34,7 +34,7 @@ lazy val root = (project in file(".")) partB ) -resolvers in ThisBuild ++= { - if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots")) +ThisBuild / resolvers ++= { + if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots")) else Seq.empty } diff --git a/src/sbt-test/scoverage/aggregate/project/plugins.sbt b/src/sbt-test/scoverage/aggregate/project/plugins.sbt index 8f2837b3..475b8886 100644 --- a/src/sbt-test/scoverage/aggregate/project/plugins.sbt +++ b/src/sbt-test/scoverage/aggregate/project/plugins.sbt @@ -4,7 +4,7 @@ val pluginVersion = sys.props.getOrElse( """|The system property 'plugin.version' is not defined. |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) -addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) +addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion withCrossVersion(CrossVersion.full)) resolvers ++= { if (pluginVersion.endsWith("-SNAPSHOT")) diff --git a/src/sbt-test/scoverage/bad-coverage/build.sbt b/src/sbt-test/scoverage/bad-coverage/build.sbt index c786340d..30698311 100644 --- a/src/sbt-test/scoverage/bad-coverage/build.sbt +++ b/src/sbt-test/scoverage/bad-coverage/build.sbt @@ -1,6 +1,6 @@ version := "0.1" -scalaVersion := "2.12.8" +scalaVersion := "2.12.13" libraryDependencies += "org.specs2" %% "specs2" % "2.5" % "test" @@ -9,6 +9,6 @@ coverageMinimum := 80 coverageFailOnMinimum := true resolvers ++= { - if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots")) + if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots")) else Seq.empty } diff --git a/src/sbt-test/scoverage/bad-coverage/project/plugins.sbt b/src/sbt-test/scoverage/bad-coverage/project/plugins.sbt index 8f2837b3..475b8886 100644 --- a/src/sbt-test/scoverage/bad-coverage/project/plugins.sbt +++ b/src/sbt-test/scoverage/bad-coverage/project/plugins.sbt @@ -4,7 +4,7 @@ val pluginVersion = sys.props.getOrElse( """|The system property 'plugin.version' is not defined. |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) -addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) +addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion withCrossVersion(CrossVersion.full)) resolvers ++= { if (pluginVersion.endsWith("-SNAPSHOT")) diff --git a/src/sbt-test/scoverage/coverage-off/build.sbt b/src/sbt-test/scoverage/coverage-off/build.sbt index c786340d..30698311 100644 --- a/src/sbt-test/scoverage/coverage-off/build.sbt +++ b/src/sbt-test/scoverage/coverage-off/build.sbt @@ -1,6 +1,6 @@ version := "0.1" -scalaVersion := "2.12.8" +scalaVersion := "2.12.13" libraryDependencies += "org.specs2" %% "specs2" % "2.5" % "test" @@ -9,6 +9,6 @@ coverageMinimum := 80 coverageFailOnMinimum := true resolvers ++= { - if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots")) + if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots")) else Seq.empty } diff --git a/src/sbt-test/scoverage/coverage-off/project/plugins.sbt b/src/sbt-test/scoverage/coverage-off/project/plugins.sbt index 8f2837b3..475b8886 100644 --- a/src/sbt-test/scoverage/coverage-off/project/plugins.sbt +++ b/src/sbt-test/scoverage/coverage-off/project/plugins.sbt @@ -4,7 +4,7 @@ val pluginVersion = sys.props.getOrElse( """|The system property 'plugin.version' is not defined. |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) -addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) +addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion withCrossVersion(CrossVersion.full)) resolvers ++= { if (pluginVersion.endsWith("-SNAPSHOT")) diff --git a/src/sbt-test/scoverage/good-coverage/build.sbt b/src/sbt-test/scoverage/good-coverage/build.sbt index c786340d..30698311 100644 --- a/src/sbt-test/scoverage/good-coverage/build.sbt +++ b/src/sbt-test/scoverage/good-coverage/build.sbt @@ -1,6 +1,6 @@ version := "0.1" -scalaVersion := "2.12.8" +scalaVersion := "2.12.13" libraryDependencies += "org.specs2" %% "specs2" % "2.5" % "test" @@ -9,6 +9,6 @@ coverageMinimum := 80 coverageFailOnMinimum := true resolvers ++= { - if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots")) + if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots")) else Seq.empty } diff --git a/src/sbt-test/scoverage/preserve-set/build.sbt b/src/sbt-test/scoverage/preserve-set/build.sbt index 8469864d..f9b0b448 100644 --- a/src/sbt-test/scoverage/preserve-set/build.sbt +++ b/src/sbt-test/scoverage/preserve-set/build.sbt @@ -2,9 +2,9 @@ import sbt.complete.DefaultParsers._ version := "0.1" -scalaVersion := "2.12.8" +scalaVersion := "2.12.13" -crossScalaVersions := Seq("2.10.6", "2.12.8") +crossScalaVersions := Seq("2.12.13") libraryDependencies += "org.specs2" %% "specs2" % "2.5" % "test" @@ -24,14 +24,14 @@ checkScoverageEnabled := { resolvers ++= { - if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots")) + if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots")) else Seq.empty } // We force coverage to be always disabled for 2.10. This is not an uncommon real world scenario coverageEnabled := { CrossVersion.partialVersion(scalaVersion.value) match { - case Some((2, 10)) => false +// case Some((2, 10)) => false case _ => coverageEnabled.value } } diff --git a/src/sbt-test/scoverage/preserve-set/test b/src/sbt-test/scoverage/preserve-set/test index 2429a4dd..349f1853 100644 --- a/src/sbt-test/scoverage/preserve-set/test +++ b/src/sbt-test/scoverage/preserve-set/test @@ -1,19 +1,8 @@ # check scalaVersion setting -> checkScalaVersion "2.12.8" +> checkScalaVersion "2.12.13" > checkScoverageEnabled "false" > coverage > checkScoverageEnabled "true" > coverageOff -> checkScalaVersion "2.12.8" -> checkScoverageEnabled "false" -# changs scala version -> ++2.10.6 -> checkScalaVersion "2.10.6" -> checkScoverageEnabled "false" -> coverage -> checkScalaVersion "2.10.6" -# We want coverage to be false, as we set it in the build.sbt -> checkScoverageEnabled "false" -> coverageOff -> checkScalaVersion "2.10.6" -> checkScoverageEnabled "false" +> checkScalaVersion "2.12.13" +> checkScoverageEnabled "false" \ No newline at end of file diff --git a/src/sbt-test/scoverage/scalac-plugin-version/build.sbt b/src/sbt-test/scoverage/scalac-plugin-version/build.sbt index 1d927f49..f5e663f7 100644 --- a/src/sbt-test/scoverage/scalac-plugin-version/build.sbt +++ b/src/sbt-test/scoverage/scalac-plugin-version/build.sbt @@ -4,13 +4,11 @@ lazy val root = (project in file(".")).settings( TaskKey[Unit]("check") := { assert( - libraryDependencies.value - .filter(module => - module.organization == "org.scoverage" && module.revision == "1.3.0") - .size == 2) + libraryDependencies.value.count(module => + module.organization == "org.scoverage" && module.revision == "1.3.0") == 2) } resolvers ++= { - if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots")) + if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots")) else Seq.empty } diff --git a/src/sbt-test/scoverage/scalajs/build.sbt b/src/sbt-test/scoverage/scalajs/build.sbt index 4f26c791..c1358702 100644 --- a/src/sbt-test/scoverage/scalajs/build.sbt +++ b/src/sbt-test/scoverage/scalajs/build.sbt @@ -6,16 +6,16 @@ lazy val root = (project in file(".")).aggregate(crossJS, crossJVM) lazy val cross = CrossProject("sjstest", file("sjstest"))(JVMPlatform, JSPlatform) .crossType(CrossType.Full) .settings( - scalaVersion := "2.12.8", + scalaVersion := "2.12.13", libraryDependencies ++= Seq( - "org.scalatest" %%% "scalatest" % "3.0.0" % "test" + "org.scalatest" %% "scalatest" % "3.2.8" % "test" cross(CrossVersion.binary) ) ) lazy val crossJS = cross.js lazy val crossJVM = cross.jvm -resolvers in ThisBuild ++= { - if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots")) +ThisBuild / resolvers ++= { + if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots")) else Seq.empty } diff --git a/src/sbt-test/scoverage/scalajs/project/plugins.sbt b/src/sbt-test/scoverage/scalajs/project/plugins.sbt index 0b681ffe..6d94fb59 100644 --- a/src/sbt-test/scoverage/scalajs/project/plugins.sbt +++ b/src/sbt-test/scoverage/scalajs/project/plugins.sbt @@ -13,6 +13,6 @@ resolvers ++= { Seq.empty } -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.27") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.0") -addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.0") +addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") diff --git a/src/sbt-test/scoverage/scalajs/sjstest/js/src/test/scala/JsTest.scala b/src/sbt-test/scoverage/scalajs/sjstest/js/src/test/scala/JsTest.scala index 133c1a36..d11e4236 100644 --- a/src/sbt-test/scoverage/scalajs/sjstest/js/src/test/scala/JsTest.scala +++ b/src/sbt-test/scoverage/scalajs/sjstest/js/src/test/scala/JsTest.scala @@ -1,6 +1,7 @@ -import org.scalatest.{FlatSpec, Matchers} +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers -class JsTest extends FlatSpec with Matchers { +class JsTest extends AnyFlatSpec with Matchers { "JS UnderTest" should "work on JS" in { UnderTest.jsMethod shouldBe "js" diff --git a/src/sbt-test/scoverage/scalajs/sjstest/jvm/src/test/scala/JvmTest.scala b/src/sbt-test/scoverage/scalajs/sjstest/jvm/src/test/scala/JvmTest.scala index 80739a94..be2bc649 100644 --- a/src/sbt-test/scoverage/scalajs/sjstest/jvm/src/test/scala/JvmTest.scala +++ b/src/sbt-test/scoverage/scalajs/sjstest/jvm/src/test/scala/JvmTest.scala @@ -1,6 +1,7 @@ -import org.scalatest.{FlatSpec, Matchers} +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers -class JvmTest extends FlatSpec with Matchers { +class JvmTest extends AnyFlatSpec with Matchers { "JVM UnderTest" should "work on JVM" in { UnderTest.jvmMethod shouldBe "jvm" diff --git a/src/sbt-test/scoverage/scalajs/sjstest/shared/src/test/scala/SharedTest.scala b/src/sbt-test/scoverage/scalajs/sjstest/shared/src/test/scala/SharedTest.scala index fecebac8..8336af72 100644 --- a/src/sbt-test/scoverage/scalajs/sjstest/shared/src/test/scala/SharedTest.scala +++ b/src/sbt-test/scoverage/scalajs/sjstest/shared/src/test/scala/SharedTest.scala @@ -1,6 +1,7 @@ -import org.scalatest.{FlatSpec, Matchers} +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers -class SharedTest extends FlatSpec with Matchers { +class SharedTest extends AnyFlatSpec with Matchers { "Shared UnderTest" should "return where it works" in { UnderTest.onJsAndJvm shouldBe "js and jvm" diff --git a/version.sbt b/version.sbt index e5cd55e1..be9ef7d7 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -version in ThisBuild := "1.6.2-SNAPSHOT" +version in ThisBuild := "1.6.2-SNAPSHOT" \ No newline at end of file From 5d298ed9fc032025f2023bf31fe869c0b7361001 Mon Sep 17 00:00:00 2001 From: Dominik Zeiger Date: Wed, 28 Apr 2021 10:57:35 +0200 Subject: [PATCH 07/49] only use major sjs version, changes as per review comments --- .github/workflows/pr.yml | 10 +--------- README.md | 4 ++-- build.sbt | 3 +-- src/main/scala/scoverage/ScoverageSbtPlugin.scala | 2 +- .../scoverage/aggregate-only/project/plugins.sbt | 2 +- src/sbt-test/scoverage/aggregate/project/plugins.sbt | 2 +- .../scoverage/bad-coverage/project/plugins.sbt | 2 +- .../scoverage/coverage-off/project/plugins.sbt | 2 +- src/sbt-test/scoverage/preserve-set/build.sbt | 2 -- src/sbt-test/scoverage/scalajs/build.sbt | 2 +- 10 files changed, 10 insertions(+), 21 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 40deb99c..400a733b 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -15,15 +15,7 @@ jobs: java: [ '11' ] scala: [ { version: '2.12.13' }, - { version: '2.12.12' }, - { version: '2.12.11' }, - { version: '2.12.10' }, - { version: '2.13.5' }, - { version: '2.13.4' }, - { version: '2.13.3' }, - { version: '2.13.2' }, - { version: '2.13.1' }, - { version: '2.13.0' } + { version: '2.12.10' } ] steps: - name: checkout the repo diff --git a/README.md b/README.md index 83218ebc..edd70463 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ discussion on scoverage. Make sure your SBT version in project/build.properties: ``` -sbt.version = 1.5.1 +sbt.version = 1.2.8 ``` Add the plugin in project/plugins.sbt: @@ -52,7 +52,7 @@ Sample project with scoverage in both sbt and maven - [the scoverage samples pro ## Notes on upgrading to version 1.6.x * ´coverageCleanSubprojectFiles´ key has been removed -* scala version 2.12+ is required as a minimum +* scala version 2.12+ is required as a minimum (due to scoverage suppport) ## Notes on upgrading to version 1.6.0 diff --git a/build.sbt b/build.sbt index 576a2deb..0180eaf2 100644 --- a/build.sbt +++ b/build.sbt @@ -9,11 +9,10 @@ releaseProcess := Seq[ReleaseStep]( inquireVersions, runClean, releaseStepCommandAndRemaining("^ test"), -// releaseStepCommandAndRemaining("^ scripted"), setReleaseVersion, commitReleaseVersion, tagRelease, - releaseStepCommandAndRemaining("^ publish"), + releaseStepCommandAndRemaining("publishSigned"), setNextVersion, commitNextVersion, pushChanges diff --git a/src/main/scala/scoverage/ScoverageSbtPlugin.scala b/src/main/scala/scoverage/ScoverageSbtPlugin.scala index f4b55635..075a4a8a 100644 --- a/src/main/scala/scoverage/ScoverageSbtPlugin.scala +++ b/src/main/scala/scoverage/ScoverageSbtPlugin.scala @@ -96,7 +96,7 @@ object ScoverageSbtPlugin extends AutoPlugin { private def optionalScalaJsSuffix(deps: Seq[ModuleID]): String = { val sjsClassifier = deps.collectFirst { case moduleId if moduleId.organization == "org.scala-js" && moduleId.name == "scalajs-library" => moduleId.revision - }.map(_.take(3)).map(sjsVersion => "_sjs" + sjsVersion) + }.map(_.take(1)).map(sjsVersion => "_sjs" + sjsVersion) sjsClassifier getOrElse "" } diff --git a/src/sbt-test/scoverage/aggregate-only/project/plugins.sbt b/src/sbt-test/scoverage/aggregate-only/project/plugins.sbt index 475b8886..8f2837b3 100644 --- a/src/sbt-test/scoverage/aggregate-only/project/plugins.sbt +++ b/src/sbt-test/scoverage/aggregate-only/project/plugins.sbt @@ -4,7 +4,7 @@ val pluginVersion = sys.props.getOrElse( """|The system property 'plugin.version' is not defined. |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) -addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion withCrossVersion(CrossVersion.full)) +addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) resolvers ++= { if (pluginVersion.endsWith("-SNAPSHOT")) diff --git a/src/sbt-test/scoverage/aggregate/project/plugins.sbt b/src/sbt-test/scoverage/aggregate/project/plugins.sbt index 475b8886..8f2837b3 100644 --- a/src/sbt-test/scoverage/aggregate/project/plugins.sbt +++ b/src/sbt-test/scoverage/aggregate/project/plugins.sbt @@ -4,7 +4,7 @@ val pluginVersion = sys.props.getOrElse( """|The system property 'plugin.version' is not defined. |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) -addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion withCrossVersion(CrossVersion.full)) +addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) resolvers ++= { if (pluginVersion.endsWith("-SNAPSHOT")) diff --git a/src/sbt-test/scoverage/bad-coverage/project/plugins.sbt b/src/sbt-test/scoverage/bad-coverage/project/plugins.sbt index 475b8886..8f2837b3 100644 --- a/src/sbt-test/scoverage/bad-coverage/project/plugins.sbt +++ b/src/sbt-test/scoverage/bad-coverage/project/plugins.sbt @@ -4,7 +4,7 @@ val pluginVersion = sys.props.getOrElse( """|The system property 'plugin.version' is not defined. |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) -addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion withCrossVersion(CrossVersion.full)) +addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) resolvers ++= { if (pluginVersion.endsWith("-SNAPSHOT")) diff --git a/src/sbt-test/scoverage/coverage-off/project/plugins.sbt b/src/sbt-test/scoverage/coverage-off/project/plugins.sbt index 475b8886..8f2837b3 100644 --- a/src/sbt-test/scoverage/coverage-off/project/plugins.sbt +++ b/src/sbt-test/scoverage/coverage-off/project/plugins.sbt @@ -4,7 +4,7 @@ val pluginVersion = sys.props.getOrElse( """|The system property 'plugin.version' is not defined. |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) -addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion withCrossVersion(CrossVersion.full)) +addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) resolvers ++= { if (pluginVersion.endsWith("-SNAPSHOT")) diff --git a/src/sbt-test/scoverage/preserve-set/build.sbt b/src/sbt-test/scoverage/preserve-set/build.sbt index f9b0b448..35e9bd25 100644 --- a/src/sbt-test/scoverage/preserve-set/build.sbt +++ b/src/sbt-test/scoverage/preserve-set/build.sbt @@ -28,10 +28,8 @@ resolvers ++= { else Seq.empty } -// We force coverage to be always disabled for 2.10. This is not an uncommon real world scenario coverageEnabled := { CrossVersion.partialVersion(scalaVersion.value) match { -// case Some((2, 10)) => false case _ => coverageEnabled.value } } diff --git a/src/sbt-test/scoverage/scalajs/build.sbt b/src/sbt-test/scoverage/scalajs/build.sbt index c1358702..4b1074b5 100644 --- a/src/sbt-test/scoverage/scalajs/build.sbt +++ b/src/sbt-test/scoverage/scalajs/build.sbt @@ -8,7 +8,7 @@ lazy val cross = CrossProject("sjstest", file("sjstest"))(JVMPlatform, JSPlatfor .settings( scalaVersion := "2.12.13", libraryDependencies ++= Seq( - "org.scalatest" %% "scalatest" % "3.2.8" % "test" cross(CrossVersion.binary) + "org.scalatest" %% "scalatest" % "3.2.8" % "test" ) ) From eb9fba934b606b351e70ed9b5d5b6e3319f53b71 Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Wed, 28 Apr 2021 13:18:31 +0200 Subject: [PATCH 08/49] Update to newly released 1.4.3 --- build.sbt | 2 +- src/main/scala/scoverage/ScoverageSbtPlugin.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 0180eaf2..bbc413d0 100644 --- a/build.sbt +++ b/build.sbt @@ -24,7 +24,7 @@ lazy val root = Project("sbt-scoverage", file(".")) libraryDependencies ++= Seq( "org.scala-lang" % "scala-compiler" % scalaVersion.value % Compile ), - libraryDependencies += "org.scoverage" %% "scalac-scoverage-plugin" % "1.4.3-SNAPSHOT" cross(CrossVersion.full), + libraryDependencies += "org.scoverage" %% "scalac-scoverage-plugin" % "1.4.3" cross(CrossVersion.full), scalaVersion := "2.12.13", publishMavenStyle := true, publishConfiguration := publishConfiguration.value.withOverwrite(true), diff --git a/src/main/scala/scoverage/ScoverageSbtPlugin.scala b/src/main/scala/scoverage/ScoverageSbtPlugin.scala index 075a4a8a..f853bc40 100644 --- a/src/main/scala/scoverage/ScoverageSbtPlugin.scala +++ b/src/main/scala/scoverage/ScoverageSbtPlugin.scala @@ -11,7 +11,7 @@ object ScoverageSbtPlugin extends AutoPlugin { val ScalacRuntimeArtifact = "scalac-scoverage-runtime" val ScalacPluginArtifact = "scalac-scoverage-plugin" // this should match the version defined in build.sbt - val DefaultScoverageVersion = "1.4.3-SNAPSHOT" + val DefaultScoverageVersion = "1.4.3" val autoImport = ScoverageKeys lazy val ScoveragePluginConfig = config("scoveragePlugin").hide From 80708de6b59fc412bb6c7480a27536f991acbf1e Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Wed, 28 Apr 2021 13:37:42 +0200 Subject: [PATCH 09/49] Remove cross from release We no longer cross publishing for sbt, and therefore don't need to do the cross test --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index bbc413d0..8188ad12 100644 --- a/build.sbt +++ b/build.sbt @@ -8,7 +8,7 @@ releaseProcess := Seq[ReleaseStep]( checkSnapshotDependencies, inquireVersions, runClean, - releaseStepCommandAndRemaining("^ test"), + releaseStepCommandAndRemaining("test"), setReleaseVersion, commitReleaseVersion, tagRelease, From f7c409ef76b31411096d453c4578272a0c9296bb Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Wed, 28 Apr 2021 13:50:43 +0200 Subject: [PATCH 10/49] Bump pgp plugin and remove extra matrix. Running that extra matrix doesn't add anything to CI. I plan on fully redoing the CI, but want to get this just released first --- .github/workflows/pr.yml | 3 +-- project/plugins.sbt | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 400a733b..d41348e4 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -14,8 +14,7 @@ jobs: matrix: java: [ '11' ] scala: [ - { version: '2.12.13' }, - { version: '2.12.10' } + { version: '2.12.13' } ] steps: - name: checkout the repo diff --git a/project/plugins.sbt b/project/plugins.sbt index 2b6a8715..5263b3bd 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,6 +1,6 @@ libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0") +addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1") addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.1") From 3e5cdc0e30bc0e7279caabde5fa1a003a1b3607a Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Wed, 28 Apr 2021 13:59:54 +0200 Subject: [PATCH 11/49] Setting version to 1.7.0 --- version.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.sbt b/version.sbt index be9ef7d7..89069b74 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -version in ThisBuild := "1.6.2-SNAPSHOT" \ No newline at end of file +version in ThisBuild := "1.7.0" From 78caf76f23c6dab1167efdc650b9b979499081d9 Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Wed, 28 Apr 2021 14:00:54 +0200 Subject: [PATCH 12/49] Setting version to 1.7.1-SNAPSHOT --- version.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.sbt b/version.sbt index 89069b74..7dc21d88 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -version in ThisBuild := "1.7.0" +version in ThisBuild := "1.7.1-SNAPSHOT" From 8f216f5cc3d8197f9867dd7ce4130b154492d30b Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Thu, 29 Apr 2021 20:59:26 +0200 Subject: [PATCH 13/49] Fix shields --- README.md | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index edd70463..a368ce9a 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,21 @@ -sbt-scoverage -======== +# sbt-scoverage -sbt-scoverage is a plugin for SBT that integrates the scoverage code coverage library. Find out more about [scoverage](https://github.com/scoverage/scalac-scoverage-plugin). - -Join the [scoverage](http://groups.google.com/group/scala-code-coverage-tool) -google group for help, bug reports, feature requests, and general -discussion on scoverage. - -[![Build Status](https://travis-ci.org/scoverage/sbt-scoverage.png?branch=master)](https://travis-ci.org/scoverage/sbt-scoverage) +[![Gitter](https://img.shields.io/gitter/room/scoverage/scoverage.svg)](https://gitter.im/scoverage/scoverage) +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.scoverage/sbt-scoverage/badge.svg?kill_cache=1)](https://search.maven.org/artifact/org.scoverage/sbt-scoverage/) [![License](http://img.shields.io/:license-Apache%202-red.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt) -[](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22sbt-scoverage%22) + +sbt-scoverage is a plugin for sbt that integrates the scoverage code coverage +library. Find out more about +[scoverage](https://github.com/scoverage/scalac-scoverage-plugin). ## How to use -Make sure your SBT version in project/build.properties: -``` +Make sure your sbt version in project/build.properties: +```scala sbt.version = 1.2.8 ``` -Add the plugin in project/plugins.sbt: +Add the plugin in `project/plugins.sbt`: ```scala addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.2") ``` @@ -33,7 +30,7 @@ $ sbt clean coverage it:test ``` To enable coverage directly in your build, use: -``` +```scala coverageEnabled := true ``` From c929d3e33c1ee808a148db86301b6aec7782b858 Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Thu, 29 Apr 2021 21:31:37 +0200 Subject: [PATCH 14/49] Correct report location in readme. Closes #176 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a368ce9a..d1ebe461 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ sbt.version = 1.2.8 Add the plugin in `project/plugins.sbt`: ```scala -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.2") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.7.0") ``` Run the tests with enabled coverage: @@ -39,7 +39,7 @@ To generate the coverage reports run $ sbt coverageReport ``` -Coverage reports will be in `target/scoverage-report`. There are HTML and XML reports. The XML is useful if you need to programatically use the results, or if you're writing a tool. +Coverage reports will be in `target/scala-/scoverage-report`. There are HTML and XML reports. The XML is useful if you need to programatically use the results, or if you're writing a tool. If you're running the coverage reports from within an sbt console session (as opposed to one command per sbt launch), then the `coverage` command is sticky. To From 3c41a98a439e66c3389de41bbd9d6403d22d2722 Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Sat, 1 May 2021 17:39:00 +0200 Subject: [PATCH 15/49] Update CI and release strategy --- .github/workflows/{pr.yml => ci.yml} | 9 +- .github/workflows/release.yml | 20 ++++ build.sbt | 95 ++++++++----------- project/plugins.sbt | 7 +- .../scala/scoverage/ScoverageSbtPlugin.scala | 3 +- version.sbt | 1 - 6 files changed, 67 insertions(+), 68 deletions(-) rename .github/workflows/{pr.yml => ci.yml} (92%) create mode 100644 .github/workflows/release.yml delete mode 100644 version.sbt diff --git a/.github/workflows/pr.yml b/.github/workflows/ci.yml similarity index 92% rename from .github/workflows/pr.yml rename to .github/workflows/ci.yml index d41348e4..036fbc59 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/ci.yml @@ -1,11 +1,12 @@ -name: pr +name: CI on: - pull_request: + push: paths-ignore: - - 'doc/**' - - 'docs/**' - '*.md' + branches: + - master + pull_request: jobs: scala: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..90ec276b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,20 @@ +name: Release +on: + push: + branches: + - master + tags: ["*"] +jobs: + publish: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2.3.4 + with: + fetch-depth: 0 + - uses: olafurpg/setup-scala@v10 + - run: sbt ci-release + env: + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} diff --git a/build.sbt b/build.sbt index 8188ad12..40e60d80 100644 --- a/build.sbt +++ b/build.sbt @@ -1,21 +1,37 @@ name := "sbt-scoverage" -organization := "org.scoverage" import sbt.ScriptedPlugin.autoImport.scriptedLaunchOpts -import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._ -releaseProcess := Seq[ReleaseStep]( - checkSnapshotDependencies, - inquireVersions, - runClean, - releaseStepCommandAndRemaining("test"), - setReleaseVersion, - commitReleaseVersion, - tagRelease, - releaseStepCommandAndRemaining("publishSigned"), - setNextVersion, - commitNextVersion, - pushChanges +def localSnapshotVersion = "1.7.1-SNAPSHOT" +def isCI = System.getenv("CI") != null + +inThisBuild( + List( + organization := "org.scoverage", + homepage := Some(url("http://scoverage.org/")), + developers := List( + Developer( + "sksamuel", + "Stephen Samuel", + "sam@sksamuel.com", + url("https://github.com/sksamuel") + ), + Developer( + "gslowikowski", + "Grzegorz Slowikowski", + "gslowikowski@gmail.com", + url("https://github.com/gslowikowski") + ) + ), + licenses := Seq( + "Apache-2.0" -> url("http://www.apache.org/license/LICENSE-2.0") + ), + scalaVersion := "2.12.13", + version ~= { dynVer => + if (isCI) dynVer + else localSnapshotVersion // only for local publishing + } + ) ) lazy val root = Project("sbt-scoverage", file(".")) @@ -24,55 +40,22 @@ lazy val root = Project("sbt-scoverage", file(".")) libraryDependencies ++= Seq( "org.scala-lang" % "scala-compiler" % scalaVersion.value % Compile ), - libraryDependencies += "org.scoverage" %% "scalac-scoverage-plugin" % "1.4.3" cross(CrossVersion.full), - scalaVersion := "2.12.13", - publishMavenStyle := true, - publishConfiguration := publishConfiguration.value.withOverwrite(true), - publishLocalConfiguration := publishLocalConfiguration.value.withOverwrite(true), - releasePublishArtifactsAction := PgpKeys.publishSigned.value, + libraryDependencies += "org.scoverage" %% "scalac-scoverage-plugin" % "1.4.3" cross (CrossVersion.full), Test / fork := false, Test / publishArtifact := false, Test / parallelExecution := false, - scalacOptions := Seq("-unchecked", "-deprecation", "-feature", "-encoding", "utf8"), - publishTo := { - if (isSnapshot.value) - Some("snapshots" at "https://oss.sonatype.org/content/repositories/snapshots") - else - Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2") - }, + scalacOptions := Seq( + "-unchecked", + "-deprecation", + "-feature", + "-encoding", + "utf8" + ), resolvers ++= { if (isSnapshot.value) Seq(Resolver.sonatypeRepo("snapshots")) else Nil }, scriptedLaunchOpts ++= Seq( "-Xmx1024M", "-Dplugin.version=" + version.value - ), - pomExtra := { - https://github.com/scoverage/sbt-scoverage - - - Apache 2 - http://www.apache.org/licenses/LICENSE-2.0 - repo - - - - git@github.com:scoverage/sbt-scoverage.git - scm:git@github.com:scoverage/sbt-scoverage.git - - - - sksamuel - sksamuel - http://github.com/sksamuel - - - gslowikowski - Grzegorz Slowikowski - http://github.com/gslowikowski - - - } + ) ) - -scalariformAutoformat := false diff --git a/project/plugins.sbt b/project/plugins.sbt index 5263b3bd..4c61369e 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,7 +1,2 @@ libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value - -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1") - -addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.1") - -addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13") +addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7") diff --git a/src/main/scala/scoverage/ScoverageSbtPlugin.scala b/src/main/scala/scoverage/ScoverageSbtPlugin.scala index f853bc40..e06c103e 100644 --- a/src/main/scala/scoverage/ScoverageSbtPlugin.scala +++ b/src/main/scala/scoverage/ScoverageSbtPlugin.scala @@ -4,6 +4,7 @@ import sbt.Keys._ import sbt._ import sbt.plugins.JvmPlugin import scoverage.report.{CoberturaXmlWriter, CoverageAggregator, ScoverageHtmlWriter, ScoverageXmlWriter} +import java.time.Instant object ScoverageSbtPlugin extends AutoPlugin { @@ -215,7 +216,7 @@ object ScoverageSbtPlugin extends AutoPlugin { // Create the coverage report for teamcity (HTML files) if (createCoverageZip) - IO.zip(Path.allSubpaths(reportDir), crossTarget / "coverage.zip") + IO.zip(Path.allSubpaths(reportDir), crossTarget / "coverage.zip", Some(Instant.now().toEpochMilli())) } private def loadCoverage(crossTarget: File, log: Logger): Option[Coverage] = { diff --git a/version.sbt b/version.sbt deleted file mode 100644 index 7dc21d88..00000000 --- a/version.sbt +++ /dev/null @@ -1 +0,0 @@ -version in ThisBuild := "1.7.1-SNAPSHOT" From c2a34da87f40c1a452cd59e569506a93d8984b3a Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Sat, 1 May 2021 17:46:04 +0200 Subject: [PATCH 16/49] Remove no longer needed travis file --- .travis.yml | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f9cd7f16..00000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: scala - -script: sbt ^^$TRAVIS_SBT_VERSION scripted - -matrix: - include: - - env: TRAVIS_SBT_VERSION="0.13.18" - - env: TRAVIS_SBT_VERSION="1.2.8" - -before_cache: - - find $HOME/.sbt -name "*.lock" | xargs rm - - find $HOME/.ivy2 -name "ivydata-*.properties" | xargs rm - -cache: - directories: - - $HOME/.ivy2/cache - - $HOME/.sbt/boot - -before_script: - - sudo chmod +x /usr/local/bin/sbt From abd65157a2c44ab5873dffd1fdecb31347a1ea3a Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Sun, 2 May 2021 10:34:54 +0200 Subject: [PATCH 17/49] Update to scoverage 1.4.4. Also add in buildInfo to re-use version in build --- build.sbt | 8 ++++--- project/plugins.sbt | 1 + .../scala/scoverage/ScoverageSbtPlugin.scala | 22 +++++++++---------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/build.sbt b/build.sbt index 40e60d80..90efc871 100644 --- a/build.sbt +++ b/build.sbt @@ -4,6 +4,7 @@ import sbt.ScriptedPlugin.autoImport.scriptedLaunchOpts def localSnapshotVersion = "1.7.1-SNAPSHOT" def isCI = System.getenv("CI") != null +def scoverageVersion = "1.4.4" inThisBuild( List( @@ -35,12 +36,13 @@ inThisBuild( ) lazy val root = Project("sbt-scoverage", file(".")) - .enablePlugins(SbtPlugin) + .enablePlugins(SbtPlugin, BuildInfoPlugin) .settings( libraryDependencies ++= Seq( - "org.scala-lang" % "scala-compiler" % scalaVersion.value % Compile + "org.scala-lang" % "scala-compiler" % scalaVersion.value % Compile, + "org.scoverage" %% "scalac-scoverage-plugin" % scoverageVersion cross (CrossVersion.full), ), - libraryDependencies += "org.scoverage" %% "scalac-scoverage-plugin" % "1.4.3" cross (CrossVersion.full), + buildInfoKeys := Seq[BuildInfoKey]("scoverageVersion" -> scoverageVersion), Test / fork := false, Test / publishArtifact := false, Test / parallelExecution := false, diff --git a/project/plugins.sbt b/project/plugins.sbt index 4c61369e..f7bfdc77 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,2 +1,3 @@ libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") diff --git a/src/main/scala/scoverage/ScoverageSbtPlugin.scala b/src/main/scala/scoverage/ScoverageSbtPlugin.scala index e06c103e..099c3d72 100644 --- a/src/main/scala/scoverage/ScoverageSbtPlugin.scala +++ b/src/main/scala/scoverage/ScoverageSbtPlugin.scala @@ -5,14 +5,14 @@ import sbt._ import sbt.plugins.JvmPlugin import scoverage.report.{CoberturaXmlWriter, CoverageAggregator, ScoverageHtmlWriter, ScoverageXmlWriter} import java.time.Instant +import buildinfo.BuildInfo object ScoverageSbtPlugin extends AutoPlugin { - val OrgScoverage = "org.scoverage" - val ScalacRuntimeArtifact = "scalac-scoverage-runtime" - val ScalacPluginArtifact = "scalac-scoverage-plugin" - // this should match the version defined in build.sbt - val DefaultScoverageVersion = "1.4.3" + val orgScoverage = "org.scoverage" + val scalacRuntimeArtifact = "scalac-scoverage-runtime" + val scalacPluginArtifact = "scalac-scoverage-plugin" + val defaultScoverageVersion = BuildInfo.scoverageVersion val autoImport = ScoverageKeys lazy val ScoveragePluginConfig = config("scoveragePlugin").hide @@ -36,7 +36,7 @@ object ScoverageSbtPlugin extends AutoPlugin { coverageOutputCobertura := true, coverageOutputDebug := false, coverageOutputTeamCity := false, - coverageScalacPluginVersion := DefaultScoverageVersion + coverageScalacPluginVersion := defaultScoverageVersion ) override def buildSettings: Seq[Setting[_]] = super.buildSettings ++ @@ -57,9 +57,9 @@ object ScoverageSbtPlugin extends AutoPlugin { Seq( // We only add for "compile" because of macros. This setting could be optimed to just "test" if the handling // of macro coverage was improved. - (OrgScoverage %% (scalacRuntime(libraryDependencies.value)) % coverageScalacPluginVersion.value).cross(CrossVersion.full), + (orgScoverage %% (scalacRuntime(libraryDependencies.value)) % coverageScalacPluginVersion.value).cross(CrossVersion.full), // We don't want to instrument the test code itself, nor add to a pom when published with coverage enabled. - (OrgScoverage %% ScalacPluginArtifact % coverageScalacPluginVersion.value % ScoveragePluginConfig.name).cross(CrossVersion.full) + (orgScoverage %% scalacPluginArtifact % coverageScalacPluginVersion.value % ScoveragePluginConfig.name).cross(CrossVersion.full) ) } else Nil @@ -71,8 +71,8 @@ object ScoverageSbtPlugin extends AutoPlugin { val updateReport = update.value if (coverageEnabled.value) { val scoverageDeps: Seq[File] = updateReport matching configurationFilter(ScoveragePluginConfig.name) - val pluginPath: File = scoverageDeps.find(_.getAbsolutePath.contains(ScalacPluginArtifact)) match { - case None => throw new Exception(s"Fatal: $ScalacPluginArtifact not in libraryDependencies") + val pluginPath: File = scoverageDeps.find(_.getAbsolutePath.contains(scalacPluginArtifact)) match { + case None => throw new Exception(s"Fatal: $scalacPluginArtifact not in libraryDependencies") case Some(pluginPath) => pluginPath } Seq( @@ -90,7 +90,7 @@ object ScoverageSbtPlugin extends AutoPlugin { ) private def scalacRuntime(deps: Seq[ModuleID]): String = { - ScalacRuntimeArtifact + optionalScalaJsSuffix(deps) + scalacRuntimeArtifact + optionalScalaJsSuffix(deps) } // returns "_sjs$sjsVersion" for Scala.js projects or "" otherwise From 89511a662f751accf65ace5779fdc8170ff1fe5e Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Sun, 2 May 2021 10:58:11 +0200 Subject: [PATCH 18/49] Remove explicit version in example in docs. I don't want to have to update the readme every release... --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d1ebe461..233529a7 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,9 @@ sbt.version = 1.2.8 ``` Add the plugin in `project/plugins.sbt`: +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.scoverage/sbt-scoverage/badge.svg?kill_cache=1)](https://search.maven.org/artifact/org.scoverage/sbt-scoverage/) ```scala -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.7.0") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "x.x.x") ``` Run the tests with enabled coverage: From 313d3e6bc1dc5813a68c5d351dc297b8737cde2e Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Sun, 2 May 2021 17:55:35 +0200 Subject: [PATCH 19/49] Update default branch from master to main --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 036fbc59..318f0b0b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ on: paths-ignore: - '*.md' branches: - - master + - main pull_request: jobs: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 90ec276b..b3204014 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: Release on: push: branches: - - master + - main tags: ["*"] jobs: publish: From 321863cdced99fc46f9ba8fd56718b0976c532e7 Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Sun, 2 May 2021 18:10:37 +0200 Subject: [PATCH 20/49] Add in dependabot for actions, and release drafter stuff. Also for the future I'd like to ignore update for the scala compiler from Steward. --- .github/dependabot.yml | 7 +++++++ .github/release-drafter.yml | 4 ++++ .github/workflows/release-drafter.yml | 14 ++++++++++++++ .scala-steward.conf | 1 + 4 files changed, 26 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/release-drafter.yml create mode 100644 .scala-steward.conf diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..e33811f6 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 00000000..27bcee3f --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,4 @@ +template: | + ## What’s Changed + + $CHANGES diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 00000000..896edaf4 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,14 @@ +name: Release Drafter + +on: + push: + branches: + - main + +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.scala-steward.conf b/.scala-steward.conf new file mode 100644 index 00000000..1a44ff58 --- /dev/null +++ b/.scala-steward.conf @@ -0,0 +1 @@ +updates.ignore = [ { groupId = "org.scala-lang" } ] From 8b11eba02f30abd4aa85f88290686a4621684c54 Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Sun, 2 May 2021 20:49:04 +0200 Subject: [PATCH 21/49] Test on jdk 8 and 11 Also both CI and release to setup-java --- .github/workflows/ci.yml | 13 ++++++------- .github/workflows/release.yml | 7 +++++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 318f0b0b..e8124c0c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,20 +13,19 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: [ '11' ] - scala: [ - { version: '2.12.13' } - ] + java: [ '8', '11' ] + steps: - name: checkout the repo uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Set up JDK - uses: actions/setup-java@v1 + - name: Set up JVM + uses: actions/setup-java@v2 with: + distribution: 'adopt' java-version: ${{ matrix.java }} - name: run tests - run: sbt ++${{ matrix.scala.version }} test scripted + run: sbt scripted diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b3204014..3370fc55 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,10 +8,13 @@ jobs: publish: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2.3.4 + - uses: actions/checkout@v2 with: fetch-depth: 0 - - uses: olafurpg/setup-scala@v10 + - uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: '11' - run: sbt ci-release env: PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} From 2b128513726e2a44ae9114f06db6d1ab1c51e374 Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Sun, 2 May 2021 23:40:45 +0200 Subject: [PATCH 22/49] Update to latest scoverage 1.4.5 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 90efc871..cea9b8db 100644 --- a/build.sbt +++ b/build.sbt @@ -4,7 +4,7 @@ import sbt.ScriptedPlugin.autoImport.scriptedLaunchOpts def localSnapshotVersion = "1.7.1-SNAPSHOT" def isCI = System.getenv("CI") != null -def scoverageVersion = "1.4.4" +def scoverageVersion = "1.4.5" inThisBuild( List( From 8a2726c96785fecd1852c177e119141f90ba7709 Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Tue, 4 May 2021 10:00:16 +0200 Subject: [PATCH 23/49] Make sure buildInfo is in it's own package. If not, this could cause issues downstream if there are multiple plugins or applications that aren't namespacing their buildInfo packages. I actually just hit on this and realized I forgot to add in buildInfoPackage here. --- build.sbt | 1 + src/main/scala/scoverage/ScoverageSbtPlugin.scala | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index cea9b8db..9abf00ec 100644 --- a/build.sbt +++ b/build.sbt @@ -43,6 +43,7 @@ lazy val root = Project("sbt-scoverage", file(".")) "org.scoverage" %% "scalac-scoverage-plugin" % scoverageVersion cross (CrossVersion.full), ), buildInfoKeys := Seq[BuildInfoKey]("scoverageVersion" -> scoverageVersion), + buildInfoPackage := "scoverage", Test / fork := false, Test / publishArtifact := false, Test / parallelExecution := false, diff --git a/src/main/scala/scoverage/ScoverageSbtPlugin.scala b/src/main/scala/scoverage/ScoverageSbtPlugin.scala index 099c3d72..e136aeed 100644 --- a/src/main/scala/scoverage/ScoverageSbtPlugin.scala +++ b/src/main/scala/scoverage/ScoverageSbtPlugin.scala @@ -5,7 +5,6 @@ import sbt._ import sbt.plugins.JvmPlugin import scoverage.report.{CoberturaXmlWriter, CoverageAggregator, ScoverageHtmlWriter, ScoverageXmlWriter} import java.time.Instant -import buildinfo.BuildInfo object ScoverageSbtPlugin extends AutoPlugin { From 50f58c9dc48accff01cd3db2903e8149375e445a Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Tue, 4 May 2021 10:37:14 +0200 Subject: [PATCH 24/49] Don't have a local snapshot version I originally added this in here to make it easier locally to just publish a snapshot for testing, but it also requires a manual update. It's probably fine to just remove this and let sbt-dynver via sbt-ci-release fully handle this. --- build.sbt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/build.sbt b/build.sbt index 9abf00ec..8c1ba7d4 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,6 @@ name := "sbt-scoverage" import sbt.ScriptedPlugin.autoImport.scriptedLaunchOpts -def localSnapshotVersion = "1.7.1-SNAPSHOT" def isCI = System.getenv("CI") != null def scoverageVersion = "1.4.5" @@ -27,11 +26,7 @@ inThisBuild( licenses := Seq( "Apache-2.0" -> url("http://www.apache.org/license/LICENSE-2.0") ), - scalaVersion := "2.12.13", - version ~= { dynVer => - if (isCI) dynVer - else localSnapshotVersion // only for local publishing - } + scalaVersion := "2.12.13" ) ) From af2396558918fea00eaa2da12906a3012eb72153 Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Thu, 6 May 2021 14:51:33 +0200 Subject: [PATCH 25/49] Add in Scalafmt --- .github/workflows/ci.yml | 22 +- .scalafmt.conf | 1 + build.sbt | 3 +- project/plugins.sbt | 1 + src/main/scala/scoverage/ScoverageKeys.scala | 6 +- .../scala/scoverage/ScoverageSbtPlugin.scala | 213 ++++++++++++------ .../aggregate/project/build.properties | 1 + 7 files changed, 177 insertions(+), 70 deletions(-) create mode 100644 .scalafmt.conf create mode 100644 src/sbt-test/scoverage/aggregate/project/build.properties diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e8124c0c..7ccae35e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ on: pull_request: jobs: - scala: + test: runs-on: ubuntu-latest strategy: matrix: @@ -27,5 +27,23 @@ jobs: distribution: 'adopt' java-version: ${{ matrix.java }} - - name: run tests + - name: Run tests run: sbt scripted + + formatting: + runs-on: ubuntu-latest + + steps: + - name: checkout the repo + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up JVM + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: '8' + + - name: Check Formatting + run: sbt scalafmtCheckAll diff --git a/.scalafmt.conf b/.scalafmt.conf new file mode 100644 index 00000000..010fa6d5 --- /dev/null +++ b/.scalafmt.conf @@ -0,0 +1 @@ +version = "2.7.5" diff --git a/build.sbt b/build.sbt index 8c1ba7d4..8c976213 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,6 @@ name := "sbt-scoverage" import sbt.ScriptedPlugin.autoImport.scriptedLaunchOpts -def isCI = System.getenv("CI") != null def scoverageVersion = "1.4.5" inThisBuild( @@ -35,7 +34,7 @@ lazy val root = Project("sbt-scoverage", file(".")) .settings( libraryDependencies ++= Seq( "org.scala-lang" % "scala-compiler" % scalaVersion.value % Compile, - "org.scoverage" %% "scalac-scoverage-plugin" % scoverageVersion cross (CrossVersion.full), + "org.scoverage" %% "scalac-scoverage-plugin" % scoverageVersion cross (CrossVersion.full) ), buildInfoKeys := Seq[BuildInfoKey]("scoverageVersion" -> scoverageVersion), buildInfoPackage := "scoverage", diff --git a/project/plugins.sbt b/project/plugins.sbt index f7bfdc77..ce24e5b0 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,4 @@ libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2") diff --git a/src/main/scala/scoverage/ScoverageKeys.scala b/src/main/scala/scoverage/ScoverageKeys.scala index 1b565dbb..3a6cd203 100644 --- a/src/main/scala/scoverage/ScoverageKeys.scala +++ b/src/main/scala/scoverage/ScoverageKeys.scala @@ -3,7 +3,10 @@ package scoverage import sbt._ object ScoverageKeys { - lazy val coverageEnabled = settingKey[Boolean]("controls whether code instrumentation is enabled or not") + // format: off + lazy val coverageEnabled = settingKey[Boolean]( + "controls whether code instrumentation is enabled or not" + ) lazy val coverageReport = taskKey[Unit]("run report generation") lazy val coverageAggregate = taskKey[Unit]("aggregate reports from subprojects") lazy val coverageExcludedPackages = settingKey[String]("regex for excluded packages") @@ -17,4 +20,5 @@ object ScoverageKeys { lazy val coverageOutputDebug = settingKey[Boolean]("turn on the debug report") lazy val coverageOutputTeamCity = settingKey[Boolean]("turn on teamcity reporting") lazy val coverageScalacPluginVersion = settingKey[String]("version of scalac-scoverage-plugin to use") + // format: on } diff --git a/src/main/scala/scoverage/ScoverageSbtPlugin.scala b/src/main/scala/scoverage/ScoverageSbtPlugin.scala index e136aeed..f9cfadc5 100644 --- a/src/main/scala/scoverage/ScoverageSbtPlugin.scala +++ b/src/main/scala/scoverage/ScoverageSbtPlugin.scala @@ -3,7 +3,11 @@ package scoverage import sbt.Keys._ import sbt._ import sbt.plugins.JvmPlugin -import scoverage.report.{CoberturaXmlWriter, CoverageAggregator, ScoverageHtmlWriter, ScoverageXmlWriter} +import scoverage.report.CoberturaXmlWriter +import scoverage.report.CoverageAggregator +import scoverage.report.ScoverageHtmlWriter +import scoverage.report.ScoverageXmlWriter + import java.time.Instant object ScoverageSbtPlugin extends AutoPlugin { @@ -17,26 +21,29 @@ object ScoverageSbtPlugin extends AutoPlugin { import autoImport._ - val aggregateFilter = ScopeFilter(inAggregates(ThisProject), - inConfigurations(Compile)) // must be outside of the 'coverageAggregate' task (see: https://github.com/sbt/sbt/issues/1095 or https://github.com/sbt/sbt/issues/780) + val aggregateFilter = ScopeFilter( + inAggregates(ThisProject), + inConfigurations(Compile) + ) // must be outside of the 'coverageAggregate' task (see: https://github.com/sbt/sbt/issues/1095 or https://github.com/sbt/sbt/issues/780) override def requires: JvmPlugin.type = plugins.JvmPlugin override def trigger: PluginTrigger = allRequirements - override def globalSettings: Seq[Def.Setting[_]] = super.globalSettings ++ Seq( - coverageEnabled := false, - coverageExcludedPackages := "", - coverageExcludedFiles := "", - coverageMinimum := 0, // default is no minimum - coverageFailOnMinimum := false, - coverageHighlighting := true, - coverageOutputXML := true, - coverageOutputHTML := true, - coverageOutputCobertura := true, - coverageOutputDebug := false, - coverageOutputTeamCity := false, - coverageScalacPluginVersion := defaultScoverageVersion - ) + override def globalSettings: Seq[Def.Setting[_]] = + super.globalSettings ++ Seq( + coverageEnabled := false, + coverageExcludedPackages := "", + coverageExcludedFiles := "", + coverageMinimum := 0, // default is no minimum + coverageFailOnMinimum := false, + coverageHighlighting := true, + coverageOutputXML := true, + coverageOutputHTML := true, + coverageOutputCobertura := true, + coverageOutputDebug := false, + coverageOutputTeamCity := false, + coverageScalacPluginVersion := defaultScoverageVersion + ) override def buildSettings: Seq[Setting[_]] = super.buildSettings ++ addCommandAlias("coverage", ";set ThisBuild / coverageEnabled := true") ++ @@ -56,9 +63,12 @@ object ScoverageSbtPlugin extends AutoPlugin { Seq( // We only add for "compile" because of macros. This setting could be optimed to just "test" if the handling // of macro coverage was improved. - (orgScoverage %% (scalacRuntime(libraryDependencies.value)) % coverageScalacPluginVersion.value).cross(CrossVersion.full), + (orgScoverage %% (scalacRuntime( + libraryDependencies.value + )) % coverageScalacPluginVersion.value).cross(CrossVersion.full), // We don't want to instrument the test code itself, nor add to a pom when published with coverage enabled. - (orgScoverage %% scalacPluginArtifact % coverageScalacPluginVersion.value % ScoveragePluginConfig.name).cross(CrossVersion.full) + (orgScoverage %% scalacPluginArtifact % coverageScalacPluginVersion.value % ScoveragePluginConfig.name) + .cross(CrossVersion.full) ) } else Nil @@ -69,16 +79,28 @@ object ScoverageSbtPlugin extends AutoPlugin { Compile / compile / scalacOptions ++= { val updateReport = update.value if (coverageEnabled.value) { - val scoverageDeps: Seq[File] = updateReport matching configurationFilter(ScoveragePluginConfig.name) - val pluginPath: File = scoverageDeps.find(_.getAbsolutePath.contains(scalacPluginArtifact)) match { - case None => throw new Exception(s"Fatal: $scalacPluginArtifact not in libraryDependencies") + val scoverageDeps: Seq[File] = + updateReport matching configurationFilter(ScoveragePluginConfig.name) + val pluginPath: File = scoverageDeps.find( + _.getAbsolutePath.contains(scalacPluginArtifact) + ) match { + case None => + throw new Exception( + s"Fatal: $scalacPluginArtifact not in libraryDependencies" + ) case Some(pluginPath) => pluginPath } Seq( Some(s"-Xplugin:${pluginPath.getAbsolutePath}"), - Some(s"-P:scoverage:dataDir:${crossTarget.value.getAbsolutePath}/scoverage-data"), - Option(coverageExcludedPackages.value.trim).filter(_.nonEmpty).map(v => s"-P:scoverage:excludedPackages:$v"), - Option(coverageExcludedFiles.value.trim).filter(_.nonEmpty).map(v => s"-P:scoverage:excludedFiles:$v"), + Some( + s"-P:scoverage:dataDir:${crossTarget.value.getAbsolutePath}/scoverage-data" + ), + Option(coverageExcludedPackages.value.trim) + .filter(_.nonEmpty) + .map(v => s"-P:scoverage:excludedPackages:$v"), + Option(coverageExcludedFiles.value.trim) + .filter(_.nonEmpty) + .map(v => s"-P:scoverage:excludedFiles:$v"), // rangepos is broken in some releases of scala so option to turn it off if (coverageHighlighting.value) Some("-Yrangepos") else None ).flatten @@ -94,9 +116,14 @@ object ScoverageSbtPlugin extends AutoPlugin { // returns "_sjs$sjsVersion" for Scala.js projects or "" otherwise private def optionalScalaJsSuffix(deps: Seq[ModuleID]): String = { - val sjsClassifier = deps.collectFirst { - case moduleId if moduleId.organization == "org.scala-js" && moduleId.name == "scalajs-library" => moduleId.revision - }.map(_.take(1)).map(sjsVersion => "_sjs" + sjsVersion) + val sjsClassifier = deps + .collectFirst { + case moduleId + if moduleId.organization == "org.scala-js" && moduleId.name == "scalajs-library" => + moduleId.revision + } + .map(_.take(1)) + .map(sjsVersion => "_sjs" + sjsVersion) sjsClassifier getOrElse "" } @@ -106,7 +133,9 @@ object ScoverageSbtPlugin extends AutoPlugin { val log = streams.value.log log.info(s"Waiting for measurement data to sync...") - Thread.sleep(1000) // have noticed some delay in writing on windows, hacky but works + Thread.sleep( + 1000 + ) // have noticed some delay in writing on windows, hacky but works loadCoverage(target, log) match { case Some(cov) => @@ -120,9 +149,15 @@ object ScoverageSbtPlugin extends AutoPlugin { coverageOutputDebug.value, coverageOutputTeamCity.value, sourceEncoding((Compile / scalacOptions).value), - log) + log + ) - checkCoverage(cov, log, coverageMinimum.value, coverageFailOnMinimum.value) + checkCoverage( + cov, + log, + coverageMinimum.value, + coverageFailOnMinimum.value + ) case None => log.warn("No coverage data, skipping reports") } } @@ -131,7 +166,9 @@ object ScoverageSbtPlugin extends AutoPlugin { val log = streams.value.log log.info(s"Aggregating coverage from subprojects...") - val dataDirs = crossTarget.all(aggregateFilter).value map (_ / Constants.DataDir) filter (_.isDirectory) + val dataDirs = crossTarget + .all(aggregateFilter) + .value map (_ / Constants.DataDir) filter (_.isDirectory) CoverageAggregator.aggregate(dataDirs) match { case Some(cov) => writeReports( @@ -144,26 +181,34 @@ object ScoverageSbtPlugin extends AutoPlugin { coverageOutputDebug.value, coverageOutputTeamCity.value, sourceEncoding((Compile / scalacOptions).value), - log) + log + ) val cfmt = cov.statementCoverageFormatted log.info(s"Aggregation complete. Coverage was [$cfmt]") - checkCoverage(cov, log, coverageMinimum.value, coverageFailOnMinimum.value) + checkCoverage( + cov, + log, + coverageMinimum.value, + coverageFailOnMinimum.value + ) case None => log.info("No subproject data to aggregate, skipping reports") } } - private def writeReports(crossTarget: File, - compileSourceDirectories: Seq[File], - coverage: Coverage, - coverageOutputCobertura: Boolean, - coverageOutputXML: Boolean, - coverageOutputHTML: Boolean, - coverageDebug: Boolean, - coverageOutputTeamCity: Boolean, - coverageSourceEncoding: Option[String], - log: Logger): Unit = { + private def writeReports( + crossTarget: File, + compileSourceDirectories: Seq[File], + coverage: Coverage, + coverageOutputCobertura: Boolean, + coverageOutputXML: Boolean, + coverageOutputHTML: Boolean, + coverageDebug: Boolean, + coverageOutputTeamCity: Boolean, + coverageSourceEncoding: Option[String], + log: Logger + ): Unit = { log.info(s"Generating scoverage reports...") val coberturaDir = crossTarget / "coverage-report" @@ -172,24 +217,46 @@ object ScoverageSbtPlugin extends AutoPlugin { reportDir.mkdirs() if (coverageOutputCobertura) { - new CoberturaXmlWriter(compileSourceDirectories, coberturaDir).write(coverage) - log.info(s"Written Cobertura report [${coberturaDir.getAbsolutePath}/cobertura.xml]") + new CoberturaXmlWriter(compileSourceDirectories, coberturaDir).write( + coverage + ) + log.info( + s"Written Cobertura report [${coberturaDir.getAbsolutePath}/cobertura.xml]" + ) } if (coverageOutputXML) { - new ScoverageXmlWriter(compileSourceDirectories, reportDir, false).write(coverage) + new ScoverageXmlWriter(compileSourceDirectories, reportDir, false).write( + coverage + ) if (coverageDebug) { - new ScoverageXmlWriter(compileSourceDirectories, reportDir, true).write(coverage) + new ScoverageXmlWriter(compileSourceDirectories, reportDir, true).write( + coverage + ) } - log.info(s"Written XML coverage report [${reportDir.getAbsolutePath}/scoverage.xml]") + log.info( + s"Written XML coverage report [${reportDir.getAbsolutePath}/scoverage.xml]" + ) } if (coverageOutputHTML) { - new ScoverageHtmlWriter(compileSourceDirectories, reportDir, coverageSourceEncoding).write(coverage) - log.info(s"Written HTML coverage report [${reportDir.getAbsolutePath}/index.html]") + new ScoverageHtmlWriter( + compileSourceDirectories, + reportDir, + coverageSourceEncoding + ).write(coverage) + log.info( + s"Written HTML coverage report [${reportDir.getAbsolutePath}/index.html]" + ) } if (coverageOutputTeamCity) { - reportToTeamcity(coverage, coverageOutputHTML, reportDir, crossTarget, log) + reportToTeamcity( + coverage, + coverageOutputHTML, + reportDir, + crossTarget, + log + ) log.info("Written coverage report to TeamCity") } @@ -198,24 +265,38 @@ object ScoverageSbtPlugin extends AutoPlugin { log.info("Coverage reports completed") } - private def reportToTeamcity(coverage: Coverage, - createCoverageZip: Boolean, - reportDir: File, - crossTarget: File, - log: Logger) { + private def reportToTeamcity( + coverage: Coverage, + createCoverageZip: Boolean, + reportDir: File, + crossTarget: File, + log: Logger + ) { - def statsKeyValue(key: String, value: Int): String = s"##teamcity[buildStatisticValue key='$key' value='$value']" + def statsKeyValue(key: String, value: Int): String = + s"##teamcity[buildStatisticValue key='$key' value='$value']" // Log statement coverage as per: https://devnet.jetbrains.com/message/5467985 - log.info(statsKeyValue("CodeCoverageAbsSCovered", coverage.invokedStatementCount)) + log.info( + statsKeyValue("CodeCoverageAbsSCovered", coverage.invokedStatementCount) + ) log.info(statsKeyValue("CodeCoverageAbsSTotal", coverage.statementCount)) // Log branch coverage as a custom metrics (in percent) - log.info(statsKeyValue("CodeCoverageBranch", "%.0f".format(coverage.branchCoveragePercent).toInt)) + log.info( + statsKeyValue( + "CodeCoverageBranch", + "%.0f".format(coverage.branchCoveragePercent).toInt + ) + ) // Create the coverage report for teamcity (HTML files) if (createCoverageZip) - IO.zip(Path.allSubpaths(reportDir), crossTarget / "coverage.zip", Some(Instant.now().toEpochMilli())) + IO.zip( + Path.allSubpaths(reportDir), + crossTarget / "coverage.zip", + Some(Instant.now().toEpochMilli()) + ) } private def loadCoverage(crossTarget: File, log: Logger): Option[Coverage] = { @@ -240,10 +321,12 @@ object ScoverageSbtPlugin extends AutoPlugin { } } - private def checkCoverage(coverage: Coverage, - log: Logger, - min: Double, - failOnMin: Boolean): Unit = { + private def checkCoverage( + coverage: Coverage, + log: Logger, + min: Double, + failOnMin: Boolean + ): Unit = { val cper = coverage.statementCoveragePercent val cfmt = coverage.statementCoverageFormatted diff --git a/src/sbt-test/scoverage/aggregate/project/build.properties b/src/sbt-test/scoverage/aggregate/project/build.properties new file mode 100644 index 00000000..f0be67b9 --- /dev/null +++ b/src/sbt-test/scoverage/aggregate/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.5.1 From 443f12bb13466af2f0b6ec83eeb874f808883fa9 Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Thu, 6 May 2021 15:00:58 +0200 Subject: [PATCH 26/49] Remove scala-compiler as a dep. I didn't catch this before, but I'm unsure why this was added in this commit: https://github.com/scoverage/sbt-scoverage/commit/5d298ed9fc032025f2023bf31fe869c0b7361001, but it shouldn't be needed. --- build.sbt | 1 - 1 file changed, 1 deletion(-) diff --git a/build.sbt b/build.sbt index 8c976213..364337b3 100644 --- a/build.sbt +++ b/build.sbt @@ -33,7 +33,6 @@ lazy val root = Project("sbt-scoverage", file(".")) .enablePlugins(SbtPlugin, BuildInfoPlugin) .settings( libraryDependencies ++= Seq( - "org.scala-lang" % "scala-compiler" % scalaVersion.value % Compile, "org.scoverage" %% "scalac-scoverage-plugin" % scoverageVersion cross (CrossVersion.full) ), buildInfoKeys := Seq[BuildInfoKey]("scoverageVersion" -> scoverageVersion), From 6d87354ffe9b43ef920eca9f20971e4777ef8d75 Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Thu, 6 May 2021 15:46:18 +0200 Subject: [PATCH 27/49] Overhaul the README This PR is me just going through the README and organzing this a bit different/better. I also removed a few things that can just be found elsewhere and in my opinion clog up the readme. - License -- This is displayed on GitHub and is still in the repo. There is no changes here to be clear, just removing it from the readmd. - Migration notes -- I've firm believer of not repeating things, so I'd like to instead have good release notes that talk about the changes and how to migrate to the newest versions. I've gone ahead and migrated the notes from the readme into the release page. For questions about migrating, please reference there in the future: https://github.com/scoverage/sbt-scoverage/releases --- README.md | 144 +++++++++++++++++++++++++----------------------------- 1 file changed, 66 insertions(+), 78 deletions(-) diff --git a/README.md b/README.md index 233529a7..b4780f94 100644 --- a/README.md +++ b/README.md @@ -6,21 +6,19 @@ sbt-scoverage is a plugin for sbt that integrates the scoverage code coverage library. Find out more about -[scoverage](https://github.com/scoverage/scalac-scoverage-plugin). +[scoverage here](https://github.com/scoverage/scalac-scoverage-plugin). -## How to use +## Setup -Make sure your sbt version in project/build.properties: -```scala -sbt.version = 1.2.8 -``` +**Requirements**: Requires sbt 1.2.8 or above -Add the plugin in `project/plugins.sbt`: -[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.scoverage/sbt-scoverage/badge.svg?kill_cache=1)](https://search.maven.org/artifact/org.scoverage/sbt-scoverage/) +In `project/plugins.sbt`: ```scala addSbtPlugin("org.scoverage" % "sbt-scoverage" % "x.x.x") ``` +## Usage + Run the tests with enabled coverage: ``` $ sbt clean coverage test @@ -40,58 +38,40 @@ To generate the coverage reports run $ sbt coverageReport ``` -Coverage reports will be in `target/scala-/scoverage-report`. There are HTML and XML reports. The XML is useful if you need to programatically use the results, or if you're writing a tool. - -If you're running the coverage reports from within an sbt console session (as -opposed to one command per sbt launch), then the `coverage` command is sticky. To -turn it back off when you're done running reports, use the `coverageOff` command or reset `coverageEnabled` with `set coverageEnabled := false`. - -Sample project with scoverage in both sbt and maven - [the scoverage samples project](https://github.com/scoverage/sbt-scoverage-samples). - -## Notes on upgrading to version 1.6.x -* ´coverageCleanSubprojectFiles´ key has been removed -* scala version 2.12+ is required as a minimum (due to scoverage suppport) - -## Notes on upgrading to version 1.6.0 - -* `coverageAggregate` aggregates raw coverage data, not coverage xml reports for modules. -There is no requirement to generate individual coverage reports for modules (`coverageReport`) -before generating aggregated report (`coverageAggregate`). - -If only aggregated report is required, not executing `coverageReport` can reduce the build time significantly. - -## Notes on upgrading to version 1.3.0 - -* The object containing the keys has changed from nested to top level so you might need to adjust the import. It's also an auto plugin now, so you might not need the import at all. -* There is an issue syncing the binary with the sbt-plugin-releases repo, so in the meantime add `resolvers += Resolver.url("scoverage-bintray", url("https://dl.bintray.com/sksamuel/sbt-plugins/"))(Resolver.ivyStylePatterns)` to your build. - -## Notes on upgrading to version 1.0.0 +Coverage reports will be in your `target/scala-/scoverage-report` +directory. There are HTML and XML reports. The XML is useful if you need to +programatically use the results, or if you're writing a tool. -If you are upgrading from 0.99.x then you must remove the `instrumentSettings` from your build.sbt or Build.scala, as that is no longer needed. +**NOTE**: If you're running the coverage reports from within an sbt console +session (as opposed to one command per sbt launch), then the `coverage` command +is sticky. To turn it back off when you're done running reports, use the +`coverageOff` command or reset `coverageEnabled` with `set coverageEnabled := +false`. -Next, the keys have been renamed slightly. The new names begin with coverageXXX, eg coverageExcludedPackages and some have had their full name changed. You can see a full list of keys by opening the object ScoverageKeys. +### Multi project reports -## Multi project reports +By default, scoverage will generate reports for each project separately. You can +merge them into an aggregated report by using the following: -By default, scoverage will generate reports for each project separately. You can merge them into an aggregated report by invoking `sbt coverageAggregate`. - -(Note, you must do this after all the coverage data is complete as a separate command, so you cannot do `sbt coverage test coverageAggregate` (at least until a way around this is found).) +``` +$ sbt coverageAggregate +``` -(You do not need to run `coverageReport` before `coverageAggregate`; it aggregates over the sub-projects' coverage data directly, not the report xml.) +**NOTE**: You do not need to run `coverageReport` before `coverageAggregate`; it +aggregates over the sub-projects' coverage data directly, not the report xml. -## Exclude classes and packages +### Exclude classes and packages -You can exclude classes from being considered for coverage measurement by providing semicolon-separated list of -regular expressions. +You can exclude classes from being considered for coverage measurement by +providing semicolon-separated list of regular expressions. -Example: ```scala coverageExcludedPackages := ";Reverse.*;.*AuthService.*;models\\.data\\..*" ``` -The regular expressions are matched against the fully qualified class name, and must match the entire string to take effect. - -Any matched classes will not be instrumented or included in the coverage report. +The regular expressions are matched against the fully qualified class name, and +must match the entire string to take effect. Any matched classes will not be +instrumented or included in the coverage report. You can also mark sections of code with comments like: @@ -101,59 +81,67 @@ You can also mark sections of code with comments like: // $COVERAGE-ON$ ``` -Any code between two such comments will not be instrumented or included in the coverage report. +Any code between two such comments will not be instrumented or included in the +coverage report. -## Minimum coverage +### Minimum coverage -Based on minimum coverage, you can fail the build with the following keys +Based on minimum coverage, you can fail the build with the following keys: ```scala coverageMinimum := 80 coverageFailOnMinimum := true ``` -These settings will be enforced when the reports are generated. -If you generate an aggregate report using `coverageAggregate` then these settings will apply to that report. +These settings will be enforced when the reports are generated. If you generate +an aggregate report using `coverageAggregate` then these settings will apply to +that report. + +## Trouble-shooting failing tests -## Failing tests -Scoverage does a lot of file writing behind the scenes in order to track which statements have been executed. -If you are running into a scenario where your tests normally pass, but fail when scoverage is enabled, then the culprit can be one of the following: +scoverage does a lot of file writing behind the scenes in order to track which +statements have been executed. If you are running into a scenario where your +tests normally pass, but fail when scoverage is enabled, then the culprit can be +one of the following: * timing issues on futures and other async operations, try upping the timeouts by an order of magnitude. * tests are run in a sandbox mode (such as with `java.security.PrivilegedAction`), try running the tests outside of the sandbox. +## Example project + +[the scoverage samples project](https://github.com/scoverage/sbt-scoverage-samples). + ## Integrations ### Codacy -[Codacy](https://www.codacy.com) integrates with your favorite coverage tool to provide an in-depth overlook of your project status. Scoverage information can be integrated into Codacy through the [sbt-codacy-coverage plugin](https://github.com/codacy/sbt-codacy-coverage). +[Codacy](https://www.codacy.com) integrates with your favorite coverage tool to +provide an in-depth overlook of your project status. scoverage information can +be integrated into Codacy through the +[codacy-coverage-reporter](https://github.com/codacy/codacy-coverage-reporter). ### Coveralls -If you have an open source project then you can add code coverage metrics with the excellent website https://coveralls.io/ Scoverage will integrate with coveralls using the [sbt-coveralls](https://github.com/scoverage/sbt-coveralls) plugin. - -### Plugin for SonarQube +If you have an open source project then you can add code coverage metrics with +the [Coveralls](https://coveralls.io/). scoverage will integrate with coveralls +using the [sbt-coveralls](https://github.com/scoverage/sbt-coveralls) plugin. -If you want to visually browse statement coverage reports then use this [plugin for SonarQube](https://github.com/RadoBuransky/sonar-scoverage-plugin). -It allows you to review overall project statement coverage as well as dig deeper into sub-modules, directories and -source code files to see uncovered statements. Statement coverage measurement can become an integral part of your -team's continuous integration process and a required quality standard. +### Codecov -## License -``` -This software is licensed under the Apache 2 license, quoted below. +You can integrate with [Codecov](https://about.codecov.io/) easily sending your +reports there via your CI. You can see an example of this here in +[codecov/example-scala](https://github.com/codecov/example-scala). -Copyright 2013-2016 Stephen Samuel and contributors +### Plugin for SonarQube -Licensed under the Apache License, Version 2.0 (the "License"); you may not -use this file except in compliance with the License. You may obtain a copy of -the License at +If you want to visually browse statement coverage reports then use this [plugin +for SonarQube](https://github.com/RadoBuransky/sonar-scoverage-plugin). It +allows you to review overall project statement coverage as well as dig deeper +into sub-modules, directories and source code files to see uncovered statements. +Statement coverage measurement can become an integral part of your team's +continuous integration process and a required quality standard. - http://www.apache.org/licenses/LICENSE-2.0 +## Release Notes -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -License for the specific language governing permissions and limitations under -the License. -``` +For any information on releases and upgrading, please refer to the [release +page](https://github.com/scoverage/sbt-scoverage/releases). From 7bb57d40cf898544aebd880400351ab096eff8c5 Mon Sep 17 00:00:00 2001 From: Vincent de Haan Date: Thu, 10 Oct 2019 23:29:28 +0200 Subject: [PATCH 28/49] Report test names --- src/main/scala/scoverage/ScoverageSbtPlugin.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/scala/scoverage/ScoverageSbtPlugin.scala b/src/main/scala/scoverage/ScoverageSbtPlugin.scala index f9cfadc5..de46492b 100644 --- a/src/main/scala/scoverage/ScoverageSbtPlugin.scala +++ b/src/main/scala/scoverage/ScoverageSbtPlugin.scala @@ -101,6 +101,7 @@ object ScoverageSbtPlugin extends AutoPlugin { Option(coverageExcludedFiles.value.trim) .filter(_.nonEmpty) .map(v => s"-P:scoverage:excludedFiles:$v"), + Some("-P:scoverage:reportTestName"), // rangepos is broken in some releases of scala so option to turn it off if (coverageHighlighting.value) Some("-Yrangepos") else None ).flatten From 6225254b81b992261c477d9954ed4e29e7ae65b7 Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Fri, 7 May 2021 14:23:03 +0200 Subject: [PATCH 29/49] Update tests in scripted. Normally I wouldn't have updated these, but since specs2 changed namespaces and I needed to go through and change everything since the current one wasn't published for newer versions of Scala. Therefore I just opted to migrate to a newer testframework that I do know will continue to be supported. I also then bumped the Scala versions in the actual tests. --- .../scoverage/aggregate-only/build.sbt | 18 ++++++------ .../partA/src/test/scala/AdderTestSuite.scala | 15 ++++------ .../src/test/scala/SubtractorTestSuite.scala | 16 ++++------- src/sbt-test/scoverage/aggregate-only/test | 10 +++---- src/sbt-test/scoverage/aggregate/build.sbt | 18 ++++++------ .../partA/src/test/scala/AdderTestSuite.scala | 15 ++++------ .../src/test/scala/SubtractorTestSuite.scala | 16 ++++------- src/sbt-test/scoverage/aggregate/test | 10 +++---- src/sbt-test/scoverage/bad-coverage/build.sbt | 7 +++-- .../src/test/scala/BadCoverageSpec.scala | 15 ++++------ src/sbt-test/scoverage/coverage-off/build.sbt | 7 +++-- .../src/test/scala/GoodCoverageSpec.scala | 15 ++++------ .../scoverage/good-coverage/build.sbt | 7 +++-- .../src/test/scala/GoodCoverageSpec.scala | 15 ++++------ src/sbt-test/scoverage/preserve-set/build.sbt | 28 +++++++++++++------ .../src/test/scala/PreserveSetSpec.scala | 10 +++---- src/sbt-test/scoverage/preserve-set/test | 6 ++-- .../scoverage/scalac-plugin-version/build.sbt | 7 +++-- src/sbt-test/scoverage/scalajs/build.sbt | 16 +++++------ .../sjstest/js/src/test/scala/JsTest.scala | 10 +++---- .../sjstest/jvm/src/test/scala/JvmTest.scala | 10 +++---- .../shared/src/test/scala/SharedTest.scala | 9 +++--- src/sbt-test/scoverage/scalajs/test | 8 +++--- 23 files changed, 137 insertions(+), 151 deletions(-) diff --git a/src/sbt-test/scoverage/aggregate-only/build.sbt b/src/sbt-test/scoverage/aggregate-only/build.sbt index 3ca537e3..da1eb7b9 100644 --- a/src/sbt-test/scoverage/aggregate-only/build.sbt +++ b/src/sbt-test/scoverage/aggregate-only/build.sbt @@ -1,23 +1,21 @@ /* The projects test aggregation of coverage reports from two sub-projects. The sub-projects are in the directories partA and partB. -*/ + */ lazy val commonSettings = Seq( organization := "org.scoverage", version := "0.1.0", - scalaVersion := "2.12.13" + scalaVersion := "2.13.5" ) -lazy val specs2Lib = "org.specs2" %% "specs2" % "2.5" % "test" - def module(name: String) = { val id = s"part$name" Project(id = id, base = file(id)) .settings(commonSettings: _*) .settings( Keys.name := name, - libraryDependencies += specs2Lib + libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test ) } @@ -25,16 +23,18 @@ lazy val partA = module("A") lazy val partB = module("B") lazy val root = (project in file(".")) - .settings(commonSettings:_*) + .settings(commonSettings: _*) .settings( name := "root", - test := { } - ).aggregate( + test := {} + ) + .aggregate( partA, partB ) ThisBuild / resolvers ++= { - if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots")) + if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) + Seq(Resolver.sonatypeRepo("snapshots")) else Seq.empty } diff --git a/src/sbt-test/scoverage/aggregate-only/partA/src/test/scala/AdderTestSuite.scala b/src/sbt-test/scoverage/aggregate-only/partA/src/test/scala/AdderTestSuite.scala index 63efd2b9..71204c58 100644 --- a/src/sbt-test/scoverage/aggregate-only/partA/src/test/scala/AdderTestSuite.scala +++ b/src/sbt-test/scoverage/aggregate-only/partA/src/test/scala/AdderTestSuite.scala @@ -1,13 +1,10 @@ -import org.specs2.mutable._ +import munit.FunSuite import org.scoverage.issue53.part.a.AdderScala -/** - * Created by Mikhail Kokho on 7/10/2015. - */ -class AdderTestSuite extends Specification { - "Adder" should { - "sum two numbers" in { - AdderScala.add(1, 2) mustEqual 3 - } +/** Created by Mikhail Kokho on 7/10/2015. + */ +class AdderTestSuite extends FunSuite { + test("Adder should sum two numbers") { + assertEquals(AdderScala.add(1, 2), 3) } } diff --git a/src/sbt-test/scoverage/aggregate-only/partB/src/test/scala/SubtractorTestSuite.scala b/src/sbt-test/scoverage/aggregate-only/partB/src/test/scala/SubtractorTestSuite.scala index 97c5266f..6b2ededf 100644 --- a/src/sbt-test/scoverage/aggregate-only/partB/src/test/scala/SubtractorTestSuite.scala +++ b/src/sbt-test/scoverage/aggregate-only/partB/src/test/scala/SubtractorTestSuite.scala @@ -1,14 +1,10 @@ -import org.specs2.mutable._ +import munit.FunSuite import org.scoverage.issue53.part.b.SubtractorScala -/** - * Created by Mikhail Kokho on 7/10/2015. - */ -class SubtractorTestSuite extends Specification { - "Subtractor" should { - "subtract two numbers" in { - SubtractorScala.minus(2, 1) mustEqual 1 - } +/** Created by Mikhail Kokho on 7/10/2015. + */ +class SubtractorTestSuite extends FunSuite { + test("Subtractor should subtract two numbers") { + assertEquals(SubtractorScala.minus(2, 1), 1) } } - diff --git a/src/sbt-test/scoverage/aggregate-only/test b/src/sbt-test/scoverage/aggregate-only/test index fb0d70f6..26983121 100644 --- a/src/sbt-test/scoverage/aggregate-only/test +++ b/src/sbt-test/scoverage/aggregate-only/test @@ -3,12 +3,12 @@ > coverage > test # There should be scoverage-data directories for modules -$ exists partA/target/scala-2.12/scoverage-data -$ exists partB/target/scala-2.12/scoverage-data +$ exists partA/target/scala-2.13/scoverage-data +$ exists partB/target/scala-2.13/scoverage-data # Generate aggregated reports without generating per-module reports first > coverageAggregate # There shouldn't be scoverage-report directories for modules --$ exists partA/target/scala-2.12/scoverage-report --$ exists partB/target/scala-2.12/scoverage-report +-$ exists partA/target/scala-2.13/scoverage-report +-$ exists partB/target/scala-2.13/scoverage-report # There should be a root scoverage-report directory -$ exists target/scala-2.12/scoverage-report \ No newline at end of file +$ exists target/scala-2.13/scoverage-report diff --git a/src/sbt-test/scoverage/aggregate/build.sbt b/src/sbt-test/scoverage/aggregate/build.sbt index 3ca537e3..da1eb7b9 100644 --- a/src/sbt-test/scoverage/aggregate/build.sbt +++ b/src/sbt-test/scoverage/aggregate/build.sbt @@ -1,23 +1,21 @@ /* The projects test aggregation of coverage reports from two sub-projects. The sub-projects are in the directories partA and partB. -*/ + */ lazy val commonSettings = Seq( organization := "org.scoverage", version := "0.1.0", - scalaVersion := "2.12.13" + scalaVersion := "2.13.5" ) -lazy val specs2Lib = "org.specs2" %% "specs2" % "2.5" % "test" - def module(name: String) = { val id = s"part$name" Project(id = id, base = file(id)) .settings(commonSettings: _*) .settings( Keys.name := name, - libraryDependencies += specs2Lib + libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test ) } @@ -25,16 +23,18 @@ lazy val partA = module("A") lazy val partB = module("B") lazy val root = (project in file(".")) - .settings(commonSettings:_*) + .settings(commonSettings: _*) .settings( name := "root", - test := { } - ).aggregate( + test := {} + ) + .aggregate( partA, partB ) ThisBuild / resolvers ++= { - if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots")) + if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) + Seq(Resolver.sonatypeRepo("snapshots")) else Seq.empty } diff --git a/src/sbt-test/scoverage/aggregate/partA/src/test/scala/AdderTestSuite.scala b/src/sbt-test/scoverage/aggregate/partA/src/test/scala/AdderTestSuite.scala index 63efd2b9..71204c58 100644 --- a/src/sbt-test/scoverage/aggregate/partA/src/test/scala/AdderTestSuite.scala +++ b/src/sbt-test/scoverage/aggregate/partA/src/test/scala/AdderTestSuite.scala @@ -1,13 +1,10 @@ -import org.specs2.mutable._ +import munit.FunSuite import org.scoverage.issue53.part.a.AdderScala -/** - * Created by Mikhail Kokho on 7/10/2015. - */ -class AdderTestSuite extends Specification { - "Adder" should { - "sum two numbers" in { - AdderScala.add(1, 2) mustEqual 3 - } +/** Created by Mikhail Kokho on 7/10/2015. + */ +class AdderTestSuite extends FunSuite { + test("Adder should sum two numbers") { + assertEquals(AdderScala.add(1, 2), 3) } } diff --git a/src/sbt-test/scoverage/aggregate/partB/src/test/scala/SubtractorTestSuite.scala b/src/sbt-test/scoverage/aggregate/partB/src/test/scala/SubtractorTestSuite.scala index 97c5266f..4bec321a 100644 --- a/src/sbt-test/scoverage/aggregate/partB/src/test/scala/SubtractorTestSuite.scala +++ b/src/sbt-test/scoverage/aggregate/partB/src/test/scala/SubtractorTestSuite.scala @@ -1,14 +1,10 @@ -import org.specs2.mutable._ +import munit.FunSuite import org.scoverage.issue53.part.b.SubtractorScala -/** - * Created by Mikhail Kokho on 7/10/2015. - */ -class SubtractorTestSuite extends Specification { - "Subtractor" should { - "subtract two numbers" in { - SubtractorScala.minus(2, 1) mustEqual 1 - } +/** Created by Mikhail Kokho on 7/10/2015. + */ +class SubtractorTestSuite extends FunSuite { + test("Subtractor should substract two numbers") { + assertEquals(SubtractorScala.minus(2, 1), 1) } } - diff --git a/src/sbt-test/scoverage/aggregate/test b/src/sbt-test/scoverage/aggregate/test index 9475fbbb..2a4f5fc3 100644 --- a/src/sbt-test/scoverage/aggregate/test +++ b/src/sbt-test/scoverage/aggregate/test @@ -3,12 +3,12 @@ > coverage > test # There should be scoverage-data directory -$ exists partA/target/scala-2.12/scoverage-data -$ exists partB/target/scala-2.12/scoverage-data +$ exists partA/target/scala-2.13/scoverage-data +$ exists partB/target/scala-2.13/scoverage-data > coverageReport # There should be scoverage-report directory -$ exists partA/target/scala-2.12/scoverage-report -$ exists partB/target/scala-2.12/scoverage-report +$ exists partA/target/scala-2.13/scoverage-report +$ exists partB/target/scala-2.13/scoverage-report > coverageAggregate # There should be a root scoverage-report directory -$ exists target/scala-2.12/scoverage-report \ No newline at end of file +$ exists target/scala-2.13/scoverage-report diff --git a/src/sbt-test/scoverage/bad-coverage/build.sbt b/src/sbt-test/scoverage/bad-coverage/build.sbt index 30698311..de77b640 100644 --- a/src/sbt-test/scoverage/bad-coverage/build.sbt +++ b/src/sbt-test/scoverage/bad-coverage/build.sbt @@ -1,14 +1,15 @@ version := "0.1" -scalaVersion := "2.12.13" +scalaVersion := "2.13.5" -libraryDependencies += "org.specs2" %% "specs2" % "2.5" % "test" +libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test coverageMinimum := 80 coverageFailOnMinimum := true resolvers ++= { - if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots")) + if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) + Seq(Resolver.sonatypeRepo("snapshots")) else Seq.empty } diff --git a/src/sbt-test/scoverage/bad-coverage/src/test/scala/BadCoverageSpec.scala b/src/sbt-test/scoverage/bad-coverage/src/test/scala/BadCoverageSpec.scala index 16ce924b..1faa5e5a 100644 --- a/src/sbt-test/scoverage/bad-coverage/src/test/scala/BadCoverageSpec.scala +++ b/src/sbt-test/scoverage/bad-coverage/src/test/scala/BadCoverageSpec.scala @@ -1,13 +1,10 @@ -import org.specs2.mutable._ +import munit.FunSuite -/** - * Created by tbarke001c on 7/8/14. - */ -class BadCoverageSpec extends Specification { +/** Created by tbarke001c on 7/8/14. + */ +class BadCoverageSpec extends FunSuite { - "BadCoverage" should { - "sum two numbers" in { - BadCoverage.sum(1, 2) mustEqual 3 - } + test("BadCoverage should sum two numbers") { + assertEquals(BadCoverage.sum(1, 2), 3) } } diff --git a/src/sbt-test/scoverage/coverage-off/build.sbt b/src/sbt-test/scoverage/coverage-off/build.sbt index 30698311..de77b640 100644 --- a/src/sbt-test/scoverage/coverage-off/build.sbt +++ b/src/sbt-test/scoverage/coverage-off/build.sbt @@ -1,14 +1,15 @@ version := "0.1" -scalaVersion := "2.12.13" +scalaVersion := "2.13.5" -libraryDependencies += "org.specs2" %% "specs2" % "2.5" % "test" +libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test coverageMinimum := 80 coverageFailOnMinimum := true resolvers ++= { - if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots")) + if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) + Seq(Resolver.sonatypeRepo("snapshots")) else Seq.empty } diff --git a/src/sbt-test/scoverage/coverage-off/src/test/scala/GoodCoverageSpec.scala b/src/sbt-test/scoverage/coverage-off/src/test/scala/GoodCoverageSpec.scala index cbf6a70d..b1d4ddfc 100644 --- a/src/sbt-test/scoverage/coverage-off/src/test/scala/GoodCoverageSpec.scala +++ b/src/sbt-test/scoverage/coverage-off/src/test/scala/GoodCoverageSpec.scala @@ -1,13 +1,10 @@ -import org.specs2.mutable._ +import munit.FunSuite -/** - * Created by tbarke001c on 7/8/14. - */ -class GoodCoverageSpec extends Specification { +/** Created by tbarke001c on 7/8/14. + */ +class GoodCoverageSpec extends FunSuite { - "GoodCoverage" should { - "sum two numbers" in { - GoodCoverage.sum(1, 2) mustEqual 3 - } + test("GoodCoverage should sum two numvers") { + assertEquals(GoodCoverage.sum(1, 2), 3) } } diff --git a/src/sbt-test/scoverage/good-coverage/build.sbt b/src/sbt-test/scoverage/good-coverage/build.sbt index 30698311..de77b640 100644 --- a/src/sbt-test/scoverage/good-coverage/build.sbt +++ b/src/sbt-test/scoverage/good-coverage/build.sbt @@ -1,14 +1,15 @@ version := "0.1" -scalaVersion := "2.12.13" +scalaVersion := "2.13.5" -libraryDependencies += "org.specs2" %% "specs2" % "2.5" % "test" +libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test coverageMinimum := 80 coverageFailOnMinimum := true resolvers ++= { - if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots")) + if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) + Seq(Resolver.sonatypeRepo("snapshots")) else Seq.empty } diff --git a/src/sbt-test/scoverage/good-coverage/src/test/scala/GoodCoverageSpec.scala b/src/sbt-test/scoverage/good-coverage/src/test/scala/GoodCoverageSpec.scala index cbf6a70d..4e88b703 100644 --- a/src/sbt-test/scoverage/good-coverage/src/test/scala/GoodCoverageSpec.scala +++ b/src/sbt-test/scoverage/good-coverage/src/test/scala/GoodCoverageSpec.scala @@ -1,13 +1,10 @@ -import org.specs2.mutable._ +import munit.FunSuite -/** - * Created by tbarke001c on 7/8/14. - */ -class GoodCoverageSpec extends Specification { +/** Created by tbarke001c on 7/8/14. + */ +class GoodCoverageSpec extends FunSuite { - "GoodCoverage" should { - "sum two numbers" in { - GoodCoverage.sum(1, 2) mustEqual 3 - } + test("GoodCoverage should sum two numbers") { + assertEquals(GoodCoverage.sum(1, 2), 3) } } diff --git a/src/sbt-test/scoverage/preserve-set/build.sbt b/src/sbt-test/scoverage/preserve-set/build.sbt index 35e9bd25..cacb0594 100644 --- a/src/sbt-test/scoverage/preserve-set/build.sbt +++ b/src/sbt-test/scoverage/preserve-set/build.sbt @@ -2,29 +2,39 @@ import sbt.complete.DefaultParsers._ version := "0.1" -scalaVersion := "2.12.13" +scalaVersion := "2.13.5" -crossScalaVersions := Seq("2.12.13") +crossScalaVersions := Seq("2.13.5") -libraryDependencies += "org.specs2" %% "specs2" % "2.5" % "test" +libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test -val checkScalaVersion = inputKey[Unit]("Input task to compare the value of scalaVersion setting with a given input.") +val checkScalaVersion = inputKey[Unit]( + "Input task to compare the value of scalaVersion setting with a given input." +) checkScalaVersion := { val arg: String = (Space ~> StringBasic).parsed - if (scalaVersion.value != arg) sys.error(s"scalaVersion [${scalaVersion.value}] not equal to expected [$arg]") + if (scalaVersion.value != arg) + sys.error( + s"scalaVersion [${scalaVersion.value}] not equal to expected [$arg]" + ) () } -val checkScoverageEnabled = inputKey[Unit]("Input task to compare the value of coverageEnabled setting with a given input.") +val checkScoverageEnabled = inputKey[Unit]( + "Input task to compare the value of coverageEnabled setting with a given input." +) checkScoverageEnabled := { val arg: String = (Space ~> StringBasic).parsed - if (coverageEnabled.value.toString != arg) sys.error(s"coverageEnabled [${coverageEnabled.value}] not equal to expected [$arg]") + if (coverageEnabled.value.toString != arg) + sys.error( + s"coverageEnabled [${coverageEnabled.value}] not equal to expected [$arg]" + ) () } - resolvers ++= { - if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots")) + if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) + Seq(Resolver.sonatypeRepo("snapshots")) else Seq.empty } diff --git a/src/sbt-test/scoverage/preserve-set/src/test/scala/PreserveSetSpec.scala b/src/sbt-test/scoverage/preserve-set/src/test/scala/PreserveSetSpec.scala index a7722e39..c4c26010 100644 --- a/src/sbt-test/scoverage/preserve-set/src/test/scala/PreserveSetSpec.scala +++ b/src/sbt-test/scoverage/preserve-set/src/test/scala/PreserveSetSpec.scala @@ -1,10 +1,8 @@ -import org.specs2.mutable._ +import munit.FunSuite -class PreserveSetSpec extends Specification { +class PreserveSetSpec extends FunSuite { - "PreserveSet" should { - "sum two numbers" in { - PreserveSet.sum(1, 2) mustEqual 3 - } + test("PreserveSet should sum two numbers") { + assertEquals(PreserveSet.sum(1, 2), 3) } } diff --git a/src/sbt-test/scoverage/preserve-set/test b/src/sbt-test/scoverage/preserve-set/test index 349f1853..1d8ab737 100644 --- a/src/sbt-test/scoverage/preserve-set/test +++ b/src/sbt-test/scoverage/preserve-set/test @@ -1,8 +1,8 @@ # check scalaVersion setting -> checkScalaVersion "2.12.13" +> checkScalaVersion "2.13.5" > checkScoverageEnabled "false" > coverage > checkScoverageEnabled "true" > coverageOff -> checkScalaVersion "2.12.13" -> checkScoverageEnabled "false" \ No newline at end of file +> checkScalaVersion "2.13.5" +> checkScoverageEnabled "false" diff --git a/src/sbt-test/scoverage/scalac-plugin-version/build.sbt b/src/sbt-test/scoverage/scalac-plugin-version/build.sbt index f5e663f7..df7f1c7c 100644 --- a/src/sbt-test/scoverage/scalac-plugin-version/build.sbt +++ b/src/sbt-test/scoverage/scalac-plugin-version/build.sbt @@ -5,10 +5,13 @@ lazy val root = (project in file(".")).settings( TaskKey[Unit]("check") := { assert( libraryDependencies.value.count(module => - module.organization == "org.scoverage" && module.revision == "1.3.0") == 2) + module.organization == "org.scoverage" && module.revision == "1.3.0" + ) == 2 + ) } resolvers ++= { - if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots")) + if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) + Seq(Resolver.sonatypeRepo("snapshots")) else Seq.empty } diff --git a/src/sbt-test/scoverage/scalajs/build.sbt b/src/sbt-test/scoverage/scalajs/build.sbt index 4b1074b5..59494e18 100644 --- a/src/sbt-test/scoverage/scalajs/build.sbt +++ b/src/sbt-test/scoverage/scalajs/build.sbt @@ -3,19 +3,19 @@ import sbtcrossproject.CrossType lazy val root = (project in file(".")).aggregate(crossJS, crossJVM) -lazy val cross = CrossProject("sjstest", file("sjstest"))(JVMPlatform, JSPlatform) - .crossType(CrossType.Full) - .settings( - scalaVersion := "2.12.13", - libraryDependencies ++= Seq( - "org.scalatest" %% "scalatest" % "3.2.8" % "test" +lazy val cross = + CrossProject("sjstest", file("sjstest"))(JVMPlatform, JSPlatform) + .crossType(CrossType.Full) + .settings( + scalaVersion := "2.13.5", + libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test ) - ) lazy val crossJS = cross.js lazy val crossJVM = cross.jvm ThisBuild / resolvers ++= { - if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots")) + if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) + Seq(Resolver.sonatypeRepo("snapshots")) else Seq.empty } diff --git a/src/sbt-test/scoverage/scalajs/sjstest/js/src/test/scala/JsTest.scala b/src/sbt-test/scoverage/scalajs/sjstest/js/src/test/scala/JsTest.scala index d11e4236..c7d3eed4 100644 --- a/src/sbt-test/scoverage/scalajs/sjstest/js/src/test/scala/JsTest.scala +++ b/src/sbt-test/scoverage/scalajs/sjstest/js/src/test/scala/JsTest.scala @@ -1,11 +1,9 @@ -import org.scalatest.flatspec.AnyFlatSpec -import org.scalatest.matchers.should.Matchers +import munit.FunSuite -class JsTest extends AnyFlatSpec with Matchers { +class JsTest extends FunSuite { - "JS UnderTest" should "work on JS" in { - UnderTest.jsMethod shouldBe "js" + test("JS UnderTest should work on JS") { + assertEquals(UnderTest.jsMethod, "js") } } - diff --git a/src/sbt-test/scoverage/scalajs/sjstest/jvm/src/test/scala/JvmTest.scala b/src/sbt-test/scoverage/scalajs/sjstest/jvm/src/test/scala/JvmTest.scala index be2bc649..b5f3ed9e 100644 --- a/src/sbt-test/scoverage/scalajs/sjstest/jvm/src/test/scala/JvmTest.scala +++ b/src/sbt-test/scoverage/scalajs/sjstest/jvm/src/test/scala/JvmTest.scala @@ -1,11 +1,9 @@ -import org.scalatest.flatspec.AnyFlatSpec -import org.scalatest.matchers.should.Matchers +import munit.FunSuite -class JvmTest extends AnyFlatSpec with Matchers { +class JvmTest extends FunSuite { - "JVM UnderTest" should "work on JVM" in { - UnderTest.jvmMethod shouldBe "jvm" + test("JVM UnderTest work on JVM") { + assertEquals(UnderTest.jvmMethod, "jvm") } } - diff --git a/src/sbt-test/scoverage/scalajs/sjstest/shared/src/test/scala/SharedTest.scala b/src/sbt-test/scoverage/scalajs/sjstest/shared/src/test/scala/SharedTest.scala index 8336af72..bbc145ae 100644 --- a/src/sbt-test/scoverage/scalajs/sjstest/shared/src/test/scala/SharedTest.scala +++ b/src/sbt-test/scoverage/scalajs/sjstest/shared/src/test/scala/SharedTest.scala @@ -1,10 +1,9 @@ -import org.scalatest.flatspec.AnyFlatSpec -import org.scalatest.matchers.should.Matchers +import munit.FunSuite -class SharedTest extends AnyFlatSpec with Matchers { +class SharedTest extends FunSuite { - "Shared UnderTest" should "return where it works" in { - UnderTest.onJsAndJvm shouldBe "js and jvm" + test("Shared UnderTest return where it works") { + assertEquals(UnderTest.onJsAndJvm, "js and jvm") } } diff --git a/src/sbt-test/scoverage/scalajs/test b/src/sbt-test/scoverage/scalajs/test index 6e6be49f..f6c10798 100644 --- a/src/sbt-test/scoverage/scalajs/test +++ b/src/sbt-test/scoverage/scalajs/test @@ -3,9 +3,9 @@ > coverage > test # There should be scoverage-data directory -$ exists sjstest/js/target/scala-2.12/scoverage-data -$ exists sjstest/jvm/target/scala-2.12/scoverage-data +$ exists sjstest/js/target/scala-2.13/scoverage-data +$ exists sjstest/jvm/target/scala-2.13/scoverage-data > coverageReport # There should be scoverage-report directory -$ exists sjstest/js/target/scala-2.12/scoverage-report -$ exists sjstest/jvm/target/scala-2.12/scoverage-report +$ exists sjstest/js/target/scala-2.13/scoverage-report +$ exists sjstest/jvm/target/scala-2.13/scoverage-report From fdc20aa78cf71cded27e09e290c0b4fbe0f075f5 Mon Sep 17 00:00:00 2001 From: Albert Meltzer Date: Sat, 8 May 2021 08:41:55 -0700 Subject: [PATCH 30/49] Coverage minima: add more fine-grained control Along with existing statement minimum, add branch minimum. Also, include this pair of control at the package and file level. --- README.md | 7 +- .../scala/scoverage/CoverageMinimum.scala | 105 ++++++++++++++++++ src/main/scala/scoverage/ScoverageKeys.scala | 20 +++- .../scala/scoverage/ScoverageSbtPlugin.scala | 54 ++------- .../bad-coverage-file-branch/build.sbt | 14 +++ .../project/plugins.sbt | 14 +++ .../src/main/scala/one/BadCoverage.scala | 9 ++ .../src/main/scala/two/BadCoverage.scala | 9 ++ .../src/test/scala/BadCoverageSpec.scala | 16 +++ .../scoverage/bad-coverage-file-branch/test | 5 + .../bad-coverage-file-stmt/build.sbt | 14 +++ .../project/plugins.sbt | 14 +++ .../src/main/scala/one/BadCoverage.scala | 9 ++ .../src/main/scala/two/BadCoverage.scala | 9 ++ .../src/test/scala/BadCoverageSpec.scala | 15 +++ .../scoverage/bad-coverage-file-stmt/test | 5 + .../bad-coverage-package-branch/build.sbt | 14 +++ .../project/plugins.sbt | 14 +++ .../src/main/scala/one/BadCoverage.scala | 9 ++ .../src/main/scala/two/BadCoverage.scala | 9 ++ .../src/test/scala/BadCoverageSpec.scala | 16 +++ .../bad-coverage-package-branch/test | 5 + .../bad-coverage-package-stmt/build.sbt | 14 +++ .../project/plugins.sbt | 14 +++ .../src/main/scala/one/BadCoverage.scala | 9 ++ .../src/main/scala/two/BadCoverage.scala | 9 ++ .../src/test/scala/BadCoverageSpec.scala | 15 +++ .../scoverage/bad-coverage-package-stmt/test | 5 + .../bad-coverage-total-branch/build.sbt | 14 +++ .../project/plugins.sbt | 14 +++ .../src/main/scala/BadCoverage.scala | 7 ++ .../src/test/scala/BadCoverageSpec.scala | 10 ++ .../scoverage/bad-coverage-total-branch/test | 5 + .../bad-coverage-total-stmt/build.sbt | 14 +++ .../project/plugins.sbt | 14 +++ .../src/main/scala/one/BadCoverage.scala | 9 ++ .../src/main/scala/two/BadCoverage.scala | 9 ++ .../src/test/scala/BadCoverageSpec.scala | 11 ++ .../scoverage/bad-coverage-total-stmt/test | 5 + src/sbt-test/scoverage/coverage-off/build.sbt | 6 + .../src/main/scala/GoodCoverage.scala | 5 +- .../src/main/scala/two/GoodCoverage.scala | 9 ++ .../src/test/scala/GoodCoverageSpec.scala | 11 +- .../scoverage/good-coverage/build.sbt | 6 + .../src/main/scala/GoodCoverage.scala | 5 +- .../src/main/scala/two/GoodCoverage.scala | 9 ++ .../src/test/scala/GoodCoverageSpec.scala | 9 ++ 47 files changed, 574 insertions(+), 50 deletions(-) create mode 100644 src/main/scala/scoverage/CoverageMinimum.scala create mode 100644 src/sbt-test/scoverage/bad-coverage-file-branch/build.sbt create mode 100644 src/sbt-test/scoverage/bad-coverage-file-branch/project/plugins.sbt create mode 100644 src/sbt-test/scoverage/bad-coverage-file-branch/src/main/scala/one/BadCoverage.scala create mode 100644 src/sbt-test/scoverage/bad-coverage-file-branch/src/main/scala/two/BadCoverage.scala create mode 100644 src/sbt-test/scoverage/bad-coverage-file-branch/src/test/scala/BadCoverageSpec.scala create mode 100644 src/sbt-test/scoverage/bad-coverage-file-branch/test create mode 100644 src/sbt-test/scoverage/bad-coverage-file-stmt/build.sbt create mode 100644 src/sbt-test/scoverage/bad-coverage-file-stmt/project/plugins.sbt create mode 100644 src/sbt-test/scoverage/bad-coverage-file-stmt/src/main/scala/one/BadCoverage.scala create mode 100644 src/sbt-test/scoverage/bad-coverage-file-stmt/src/main/scala/two/BadCoverage.scala create mode 100644 src/sbt-test/scoverage/bad-coverage-file-stmt/src/test/scala/BadCoverageSpec.scala create mode 100644 src/sbt-test/scoverage/bad-coverage-file-stmt/test create mode 100644 src/sbt-test/scoverage/bad-coverage-package-branch/build.sbt create mode 100644 src/sbt-test/scoverage/bad-coverage-package-branch/project/plugins.sbt create mode 100644 src/sbt-test/scoverage/bad-coverage-package-branch/src/main/scala/one/BadCoverage.scala create mode 100644 src/sbt-test/scoverage/bad-coverage-package-branch/src/main/scala/two/BadCoverage.scala create mode 100644 src/sbt-test/scoverage/bad-coverage-package-branch/src/test/scala/BadCoverageSpec.scala create mode 100644 src/sbt-test/scoverage/bad-coverage-package-branch/test create mode 100644 src/sbt-test/scoverage/bad-coverage-package-stmt/build.sbt create mode 100644 src/sbt-test/scoverage/bad-coverage-package-stmt/project/plugins.sbt create mode 100644 src/sbt-test/scoverage/bad-coverage-package-stmt/src/main/scala/one/BadCoverage.scala create mode 100644 src/sbt-test/scoverage/bad-coverage-package-stmt/src/main/scala/two/BadCoverage.scala create mode 100644 src/sbt-test/scoverage/bad-coverage-package-stmt/src/test/scala/BadCoverageSpec.scala create mode 100644 src/sbt-test/scoverage/bad-coverage-package-stmt/test create mode 100644 src/sbt-test/scoverage/bad-coverage-total-branch/build.sbt create mode 100644 src/sbt-test/scoverage/bad-coverage-total-branch/project/plugins.sbt create mode 100644 src/sbt-test/scoverage/bad-coverage-total-branch/src/main/scala/BadCoverage.scala create mode 100644 src/sbt-test/scoverage/bad-coverage-total-branch/src/test/scala/BadCoverageSpec.scala create mode 100644 src/sbt-test/scoverage/bad-coverage-total-branch/test create mode 100644 src/sbt-test/scoverage/bad-coverage-total-stmt/build.sbt create mode 100644 src/sbt-test/scoverage/bad-coverage-total-stmt/project/plugins.sbt create mode 100644 src/sbt-test/scoverage/bad-coverage-total-stmt/src/main/scala/one/BadCoverage.scala create mode 100644 src/sbt-test/scoverage/bad-coverage-total-stmt/src/main/scala/two/BadCoverage.scala create mode 100644 src/sbt-test/scoverage/bad-coverage-total-stmt/src/test/scala/BadCoverageSpec.scala create mode 100644 src/sbt-test/scoverage/bad-coverage-total-stmt/test create mode 100644 src/sbt-test/scoverage/coverage-off/src/main/scala/two/GoodCoverage.scala create mode 100644 src/sbt-test/scoverage/good-coverage/src/main/scala/two/GoodCoverage.scala diff --git a/README.md b/README.md index b4780f94..ebc88679 100644 --- a/README.md +++ b/README.md @@ -89,8 +89,13 @@ coverage report. Based on minimum coverage, you can fail the build with the following keys: ```scala -coverageMinimum := 80 coverageFailOnMinimum := true +coverageMinimumStmtTotal := 90 +coverageMinimumBranchTotal := 90 +coverageMinimumStmtPerPackage := 90 +coverageMinimumBranchPerPackage := 85 +coverageMinimumStmtPerFile := 85 +coverageMinimumBranchPerFile := 80 ``` These settings will be enforced when the reports are generated. If you generate diff --git a/src/main/scala/scoverage/CoverageMinimum.scala b/src/main/scala/scoverage/CoverageMinimum.scala new file mode 100644 index 00000000..be05c872 --- /dev/null +++ b/src/main/scala/scoverage/CoverageMinimum.scala @@ -0,0 +1,105 @@ +package scoverage + +import sbt._ +import scoverage.DoubleFormat.twoFractionDigits + +case class CoverageMinimum( + statement: Double, + branch: Double +) { + def checkCoverage( + metrics: CoverageMetrics, + metric: String + )(implicit log: Logger): Boolean = { + CoverageMinimum.checkCoverage( + s"Branch:$metric", + branch, + metrics.branchCoveragePercent + ) && + CoverageMinimum.checkCoverage( + s"Stmt:$metric", + statement, + metrics.statementCoveragePercent + ) + } + +} + +object CoverageMinimum { + + def checkCoverage( + metric: String, + min: Double, + cper: Double + )(implicit log: Logger): Boolean = { + // check for default minimum + min <= 0 || { + def is100(d: Double) = Math.abs(100 - d) <= 0.00001 + + if (is100(min) && is100(cper)) { + log.debug(s"100% Coverage: $metric") + true + } else { + val ok: Boolean = min <= cper + def minfmt = twoFractionDigits(min) + def cfmt = twoFractionDigits(cper) + if (ok) { + log.debug(s"Coverage is above minimum [$cfmt% >= $minfmt%]: $metric") + } else { + log.error(s"Coverage is below minimum [$cfmt% < $minfmt%]: $metric") + } + ok + } + } + } + + case class All( + total: CoverageMinimum, + perPackage: CoverageMinimum, + perFile: CoverageMinimum + ) { + def checkCoverage( + coverage: Coverage, + failOnMin: Boolean + )(implicit log: Logger): Unit = { + val ok: Boolean = total.checkCoverage(coverage, "Total") && + coverage.packages.forall(pkg => + perPackage.checkCoverage(pkg, s"Package:${pkg.name}") + ) && + coverage.files.forall(file => + perFile.checkCoverage(file, s"File:${file.filename}") + ) + + if (!ok && failOnMin) + throw new RuntimeException("Coverage minimum was not reached") + + log.info( + s"All done. Coverage was" + + s" stmt=[${coverage.statementCoverageFormatted}%]" + + s" branch=[${coverage.branchCoverageFormatted}]" + ) + } + + } + + def all = Def.setting { + import ScoverageKeys._ + val stmtTotal = + math.max(coverageMinimum.value, coverageMinimumStmtTotal.value) + All( + total = CoverageMinimum( + statement = stmtTotal, + branch = coverageMinimumBranchTotal.value + ), + perPackage = CoverageMinimum( + statement = coverageMinimumStmtPerPackage.value, + branch = coverageMinimumBranchPerPackage.value + ), + perFile = CoverageMinimum( + statement = coverageMinimumStmtPerFile.value, + branch = coverageMinimumBranchPerFile.value + ) + ) + } + +} diff --git a/src/main/scala/scoverage/ScoverageKeys.scala b/src/main/scala/scoverage/ScoverageKeys.scala index 3a6cd203..f846b277 100644 --- a/src/main/scala/scoverage/ScoverageKeys.scala +++ b/src/main/scala/scoverage/ScoverageKeys.scala @@ -11,8 +11,6 @@ object ScoverageKeys { lazy val coverageAggregate = taskKey[Unit]("aggregate reports from subprojects") lazy val coverageExcludedPackages = settingKey[String]("regex for excluded packages") lazy val coverageExcludedFiles = settingKey[String]("regex for excluded file paths") - lazy val coverageMinimum = settingKey[Double]("scoverage-minimum-coverage") - lazy val coverageFailOnMinimum = settingKey[Boolean]("if coverage is less than this value then fail build") lazy val coverageHighlighting = settingKey[Boolean]("enables range positioning for highlighting") lazy val coverageOutputCobertura = settingKey[Boolean]("enables cobertura XML report generation") lazy val coverageOutputXML = settingKey[Boolean]("enables xml report generation") @@ -21,4 +19,22 @@ object ScoverageKeys { lazy val coverageOutputTeamCity = settingKey[Boolean]("turn on teamcity reporting") lazy val coverageScalacPluginVersion = settingKey[String]("version of scalac-scoverage-plugin to use") // format: on + + @deprecated("Use coverageMinimumStmtTotal instead", "v1.8.0") + lazy val coverageMinimum = + settingKey[Double]("see coverageMinimumStmtTotal") + lazy val coverageMinimumStmtTotal = + settingKey[Double]("scoverage minimum coverage: statement total") + lazy val coverageMinimumBranchTotal = + settingKey[Double]("scoverage minimum coverage: branch total") + lazy val coverageMinimumStmtPerPackage = + settingKey[Double]("scoverage minimum coverage: statement per package") + lazy val coverageMinimumBranchPerPackage = + settingKey[Double]("scoverage minimum coverage: branch per package") + lazy val coverageMinimumStmtPerFile = + settingKey[Double]("scoverage minimum coverage: statement per file") + lazy val coverageMinimumBranchPerFile = + settingKey[Double]("scoverage minimum coverage: branch per file") + lazy val coverageFailOnMinimum = + settingKey[Boolean]("if coverage is less than minimum then fail build") } diff --git a/src/main/scala/scoverage/ScoverageSbtPlugin.scala b/src/main/scala/scoverage/ScoverageSbtPlugin.scala index 9e74868a..07abe634 100644 --- a/src/main/scala/scoverage/ScoverageSbtPlugin.scala +++ b/src/main/scala/scoverage/ScoverageSbtPlugin.scala @@ -35,6 +35,12 @@ object ScoverageSbtPlugin extends AutoPlugin { coverageExcludedPackages := "", coverageExcludedFiles := "", coverageMinimum := 0, // default is no minimum + coverageMinimumStmtTotal := 0, + coverageMinimumBranchTotal := 0, + coverageMinimumStmtPerPackage := 0, + coverageMinimumBranchPerPackage := 0, + coverageMinimumStmtPerFile := 0, + coverageMinimumBranchPerFile := 0, coverageFailOnMinimum := false, coverageHighlighting := true, coverageOutputXML := true, @@ -131,7 +137,7 @@ object ScoverageSbtPlugin extends AutoPlugin { private lazy val coverageReport0 = Def.task { val target = crossTarget.value - val log = streams.value.log + implicit val log = streams.value.log log.info(s"Waiting for measurement data to sync...") Thread.sleep( @@ -153,18 +159,14 @@ object ScoverageSbtPlugin extends AutoPlugin { log ) - checkCoverage( - cov, - log, - coverageMinimum.value, - coverageFailOnMinimum.value - ) + CoverageMinimum.all.value + .checkCoverage(cov, coverageFailOnMinimum.value) case None => log.warn("No coverage data, skipping reports") } } private lazy val coverageAggregate0 = Def.task { - val log = streams.value.log + implicit val log = streams.value.log log.info(s"Aggregating coverage from subprojects...") val dataDirs = crossTarget @@ -187,12 +189,8 @@ object ScoverageSbtPlugin extends AutoPlugin { val cfmt = cov.statementCoverageFormatted log.info(s"Aggregation complete. Coverage was [$cfmt]") - checkCoverage( - cov, - log, - coverageMinimum.value, - coverageFailOnMinimum.value - ) + CoverageMinimum.all.value + .checkCoverage(cov, coverageFailOnMinimum.value) case None => log.info("No subproject data to aggregate, skipping reports") } @@ -326,34 +324,6 @@ object ScoverageSbtPlugin extends AutoPlugin { } } - private def checkCoverage( - coverage: Coverage, - log: Logger, - min: Double, - failOnMin: Boolean - ): Unit = { - - val cper = coverage.statementCoveragePercent - val cfmt = coverage.statementCoverageFormatted - - // check for default minimum - if (min > 0) { - def is100(d: Double) = Math.abs(100 - d) <= 0.00001 - - if (is100(min) && is100(cper)) { - log.info(s"100% Coverage !") - } else if (min > cper) { - log.error(s"Coverage is below minimum [$cfmt% < $min%]") - if (failOnMin) - throw new RuntimeException("Coverage minimum was not reached") - } else { - log.info(s"Coverage is above minimum [$cfmt% > $min%]") - } - } - - log.info(s"All done. Coverage was [$cfmt%]") - } - private def sourceEncoding(scalacOptions: Seq[String]): Option[String] = { val i = scalacOptions.indexOf("-encoding") + 1 if (i > 0 && i < scalacOptions.length) Some(scalacOptions(i)) else None diff --git a/src/sbt-test/scoverage/bad-coverage-file-branch/build.sbt b/src/sbt-test/scoverage/bad-coverage-file-branch/build.sbt new file mode 100644 index 00000000..36d96ac6 --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-file-branch/build.sbt @@ -0,0 +1,14 @@ +version := "0.1" + +scalaVersion := "2.13.5" + +libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test + +coverageMinimumBranchPerFile := 80 + +coverageFailOnMinimum := true + +resolvers ++= { + if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots")) + else Seq.empty +} diff --git a/src/sbt-test/scoverage/bad-coverage-file-branch/project/plugins.sbt b/src/sbt-test/scoverage/bad-coverage-file-branch/project/plugins.sbt new file mode 100644 index 00000000..8f2837b3 --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-file-branch/project/plugins.sbt @@ -0,0 +1,14 @@ +val pluginVersion = sys.props.getOrElse( + "plugin.version", + throw new RuntimeException( + """|The system property 'plugin.version' is not defined. + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) + +addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) + +resolvers ++= { + if (pluginVersion.endsWith("-SNAPSHOT")) + Seq(Resolver.sonatypeRepo("snapshots")) + else + Seq.empty +} diff --git a/src/sbt-test/scoverage/bad-coverage-file-branch/src/main/scala/one/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage-file-branch/src/main/scala/one/BadCoverage.scala new file mode 100644 index 00000000..300ec10c --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-file-branch/src/main/scala/one/BadCoverage.scala @@ -0,0 +1,9 @@ +package one + +object BadCoverage { + + def sum(num1: Int, num2: Int) = { + if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2 + } + +} diff --git a/src/sbt-test/scoverage/bad-coverage-file-branch/src/main/scala/two/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage-file-branch/src/main/scala/two/BadCoverage.scala new file mode 100644 index 00000000..3ebc31da --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-file-branch/src/main/scala/two/BadCoverage.scala @@ -0,0 +1,9 @@ +package two + +object BadCoverage { + + def sum(num1: Int, num2: Int) = { + if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2 + } + +} diff --git a/src/sbt-test/scoverage/bad-coverage-file-branch/src/test/scala/BadCoverageSpec.scala b/src/sbt-test/scoverage/bad-coverage-file-branch/src/test/scala/BadCoverageSpec.scala new file mode 100644 index 00000000..801c7b43 --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-file-branch/src/test/scala/BadCoverageSpec.scala @@ -0,0 +1,16 @@ +import munit.FunSuite + +class BadCoverageSpec extends FunSuite { + + test("one.BadCoverage should sum two numbers") { + assertEquals(one.BadCoverage.sum(1, 2), 3) + assertEquals(one.BadCoverage.sum(0, 3), 3) + assertEquals(one.BadCoverage.sum(3, 0), 3) + } + + test("two.BadCoverage should sum two numbers") { + assertEquals(two.BadCoverage.sum(1, 2), 3) + assertEquals(two.BadCoverage.sum(0, 3), 3) + } + +} diff --git a/src/sbt-test/scoverage/bad-coverage-file-branch/test b/src/sbt-test/scoverage/bad-coverage-file-branch/test new file mode 100644 index 00000000..45cbbb60 --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-file-branch/test @@ -0,0 +1,5 @@ +# run scoverage +> clean +> coverage +> test +-> coverageReport diff --git a/src/sbt-test/scoverage/bad-coverage-file-stmt/build.sbt b/src/sbt-test/scoverage/bad-coverage-file-stmt/build.sbt new file mode 100644 index 00000000..291ad6c8 --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-file-stmt/build.sbt @@ -0,0 +1,14 @@ +version := "0.1" + +scalaVersion := "2.13.5" + +libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test + +coverageMinimumStmtPerFile := 90 + +coverageFailOnMinimum := true + +resolvers ++= { + if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots")) + else Seq.empty +} diff --git a/src/sbt-test/scoverage/bad-coverage-file-stmt/project/plugins.sbt b/src/sbt-test/scoverage/bad-coverage-file-stmt/project/plugins.sbt new file mode 100644 index 00000000..8f2837b3 --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-file-stmt/project/plugins.sbt @@ -0,0 +1,14 @@ +val pluginVersion = sys.props.getOrElse( + "plugin.version", + throw new RuntimeException( + """|The system property 'plugin.version' is not defined. + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) + +addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) + +resolvers ++= { + if (pluginVersion.endsWith("-SNAPSHOT")) + Seq(Resolver.sonatypeRepo("snapshots")) + else + Seq.empty +} diff --git a/src/sbt-test/scoverage/bad-coverage-file-stmt/src/main/scala/one/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage-file-stmt/src/main/scala/one/BadCoverage.scala new file mode 100644 index 00000000..300ec10c --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-file-stmt/src/main/scala/one/BadCoverage.scala @@ -0,0 +1,9 @@ +package one + +object BadCoverage { + + def sum(num1: Int, num2: Int) = { + if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2 + } + +} diff --git a/src/sbt-test/scoverage/bad-coverage-file-stmt/src/main/scala/two/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage-file-stmt/src/main/scala/two/BadCoverage.scala new file mode 100644 index 00000000..3ebc31da --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-file-stmt/src/main/scala/two/BadCoverage.scala @@ -0,0 +1,9 @@ +package two + +object BadCoverage { + + def sum(num1: Int, num2: Int) = { + if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2 + } + +} diff --git a/src/sbt-test/scoverage/bad-coverage-file-stmt/src/test/scala/BadCoverageSpec.scala b/src/sbt-test/scoverage/bad-coverage-file-stmt/src/test/scala/BadCoverageSpec.scala new file mode 100644 index 00000000..e6f4c197 --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-file-stmt/src/test/scala/BadCoverageSpec.scala @@ -0,0 +1,15 @@ +import munit.FunSuite + +class BadCoverageSpec extends FunSuite { + + test("one.BadCoverage should sum two numbers") { + assertEquals(one.BadCoverage.sum(1, 2), 3) + assertEquals(one.BadCoverage.sum(0, 3), 3) + assertEquals(one.BadCoverage.sum(3, 0), 3) + } + + test("two.BadCoverage should sum two numbers") { + assertEquals(two.BadCoverage.sum(1, 2), 3) + } + +} diff --git a/src/sbt-test/scoverage/bad-coverage-file-stmt/test b/src/sbt-test/scoverage/bad-coverage-file-stmt/test new file mode 100644 index 00000000..45cbbb60 --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-file-stmt/test @@ -0,0 +1,5 @@ +# run scoverage +> clean +> coverage +> test +-> coverageReport diff --git a/src/sbt-test/scoverage/bad-coverage-package-branch/build.sbt b/src/sbt-test/scoverage/bad-coverage-package-branch/build.sbt new file mode 100644 index 00000000..333d81eb --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-package-branch/build.sbt @@ -0,0 +1,14 @@ +version := "0.1" + +scalaVersion := "2.13.5" + +libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test + +coverageMinimumBranchPerPackage := 80 + +coverageFailOnMinimum := true + +resolvers ++= { + if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots")) + else Seq.empty +} diff --git a/src/sbt-test/scoverage/bad-coverage-package-branch/project/plugins.sbt b/src/sbt-test/scoverage/bad-coverage-package-branch/project/plugins.sbt new file mode 100644 index 00000000..8f2837b3 --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-package-branch/project/plugins.sbt @@ -0,0 +1,14 @@ +val pluginVersion = sys.props.getOrElse( + "plugin.version", + throw new RuntimeException( + """|The system property 'plugin.version' is not defined. + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) + +addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) + +resolvers ++= { + if (pluginVersion.endsWith("-SNAPSHOT")) + Seq(Resolver.sonatypeRepo("snapshots")) + else + Seq.empty +} diff --git a/src/sbt-test/scoverage/bad-coverage-package-branch/src/main/scala/one/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage-package-branch/src/main/scala/one/BadCoverage.scala new file mode 100644 index 00000000..300ec10c --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-package-branch/src/main/scala/one/BadCoverage.scala @@ -0,0 +1,9 @@ +package one + +object BadCoverage { + + def sum(num1: Int, num2: Int) = { + if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2 + } + +} diff --git a/src/sbt-test/scoverage/bad-coverage-package-branch/src/main/scala/two/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage-package-branch/src/main/scala/two/BadCoverage.scala new file mode 100644 index 00000000..3ebc31da --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-package-branch/src/main/scala/two/BadCoverage.scala @@ -0,0 +1,9 @@ +package two + +object BadCoverage { + + def sum(num1: Int, num2: Int) = { + if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2 + } + +} diff --git a/src/sbt-test/scoverage/bad-coverage-package-branch/src/test/scala/BadCoverageSpec.scala b/src/sbt-test/scoverage/bad-coverage-package-branch/src/test/scala/BadCoverageSpec.scala new file mode 100644 index 00000000..801c7b43 --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-package-branch/src/test/scala/BadCoverageSpec.scala @@ -0,0 +1,16 @@ +import munit.FunSuite + +class BadCoverageSpec extends FunSuite { + + test("one.BadCoverage should sum two numbers") { + assertEquals(one.BadCoverage.sum(1, 2), 3) + assertEquals(one.BadCoverage.sum(0, 3), 3) + assertEquals(one.BadCoverage.sum(3, 0), 3) + } + + test("two.BadCoverage should sum two numbers") { + assertEquals(two.BadCoverage.sum(1, 2), 3) + assertEquals(two.BadCoverage.sum(0, 3), 3) + } + +} diff --git a/src/sbt-test/scoverage/bad-coverage-package-branch/test b/src/sbt-test/scoverage/bad-coverage-package-branch/test new file mode 100644 index 00000000..45cbbb60 --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-package-branch/test @@ -0,0 +1,5 @@ +# run scoverage +> clean +> coverage +> test +-> coverageReport diff --git a/src/sbt-test/scoverage/bad-coverage-package-stmt/build.sbt b/src/sbt-test/scoverage/bad-coverage-package-stmt/build.sbt new file mode 100644 index 00000000..c9f662cc --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-package-stmt/build.sbt @@ -0,0 +1,14 @@ +version := "0.1" + +scalaVersion := "2.13.5" + +libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test + +coverageMinimumStmtPerPackage := 80 + +coverageFailOnMinimum := true + +resolvers ++= { + if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots")) + else Seq.empty +} diff --git a/src/sbt-test/scoverage/bad-coverage-package-stmt/project/plugins.sbt b/src/sbt-test/scoverage/bad-coverage-package-stmt/project/plugins.sbt new file mode 100644 index 00000000..8f2837b3 --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-package-stmt/project/plugins.sbt @@ -0,0 +1,14 @@ +val pluginVersion = sys.props.getOrElse( + "plugin.version", + throw new RuntimeException( + """|The system property 'plugin.version' is not defined. + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) + +addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) + +resolvers ++= { + if (pluginVersion.endsWith("-SNAPSHOT")) + Seq(Resolver.sonatypeRepo("snapshots")) + else + Seq.empty +} diff --git a/src/sbt-test/scoverage/bad-coverage-package-stmt/src/main/scala/one/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage-package-stmt/src/main/scala/one/BadCoverage.scala new file mode 100644 index 00000000..300ec10c --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-package-stmt/src/main/scala/one/BadCoverage.scala @@ -0,0 +1,9 @@ +package one + +object BadCoverage { + + def sum(num1: Int, num2: Int) = { + if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2 + } + +} diff --git a/src/sbt-test/scoverage/bad-coverage-package-stmt/src/main/scala/two/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage-package-stmt/src/main/scala/two/BadCoverage.scala new file mode 100644 index 00000000..3ebc31da --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-package-stmt/src/main/scala/two/BadCoverage.scala @@ -0,0 +1,9 @@ +package two + +object BadCoverage { + + def sum(num1: Int, num2: Int) = { + if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2 + } + +} diff --git a/src/sbt-test/scoverage/bad-coverage-package-stmt/src/test/scala/BadCoverageSpec.scala b/src/sbt-test/scoverage/bad-coverage-package-stmt/src/test/scala/BadCoverageSpec.scala new file mode 100644 index 00000000..e6f4c197 --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-package-stmt/src/test/scala/BadCoverageSpec.scala @@ -0,0 +1,15 @@ +import munit.FunSuite + +class BadCoverageSpec extends FunSuite { + + test("one.BadCoverage should sum two numbers") { + assertEquals(one.BadCoverage.sum(1, 2), 3) + assertEquals(one.BadCoverage.sum(0, 3), 3) + assertEquals(one.BadCoverage.sum(3, 0), 3) + } + + test("two.BadCoverage should sum two numbers") { + assertEquals(two.BadCoverage.sum(1, 2), 3) + } + +} diff --git a/src/sbt-test/scoverage/bad-coverage-package-stmt/test b/src/sbt-test/scoverage/bad-coverage-package-stmt/test new file mode 100644 index 00000000..45cbbb60 --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-package-stmt/test @@ -0,0 +1,5 @@ +# run scoverage +> clean +> coverage +> test +-> coverageReport diff --git a/src/sbt-test/scoverage/bad-coverage-total-branch/build.sbt b/src/sbt-test/scoverage/bad-coverage-total-branch/build.sbt new file mode 100644 index 00000000..8b61d1bb --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-total-branch/build.sbt @@ -0,0 +1,14 @@ +version := "0.1" + +scalaVersion := "2.13.5" + +libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test + +coverageMinimumBranchTotal := 80 + +coverageFailOnMinimum := true + +resolvers ++= { + if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots")) + else Seq.empty +} diff --git a/src/sbt-test/scoverage/bad-coverage-total-branch/project/plugins.sbt b/src/sbt-test/scoverage/bad-coverage-total-branch/project/plugins.sbt new file mode 100644 index 00000000..8f2837b3 --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-total-branch/project/plugins.sbt @@ -0,0 +1,14 @@ +val pluginVersion = sys.props.getOrElse( + "plugin.version", + throw new RuntimeException( + """|The system property 'plugin.version' is not defined. + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) + +addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) + +resolvers ++= { + if (pluginVersion.endsWith("-SNAPSHOT")) + Seq(Resolver.sonatypeRepo("snapshots")) + else + Seq.empty +} diff --git a/src/sbt-test/scoverage/bad-coverage-total-branch/src/main/scala/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage-total-branch/src/main/scala/BadCoverage.scala new file mode 100644 index 00000000..fd6887a7 --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-total-branch/src/main/scala/BadCoverage.scala @@ -0,0 +1,7 @@ +object BadCoverage { + + def sum(num1: Int, num2: Int) = { + if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2 + } + +} diff --git a/src/sbt-test/scoverage/bad-coverage-total-branch/src/test/scala/BadCoverageSpec.scala b/src/sbt-test/scoverage/bad-coverage-total-branch/src/test/scala/BadCoverageSpec.scala new file mode 100644 index 00000000..eb4b4ec8 --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-total-branch/src/test/scala/BadCoverageSpec.scala @@ -0,0 +1,10 @@ +import munit.FunSuite + +class BadCoverageSpec extends FunSuite { + + test("BadCoverage should sum two numbers") { + assertEquals(BadCoverage.sum(1, 2), 3) + assertEquals(BadCoverage.sum(0, 3), 3) + } + +} diff --git a/src/sbt-test/scoverage/bad-coverage-total-branch/test b/src/sbt-test/scoverage/bad-coverage-total-branch/test new file mode 100644 index 00000000..45cbbb60 --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-total-branch/test @@ -0,0 +1,5 @@ +# run scoverage +> clean +> coverage +> test +-> coverageReport diff --git a/src/sbt-test/scoverage/bad-coverage-total-stmt/build.sbt b/src/sbt-test/scoverage/bad-coverage-total-stmt/build.sbt new file mode 100644 index 00000000..e6522c5b --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-total-stmt/build.sbt @@ -0,0 +1,14 @@ +version := "0.1" + +scalaVersion := "2.13.5" + +libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test + +coverageMinimumStmtTotal := 80 + +coverageFailOnMinimum := true + +resolvers ++= { + if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots")) + else Seq.empty +} diff --git a/src/sbt-test/scoverage/bad-coverage-total-stmt/project/plugins.sbt b/src/sbt-test/scoverage/bad-coverage-total-stmt/project/plugins.sbt new file mode 100644 index 00000000..8f2837b3 --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-total-stmt/project/plugins.sbt @@ -0,0 +1,14 @@ +val pluginVersion = sys.props.getOrElse( + "plugin.version", + throw new RuntimeException( + """|The system property 'plugin.version' is not defined. + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) + +addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) + +resolvers ++= { + if (pluginVersion.endsWith("-SNAPSHOT")) + Seq(Resolver.sonatypeRepo("snapshots")) + else + Seq.empty +} diff --git a/src/sbt-test/scoverage/bad-coverage-total-stmt/src/main/scala/one/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage-total-stmt/src/main/scala/one/BadCoverage.scala new file mode 100644 index 00000000..300ec10c --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-total-stmt/src/main/scala/one/BadCoverage.scala @@ -0,0 +1,9 @@ +package one + +object BadCoverage { + + def sum(num1: Int, num2: Int) = { + if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2 + } + +} diff --git a/src/sbt-test/scoverage/bad-coverage-total-stmt/src/main/scala/two/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage-total-stmt/src/main/scala/two/BadCoverage.scala new file mode 100644 index 00000000..3ebc31da --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-total-stmt/src/main/scala/two/BadCoverage.scala @@ -0,0 +1,9 @@ +package two + +object BadCoverage { + + def sum(num1: Int, num2: Int) = { + if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2 + } + +} diff --git a/src/sbt-test/scoverage/bad-coverage-total-stmt/src/test/scala/BadCoverageSpec.scala b/src/sbt-test/scoverage/bad-coverage-total-stmt/src/test/scala/BadCoverageSpec.scala new file mode 100644 index 00000000..e487ec12 --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-total-stmt/src/test/scala/BadCoverageSpec.scala @@ -0,0 +1,11 @@ +import munit.FunSuite + +class BadCoverageSpec extends FunSuite { + + test("one.BadCoverage should sum two numbers") { + assertEquals(one.BadCoverage.sum(1, 2), 3) + assertEquals(one.BadCoverage.sum(0, 3), 3) + assertEquals(one.BadCoverage.sum(3, 0), 3) + } + +} diff --git a/src/sbt-test/scoverage/bad-coverage-total-stmt/test b/src/sbt-test/scoverage/bad-coverage-total-stmt/test new file mode 100644 index 00000000..45cbbb60 --- /dev/null +++ b/src/sbt-test/scoverage/bad-coverage-total-stmt/test @@ -0,0 +1,5 @@ +# run scoverage +> clean +> coverage +> test +-> coverageReport diff --git a/src/sbt-test/scoverage/coverage-off/build.sbt b/src/sbt-test/scoverage/coverage-off/build.sbt index de77b640..0ab1d3ef 100644 --- a/src/sbt-test/scoverage/coverage-off/build.sbt +++ b/src/sbt-test/scoverage/coverage-off/build.sbt @@ -5,6 +5,12 @@ scalaVersion := "2.13.5" libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test coverageMinimum := 80 +coverageMinimumStmtTotal := 100 +coverageMinimumBranchTotal := 100 +coverageMinimumStmtPerPackage := 100 +coverageMinimumBranchPerPackage := 100 +coverageMinimumStmtPerFile := 100 +coverageMinimumBranchPerFile := 100 coverageFailOnMinimum := true diff --git a/src/sbt-test/scoverage/coverage-off/src/main/scala/GoodCoverage.scala b/src/sbt-test/scoverage/coverage-off/src/main/scala/GoodCoverage.scala index f4f3ecae..ac6582bb 100644 --- a/src/sbt-test/scoverage/coverage-off/src/main/scala/GoodCoverage.scala +++ b/src/sbt-test/scoverage/coverage-off/src/main/scala/GoodCoverage.scala @@ -1,6 +1,7 @@ object GoodCoverage { def sum(num1: Int, num2: Int) = { - num1 + num2 + if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2 } -} \ No newline at end of file + +} diff --git a/src/sbt-test/scoverage/coverage-off/src/main/scala/two/GoodCoverage.scala b/src/sbt-test/scoverage/coverage-off/src/main/scala/two/GoodCoverage.scala new file mode 100644 index 00000000..587e11e1 --- /dev/null +++ b/src/sbt-test/scoverage/coverage-off/src/main/scala/two/GoodCoverage.scala @@ -0,0 +1,9 @@ +package two + +object GoodCoverage { + + def sum(num1: Int, num2: Int) = { + if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2 + } + +} diff --git a/src/sbt-test/scoverage/coverage-off/src/test/scala/GoodCoverageSpec.scala b/src/sbt-test/scoverage/coverage-off/src/test/scala/GoodCoverageSpec.scala index b1d4ddfc..44eec1c9 100644 --- a/src/sbt-test/scoverage/coverage-off/src/test/scala/GoodCoverageSpec.scala +++ b/src/sbt-test/scoverage/coverage-off/src/test/scala/GoodCoverageSpec.scala @@ -4,7 +4,16 @@ import munit.FunSuite */ class GoodCoverageSpec extends FunSuite { - test("GoodCoverage should sum two numvers") { + test("GoodCoverage should sum two numbers") { assertEquals(GoodCoverage.sum(1, 2), 3) + assertEquals(GoodCoverage.sum(0, 3), 3) + assertEquals(GoodCoverage.sum(3, 0), 3) } + + test("two.GoodCoverage should sum two numbers") { + assertEquals(two.GoodCoverage.sum(1, 2), 3) + assertEquals(two.GoodCoverage.sum(0, 3), 3) + assertEquals(two.GoodCoverage.sum(3, 0), 3) + } + } diff --git a/src/sbt-test/scoverage/good-coverage/build.sbt b/src/sbt-test/scoverage/good-coverage/build.sbt index de77b640..0ab1d3ef 100644 --- a/src/sbt-test/scoverage/good-coverage/build.sbt +++ b/src/sbt-test/scoverage/good-coverage/build.sbt @@ -5,6 +5,12 @@ scalaVersion := "2.13.5" libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test coverageMinimum := 80 +coverageMinimumStmtTotal := 100 +coverageMinimumBranchTotal := 100 +coverageMinimumStmtPerPackage := 100 +coverageMinimumBranchPerPackage := 100 +coverageMinimumStmtPerFile := 100 +coverageMinimumBranchPerFile := 100 coverageFailOnMinimum := true diff --git a/src/sbt-test/scoverage/good-coverage/src/main/scala/GoodCoverage.scala b/src/sbt-test/scoverage/good-coverage/src/main/scala/GoodCoverage.scala index f4f3ecae..ac6582bb 100644 --- a/src/sbt-test/scoverage/good-coverage/src/main/scala/GoodCoverage.scala +++ b/src/sbt-test/scoverage/good-coverage/src/main/scala/GoodCoverage.scala @@ -1,6 +1,7 @@ object GoodCoverage { def sum(num1: Int, num2: Int) = { - num1 + num2 + if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2 } -} \ No newline at end of file + +} diff --git a/src/sbt-test/scoverage/good-coverage/src/main/scala/two/GoodCoverage.scala b/src/sbt-test/scoverage/good-coverage/src/main/scala/two/GoodCoverage.scala new file mode 100644 index 00000000..587e11e1 --- /dev/null +++ b/src/sbt-test/scoverage/good-coverage/src/main/scala/two/GoodCoverage.scala @@ -0,0 +1,9 @@ +package two + +object GoodCoverage { + + def sum(num1: Int, num2: Int) = { + if (0 == num1) num2 else if (0 == num2) num1 else num1 + num2 + } + +} diff --git a/src/sbt-test/scoverage/good-coverage/src/test/scala/GoodCoverageSpec.scala b/src/sbt-test/scoverage/good-coverage/src/test/scala/GoodCoverageSpec.scala index 4e88b703..44eec1c9 100644 --- a/src/sbt-test/scoverage/good-coverage/src/test/scala/GoodCoverageSpec.scala +++ b/src/sbt-test/scoverage/good-coverage/src/test/scala/GoodCoverageSpec.scala @@ -6,5 +6,14 @@ class GoodCoverageSpec extends FunSuite { test("GoodCoverage should sum two numbers") { assertEquals(GoodCoverage.sum(1, 2), 3) + assertEquals(GoodCoverage.sum(0, 3), 3) + assertEquals(GoodCoverage.sum(3, 0), 3) } + + test("two.GoodCoverage should sum two numbers") { + assertEquals(two.GoodCoverage.sum(1, 2), 3) + assertEquals(two.GoodCoverage.sum(0, 3), 3) + assertEquals(two.GoodCoverage.sum(3, 0), 3) + } + } From 3af76cc068ca13f7a4c2beaeda3b44b85870a51b Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 10 May 2021 03:32:41 +0200 Subject: [PATCH 31/49] Update sbt, scripted-plugin to 1.5.2 --- project/build.properties | 2 +- src/sbt-test/scoverage/aggregate/project/build.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/project/build.properties b/project/build.properties index f0be67b9..19479ba4 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.1 +sbt.version=1.5.2 diff --git a/src/sbt-test/scoverage/aggregate/project/build.properties b/src/sbt-test/scoverage/aggregate/project/build.properties index f0be67b9..19479ba4 100644 --- a/src/sbt-test/scoverage/aggregate/project/build.properties +++ b/src/sbt-test/scoverage/aggregate/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.1 +sbt.version=1.5.2 From ea3e142ba62ff34999e3a45e802b92fabc60f170 Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Mon, 10 May 2021 20:16:24 +0200 Subject: [PATCH 32/49] Bump scoverage version to 1.4.6 --- build.sbt | 2 +- src/main/scala/scoverage/ScoverageSbtPlugin.scala | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 364337b3..86c76280 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ name := "sbt-scoverage" import sbt.ScriptedPlugin.autoImport.scriptedLaunchOpts -def scoverageVersion = "1.4.5" +def scoverageVersion = "1.4.6" inThisBuild( List( diff --git a/src/main/scala/scoverage/ScoverageSbtPlugin.scala b/src/main/scala/scoverage/ScoverageSbtPlugin.scala index 07abe634..183b6868 100644 --- a/src/main/scala/scoverage/ScoverageSbtPlugin.scala +++ b/src/main/scala/scoverage/ScoverageSbtPlugin.scala @@ -69,9 +69,9 @@ object ScoverageSbtPlugin extends AutoPlugin { Seq( // We only add for "compile" because of macros. This setting could be optimed to just "test" if the handling // of macro coverage was improved. - (orgScoverage %% (scalacRuntime( + orgScoverage %% (scalacRuntime( libraryDependencies.value - )) % coverageScalacPluginVersion.value).cross(CrossVersion.full), + )) % coverageScalacPluginVersion.value, // We don't want to instrument the test code itself, nor add to a pom when published with coverage enabled. (orgScoverage %% scalacPluginArtifact % coverageScalacPluginVersion.value % ScoveragePluginConfig.name) .cross(CrossVersion.full) From a15cce2d1e4ebfdbe9cd8de1a7c54d97202e2718 Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Tue, 11 May 2021 13:34:05 +0200 Subject: [PATCH 33/49] Add in missing percent sign for branch coverage --- src/main/scala/scoverage/CoverageMinimum.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/scoverage/CoverageMinimum.scala b/src/main/scala/scoverage/CoverageMinimum.scala index be05c872..8e0c3030 100644 --- a/src/main/scala/scoverage/CoverageMinimum.scala +++ b/src/main/scala/scoverage/CoverageMinimum.scala @@ -76,7 +76,7 @@ object CoverageMinimum { log.info( s"All done. Coverage was" + s" stmt=[${coverage.statementCoverageFormatted}%]" + - s" branch=[${coverage.branchCoverageFormatted}]" + s" branch=[${coverage.branchCoverageFormatted}%]" ) } From 6d9d65abce67990048f662217eff2284caa13429 Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Tue, 11 May 2021 15:21:59 +0200 Subject: [PATCH 34/49] Add in .git-blame-ignore-revs Reformatting an entire project typically has the complaint that blame is no longer useful. Thankfully, git has a solution for this. You can read more about this here: https://www.moxio.com/blog/43/ignoring-bulk-change-commits-with-git-blame This `.git-blame-ignore-revs` file can be used to ensure that the formatting commit is ignored when locally using `git blame.` --- .git-blame-ignore-revs | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .git-blame-ignore-revs diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000..cbc018a2 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,6 @@ +# It's a good idea to ignore the following commits from git blame.j +# You can read more about this here if you're unfamiliar: +# https://www.moxio.com/blog/43/ignoring-bulk-change-commits-with-git-blame +# +# Added scalafmt +af2396558918fea00eaa2da12906a3012eb72153 From 90289bb0c9364b8b08ca3653533c2c848a316652 Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Wed, 19 May 2021 21:51:31 +0200 Subject: [PATCH 35/49] Bump scoverage version to 1.4.7 --- build.sbt | 2 +- src/sbt-test/scoverage/aggregate-only/build.sbt | 2 +- src/sbt-test/scoverage/aggregate/build.sbt | 2 +- src/sbt-test/scoverage/bad-coverage-file-branch/build.sbt | 2 +- src/sbt-test/scoverage/bad-coverage-file-stmt/build.sbt | 2 +- src/sbt-test/scoverage/bad-coverage-package-branch/build.sbt | 2 +- src/sbt-test/scoverage/bad-coverage-package-stmt/build.sbt | 2 +- src/sbt-test/scoverage/bad-coverage-total-branch/build.sbt | 2 +- src/sbt-test/scoverage/bad-coverage-total-stmt/build.sbt | 2 +- src/sbt-test/scoverage/bad-coverage/build.sbt | 2 +- src/sbt-test/scoverage/coverage-off/build.sbt | 2 +- src/sbt-test/scoverage/good-coverage/build.sbt | 2 +- src/sbt-test/scoverage/preserve-set/build.sbt | 4 ++-- src/sbt-test/scoverage/preserve-set/test | 4 ++-- src/sbt-test/scoverage/scalajs/build.sbt | 2 +- src/sbt-test/scoverage/scalajs/project/plugins.sbt | 2 +- 16 files changed, 18 insertions(+), 18 deletions(-) diff --git a/build.sbt b/build.sbt index 86c76280..4dd56258 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ name := "sbt-scoverage" import sbt.ScriptedPlugin.autoImport.scriptedLaunchOpts -def scoverageVersion = "1.4.6" +def scoverageVersion = "1.4.7" inThisBuild( List( diff --git a/src/sbt-test/scoverage/aggregate-only/build.sbt b/src/sbt-test/scoverage/aggregate-only/build.sbt index da1eb7b9..c2c6ed97 100644 --- a/src/sbt-test/scoverage/aggregate-only/build.sbt +++ b/src/sbt-test/scoverage/aggregate-only/build.sbt @@ -6,7 +6,7 @@ lazy val commonSettings = Seq( organization := "org.scoverage", version := "0.1.0", - scalaVersion := "2.13.5" + scalaVersion := "2.13.6" ) def module(name: String) = { diff --git a/src/sbt-test/scoverage/aggregate/build.sbt b/src/sbt-test/scoverage/aggregate/build.sbt index da1eb7b9..c2c6ed97 100644 --- a/src/sbt-test/scoverage/aggregate/build.sbt +++ b/src/sbt-test/scoverage/aggregate/build.sbt @@ -6,7 +6,7 @@ lazy val commonSettings = Seq( organization := "org.scoverage", version := "0.1.0", - scalaVersion := "2.13.5" + scalaVersion := "2.13.6" ) def module(name: String) = { diff --git a/src/sbt-test/scoverage/bad-coverage-file-branch/build.sbt b/src/sbt-test/scoverage/bad-coverage-file-branch/build.sbt index 36d96ac6..97ccf122 100644 --- a/src/sbt-test/scoverage/bad-coverage-file-branch/build.sbt +++ b/src/sbt-test/scoverage/bad-coverage-file-branch/build.sbt @@ -1,6 +1,6 @@ version := "0.1" -scalaVersion := "2.13.5" +scalaVersion := "2.13.6" libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test diff --git a/src/sbt-test/scoverage/bad-coverage-file-stmt/build.sbt b/src/sbt-test/scoverage/bad-coverage-file-stmt/build.sbt index 291ad6c8..5da5b2c5 100644 --- a/src/sbt-test/scoverage/bad-coverage-file-stmt/build.sbt +++ b/src/sbt-test/scoverage/bad-coverage-file-stmt/build.sbt @@ -1,6 +1,6 @@ version := "0.1" -scalaVersion := "2.13.5" +scalaVersion := "2.13.6" libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test diff --git a/src/sbt-test/scoverage/bad-coverage-package-branch/build.sbt b/src/sbt-test/scoverage/bad-coverage-package-branch/build.sbt index 333d81eb..7390cca4 100644 --- a/src/sbt-test/scoverage/bad-coverage-package-branch/build.sbt +++ b/src/sbt-test/scoverage/bad-coverage-package-branch/build.sbt @@ -1,6 +1,6 @@ version := "0.1" -scalaVersion := "2.13.5" +scalaVersion := "2.13.6" libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test diff --git a/src/sbt-test/scoverage/bad-coverage-package-stmt/build.sbt b/src/sbt-test/scoverage/bad-coverage-package-stmt/build.sbt index c9f662cc..1b0556a6 100644 --- a/src/sbt-test/scoverage/bad-coverage-package-stmt/build.sbt +++ b/src/sbt-test/scoverage/bad-coverage-package-stmt/build.sbt @@ -1,6 +1,6 @@ version := "0.1" -scalaVersion := "2.13.5" +scalaVersion := "2.13.6" libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test diff --git a/src/sbt-test/scoverage/bad-coverage-total-branch/build.sbt b/src/sbt-test/scoverage/bad-coverage-total-branch/build.sbt index 8b61d1bb..3708759e 100644 --- a/src/sbt-test/scoverage/bad-coverage-total-branch/build.sbt +++ b/src/sbt-test/scoverage/bad-coverage-total-branch/build.sbt @@ -1,6 +1,6 @@ version := "0.1" -scalaVersion := "2.13.5" +scalaVersion := "2.13.6" libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test diff --git a/src/sbt-test/scoverage/bad-coverage-total-stmt/build.sbt b/src/sbt-test/scoverage/bad-coverage-total-stmt/build.sbt index e6522c5b..fd782053 100644 --- a/src/sbt-test/scoverage/bad-coverage-total-stmt/build.sbt +++ b/src/sbt-test/scoverage/bad-coverage-total-stmt/build.sbt @@ -1,6 +1,6 @@ version := "0.1" -scalaVersion := "2.13.5" +scalaVersion := "2.13.6" libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test diff --git a/src/sbt-test/scoverage/bad-coverage/build.sbt b/src/sbt-test/scoverage/bad-coverage/build.sbt index de77b640..502f94a2 100644 --- a/src/sbt-test/scoverage/bad-coverage/build.sbt +++ b/src/sbt-test/scoverage/bad-coverage/build.sbt @@ -1,6 +1,6 @@ version := "0.1" -scalaVersion := "2.13.5" +scalaVersion := "2.13.6" libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test diff --git a/src/sbt-test/scoverage/coverage-off/build.sbt b/src/sbt-test/scoverage/coverage-off/build.sbt index 0ab1d3ef..f24ad2a8 100644 --- a/src/sbt-test/scoverage/coverage-off/build.sbt +++ b/src/sbt-test/scoverage/coverage-off/build.sbt @@ -1,6 +1,6 @@ version := "0.1" -scalaVersion := "2.13.5" +scalaVersion := "2.13.6" libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test diff --git a/src/sbt-test/scoverage/good-coverage/build.sbt b/src/sbt-test/scoverage/good-coverage/build.sbt index 0ab1d3ef..f24ad2a8 100644 --- a/src/sbt-test/scoverage/good-coverage/build.sbt +++ b/src/sbt-test/scoverage/good-coverage/build.sbt @@ -1,6 +1,6 @@ version := "0.1" -scalaVersion := "2.13.5" +scalaVersion := "2.13.6" libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test diff --git a/src/sbt-test/scoverage/preserve-set/build.sbt b/src/sbt-test/scoverage/preserve-set/build.sbt index cacb0594..e4eb293e 100644 --- a/src/sbt-test/scoverage/preserve-set/build.sbt +++ b/src/sbt-test/scoverage/preserve-set/build.sbt @@ -2,9 +2,9 @@ import sbt.complete.DefaultParsers._ version := "0.1" -scalaVersion := "2.13.5" +scalaVersion := "2.13.6" -crossScalaVersions := Seq("2.13.5") +crossScalaVersions := Seq("2.13.6") libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test diff --git a/src/sbt-test/scoverage/preserve-set/test b/src/sbt-test/scoverage/preserve-set/test index 1d8ab737..cc273221 100644 --- a/src/sbt-test/scoverage/preserve-set/test +++ b/src/sbt-test/scoverage/preserve-set/test @@ -1,8 +1,8 @@ # check scalaVersion setting -> checkScalaVersion "2.13.5" +> checkScalaVersion "2.13.6" > checkScoverageEnabled "false" > coverage > checkScoverageEnabled "true" > coverageOff -> checkScalaVersion "2.13.5" +> checkScalaVersion "2.13.6" > checkScoverageEnabled "false" diff --git a/src/sbt-test/scoverage/scalajs/build.sbt b/src/sbt-test/scoverage/scalajs/build.sbt index 59494e18..4406129c 100644 --- a/src/sbt-test/scoverage/scalajs/build.sbt +++ b/src/sbt-test/scoverage/scalajs/build.sbt @@ -7,7 +7,7 @@ lazy val cross = CrossProject("sjstest", file("sjstest"))(JVMPlatform, JSPlatform) .crossType(CrossType.Full) .settings( - scalaVersion := "2.13.5", + scalaVersion := "2.13.6", libraryDependencies += "org.scalameta" %% "munit" % "0.7.25" % Test ) diff --git a/src/sbt-test/scoverage/scalajs/project/plugins.sbt b/src/sbt-test/scoverage/scalajs/project/plugins.sbt index 6d94fb59..7687f56d 100644 --- a/src/sbt-test/scoverage/scalajs/project/plugins.sbt +++ b/src/sbt-test/scoverage/scalajs/project/plugins.sbt @@ -13,6 +13,6 @@ resolvers ++= { Seq.empty } -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.0") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.1") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0") From f9874cd34eaefe41bcbd23f3dd5c7b4f4371086e Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 28 May 2021 20:55:35 +0200 Subject: [PATCH 36/49] Update scalac-scoverage-plugin to 1.4.8 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 4dd56258..2d51a0a6 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ name := "sbt-scoverage" import sbt.ScriptedPlugin.autoImport.scriptedLaunchOpts -def scoverageVersion = "1.4.7" +def scoverageVersion = "1.4.8" inThisBuild( List( From 4dcf1215f686bb85eeaa4910f6ede8cf9da687bc Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 1 Jun 2021 09:13:27 +0200 Subject: [PATCH 37/49] Update sbt, scripted-plugin to 1.5.3 --- project/build.properties | 2 +- src/sbt-test/scoverage/aggregate/project/build.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/project/build.properties b/project/build.properties index 19479ba4..67d27a1d 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.2 +sbt.version=1.5.3 diff --git a/src/sbt-test/scoverage/aggregate/project/build.properties b/src/sbt-test/scoverage/aggregate/project/build.properties index 19479ba4..67d27a1d 100644 --- a/src/sbt-test/scoverage/aggregate/project/build.properties +++ b/src/sbt-test/scoverage/aggregate/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.2 +sbt.version=1.5.3 From bad6866e3ac484335cc52d6550a3f3789de86718 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 4 Jun 2021 12:49:19 +0700 Subject: [PATCH 38/49] Update to scala 2.12.14 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 2d51a0a6..f3b4aceb 100644 --- a/build.sbt +++ b/build.sbt @@ -25,7 +25,7 @@ inThisBuild( licenses := Seq( "Apache-2.0" -> url("http://www.apache.org/license/LICENSE-2.0") ), - scalaVersion := "2.12.13" + scalaVersion := "2.12.14" ) ) From f8952fd6c6bac4637bc87e2dab687d83984be59d Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 14 Jun 2021 09:07:10 +0200 Subject: [PATCH 39/49] Update sbt, scripted-plugin to 1.5.4 --- project/build.properties | 2 +- src/sbt-test/scoverage/aggregate/project/build.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/project/build.properties b/project/build.properties index 67d27a1d..9edb75b7 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.3 +sbt.version=1.5.4 diff --git a/src/sbt-test/scoverage/aggregate/project/build.properties b/src/sbt-test/scoverage/aggregate/project/build.properties index 67d27a1d..9edb75b7 100644 --- a/src/sbt-test/scoverage/aggregate/project/build.properties +++ b/src/sbt-test/scoverage/aggregate/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.3 +sbt.version=1.5.4 From 8b3f4de42b808b2dfe06cfbbd5c3c48296f5c0a1 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 9 Jul 2021 03:51:47 +0200 Subject: [PATCH 40/49] Update sbt-scalafmt to 2.4.3 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index ce24e5b0..559fb208 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,4 @@ libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.3") From 9d9fa31153e906a339069a1074fea500e548f54a Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 12 Jul 2021 13:47:32 +0200 Subject: [PATCH 41/49] Update sbt, scripted-plugin to 1.5.5 --- project/build.properties | 2 +- src/sbt-test/scoverage/aggregate/project/build.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/project/build.properties b/project/build.properties index 9edb75b7..10fd9eee 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.4 +sbt.version=1.5.5 diff --git a/src/sbt-test/scoverage/aggregate/project/build.properties b/src/sbt-test/scoverage/aggregate/project/build.properties index 9edb75b7..10fd9eee 100644 --- a/src/sbt-test/scoverage/aggregate/project/build.properties +++ b/src/sbt-test/scoverage/aggregate/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.4 +sbt.version=1.5.5 From 369559e54068770877d2d28fa2dbf7497513d81e Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 19 Aug 2021 05:58:26 +0200 Subject: [PATCH 42/49] Update scalafmt-core to 3.0.0 --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 010fa6d5..334e29d7 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1 +1 @@ -version = "2.7.5" +version = "3.0.0" From cf2dcaca88019354617c3594c72ed8e0e1fce9a8 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Thu, 19 Aug 2021 05:58:34 +0200 Subject: [PATCH 43/49] Reformat with scalafmt 3.0.0 --- .../scala/org/scoverage/issue53/part/a/AdderScala.scala | 5 ++--- .../org/scoverage/issue53/part/b/SubtractorScala.scala | 6 ++---- src/sbt-test/scoverage/aggregate-only/project/plugins.sbt | 4 +++- .../scala/org/scoverage/issue53/part/a/AdderScala.scala | 5 ++--- .../org/scoverage/issue53/part/b/SubtractorScala.scala | 6 ++---- src/sbt-test/scoverage/aggregate/project/plugins.sbt | 4 +++- src/sbt-test/scoverage/bad-coverage-file-branch/build.sbt | 7 ++++++- .../scoverage/bad-coverage-file-branch/project/plugins.sbt | 4 +++- src/sbt-test/scoverage/bad-coverage-file-stmt/build.sbt | 7 ++++++- .../scoverage/bad-coverage-file-stmt/project/plugins.sbt | 4 +++- .../scoverage/bad-coverage-package-branch/build.sbt | 7 ++++++- .../bad-coverage-package-branch/project/plugins.sbt | 4 +++- src/sbt-test/scoverage/bad-coverage-package-stmt/build.sbt | 7 ++++++- .../bad-coverage-package-stmt/project/plugins.sbt | 4 +++- src/sbt-test/scoverage/bad-coverage-total-branch/build.sbt | 7 ++++++- .../bad-coverage-total-branch/project/plugins.sbt | 4 +++- src/sbt-test/scoverage/bad-coverage-total-stmt/build.sbt | 7 ++++++- .../scoverage/bad-coverage-total-stmt/project/plugins.sbt | 4 +++- src/sbt-test/scoverage/bad-coverage/project/plugins.sbt | 4 +++- .../bad-coverage/src/main/scala/BadCoverage.scala | 2 +- src/sbt-test/scoverage/coverage-off/project/plugins.sbt | 4 +++- src/sbt-test/scoverage/good-coverage/project/plugins.sbt | 4 +++- src/sbt-test/scoverage/preserve-set/project/plugins.sbt | 4 +++- .../scoverage/scalac-plugin-version/project/plugins.sbt | 4 +++- src/sbt-test/scoverage/scalajs/project/plugins.sbt | 4 +++- .../scalajs/sjstest/shared/src/main/scala/UnderTest.scala | 1 - 26 files changed, 87 insertions(+), 36 deletions(-) diff --git a/src/sbt-test/scoverage/aggregate-only/partA/src/main/scala/org/scoverage/issue53/part/a/AdderScala.scala b/src/sbt-test/scoverage/aggregate-only/partA/src/main/scala/org/scoverage/issue53/part/a/AdderScala.scala index 30415c1d..96b580e3 100644 --- a/src/sbt-test/scoverage/aggregate-only/partA/src/main/scala/org/scoverage/issue53/part/a/AdderScala.scala +++ b/src/sbt-test/scoverage/aggregate-only/partA/src/main/scala/org/scoverage/issue53/part/a/AdderScala.scala @@ -1,8 +1,7 @@ package org.scoverage.issue53.part.a -/** - * Created by Mikhail Kokho on 7/10/2015. - */ +/** Created by Mikhail Kokho on 7/10/2015. + */ object AdderScala { def add(x: Int, y: Int) = x + y diff --git a/src/sbt-test/scoverage/aggregate-only/partB/src/main/scala/org/scoverage/issue53/part/b/SubtractorScala.scala b/src/sbt-test/scoverage/aggregate-only/partB/src/main/scala/org/scoverage/issue53/part/b/SubtractorScala.scala index e6da85fd..fbb7dcda 100644 --- a/src/sbt-test/scoverage/aggregate-only/partB/src/main/scala/org/scoverage/issue53/part/b/SubtractorScala.scala +++ b/src/sbt-test/scoverage/aggregate-only/partB/src/main/scala/org/scoverage/issue53/part/b/SubtractorScala.scala @@ -1,9 +1,7 @@ - package org.scoverage.issue53.part.b -/** - * Created by Mikhail Kokho on 7/10/2015. - */ +/** Created by Mikhail Kokho on 7/10/2015. + */ object SubtractorScala { def minus(x: Int, y: Int) = x - y diff --git a/src/sbt-test/scoverage/aggregate-only/project/plugins.sbt b/src/sbt-test/scoverage/aggregate-only/project/plugins.sbt index 8f2837b3..8d349239 100644 --- a/src/sbt-test/scoverage/aggregate-only/project/plugins.sbt +++ b/src/sbt-test/scoverage/aggregate-only/project/plugins.sbt @@ -2,7 +2,9 @@ val pluginVersion = sys.props.getOrElse( "plugin.version", throw new RuntimeException( """|The system property 'plugin.version' is not defined. - |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin + ) +) addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) diff --git a/src/sbt-test/scoverage/aggregate/partA/src/main/scala/org/scoverage/issue53/part/a/AdderScala.scala b/src/sbt-test/scoverage/aggregate/partA/src/main/scala/org/scoverage/issue53/part/a/AdderScala.scala index 30415c1d..96b580e3 100644 --- a/src/sbt-test/scoverage/aggregate/partA/src/main/scala/org/scoverage/issue53/part/a/AdderScala.scala +++ b/src/sbt-test/scoverage/aggregate/partA/src/main/scala/org/scoverage/issue53/part/a/AdderScala.scala @@ -1,8 +1,7 @@ package org.scoverage.issue53.part.a -/** - * Created by Mikhail Kokho on 7/10/2015. - */ +/** Created by Mikhail Kokho on 7/10/2015. + */ object AdderScala { def add(x: Int, y: Int) = x + y diff --git a/src/sbt-test/scoverage/aggregate/partB/src/main/scala/org/scoverage/issue53/part/b/SubtractorScala.scala b/src/sbt-test/scoverage/aggregate/partB/src/main/scala/org/scoverage/issue53/part/b/SubtractorScala.scala index e6da85fd..fbb7dcda 100644 --- a/src/sbt-test/scoverage/aggregate/partB/src/main/scala/org/scoverage/issue53/part/b/SubtractorScala.scala +++ b/src/sbt-test/scoverage/aggregate/partB/src/main/scala/org/scoverage/issue53/part/b/SubtractorScala.scala @@ -1,9 +1,7 @@ - package org.scoverage.issue53.part.b -/** - * Created by Mikhail Kokho on 7/10/2015. - */ +/** Created by Mikhail Kokho on 7/10/2015. + */ object SubtractorScala { def minus(x: Int, y: Int) = x - y diff --git a/src/sbt-test/scoverage/aggregate/project/plugins.sbt b/src/sbt-test/scoverage/aggregate/project/plugins.sbt index 8f2837b3..8d349239 100644 --- a/src/sbt-test/scoverage/aggregate/project/plugins.sbt +++ b/src/sbt-test/scoverage/aggregate/project/plugins.sbt @@ -2,7 +2,9 @@ val pluginVersion = sys.props.getOrElse( "plugin.version", throw new RuntimeException( """|The system property 'plugin.version' is not defined. - |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin + ) +) addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) diff --git a/src/sbt-test/scoverage/bad-coverage-file-branch/build.sbt b/src/sbt-test/scoverage/bad-coverage-file-branch/build.sbt index 97ccf122..56f70037 100644 --- a/src/sbt-test/scoverage/bad-coverage-file-branch/build.sbt +++ b/src/sbt-test/scoverage/bad-coverage-file-branch/build.sbt @@ -9,6 +9,11 @@ coverageMinimumBranchPerFile := 80 coverageFailOnMinimum := true resolvers ++= { - if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots")) + if ( + sys.props + .get("plugin.version") + .map(_.endsWith("-SNAPSHOT")) + .getOrElse(false) + ) Seq(Resolver.sonatypeRepo("snapshots")) else Seq.empty } diff --git a/src/sbt-test/scoverage/bad-coverage-file-branch/project/plugins.sbt b/src/sbt-test/scoverage/bad-coverage-file-branch/project/plugins.sbt index 8f2837b3..8d349239 100644 --- a/src/sbt-test/scoverage/bad-coverage-file-branch/project/plugins.sbt +++ b/src/sbt-test/scoverage/bad-coverage-file-branch/project/plugins.sbt @@ -2,7 +2,9 @@ val pluginVersion = sys.props.getOrElse( "plugin.version", throw new RuntimeException( """|The system property 'plugin.version' is not defined. - |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin + ) +) addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) diff --git a/src/sbt-test/scoverage/bad-coverage-file-stmt/build.sbt b/src/sbt-test/scoverage/bad-coverage-file-stmt/build.sbt index 5da5b2c5..9da543b4 100644 --- a/src/sbt-test/scoverage/bad-coverage-file-stmt/build.sbt +++ b/src/sbt-test/scoverage/bad-coverage-file-stmt/build.sbt @@ -9,6 +9,11 @@ coverageMinimumStmtPerFile := 90 coverageFailOnMinimum := true resolvers ++= { - if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots")) + if ( + sys.props + .get("plugin.version") + .map(_.endsWith("-SNAPSHOT")) + .getOrElse(false) + ) Seq(Resolver.sonatypeRepo("snapshots")) else Seq.empty } diff --git a/src/sbt-test/scoverage/bad-coverage-file-stmt/project/plugins.sbt b/src/sbt-test/scoverage/bad-coverage-file-stmt/project/plugins.sbt index 8f2837b3..8d349239 100644 --- a/src/sbt-test/scoverage/bad-coverage-file-stmt/project/plugins.sbt +++ b/src/sbt-test/scoverage/bad-coverage-file-stmt/project/plugins.sbt @@ -2,7 +2,9 @@ val pluginVersion = sys.props.getOrElse( "plugin.version", throw new RuntimeException( """|The system property 'plugin.version' is not defined. - |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin + ) +) addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) diff --git a/src/sbt-test/scoverage/bad-coverage-package-branch/build.sbt b/src/sbt-test/scoverage/bad-coverage-package-branch/build.sbt index 7390cca4..748cf6e4 100644 --- a/src/sbt-test/scoverage/bad-coverage-package-branch/build.sbt +++ b/src/sbt-test/scoverage/bad-coverage-package-branch/build.sbt @@ -9,6 +9,11 @@ coverageMinimumBranchPerPackage := 80 coverageFailOnMinimum := true resolvers ++= { - if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots")) + if ( + sys.props + .get("plugin.version") + .map(_.endsWith("-SNAPSHOT")) + .getOrElse(false) + ) Seq(Resolver.sonatypeRepo("snapshots")) else Seq.empty } diff --git a/src/sbt-test/scoverage/bad-coverage-package-branch/project/plugins.sbt b/src/sbt-test/scoverage/bad-coverage-package-branch/project/plugins.sbt index 8f2837b3..8d349239 100644 --- a/src/sbt-test/scoverage/bad-coverage-package-branch/project/plugins.sbt +++ b/src/sbt-test/scoverage/bad-coverage-package-branch/project/plugins.sbt @@ -2,7 +2,9 @@ val pluginVersion = sys.props.getOrElse( "plugin.version", throw new RuntimeException( """|The system property 'plugin.version' is not defined. - |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin + ) +) addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) diff --git a/src/sbt-test/scoverage/bad-coverage-package-stmt/build.sbt b/src/sbt-test/scoverage/bad-coverage-package-stmt/build.sbt index 1b0556a6..18176ee4 100644 --- a/src/sbt-test/scoverage/bad-coverage-package-stmt/build.sbt +++ b/src/sbt-test/scoverage/bad-coverage-package-stmt/build.sbt @@ -9,6 +9,11 @@ coverageMinimumStmtPerPackage := 80 coverageFailOnMinimum := true resolvers ++= { - if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots")) + if ( + sys.props + .get("plugin.version") + .map(_.endsWith("-SNAPSHOT")) + .getOrElse(false) + ) Seq(Resolver.sonatypeRepo("snapshots")) else Seq.empty } diff --git a/src/sbt-test/scoverage/bad-coverage-package-stmt/project/plugins.sbt b/src/sbt-test/scoverage/bad-coverage-package-stmt/project/plugins.sbt index 8f2837b3..8d349239 100644 --- a/src/sbt-test/scoverage/bad-coverage-package-stmt/project/plugins.sbt +++ b/src/sbt-test/scoverage/bad-coverage-package-stmt/project/plugins.sbt @@ -2,7 +2,9 @@ val pluginVersion = sys.props.getOrElse( "plugin.version", throw new RuntimeException( """|The system property 'plugin.version' is not defined. - |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin + ) +) addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) diff --git a/src/sbt-test/scoverage/bad-coverage-total-branch/build.sbt b/src/sbt-test/scoverage/bad-coverage-total-branch/build.sbt index 3708759e..33b3c8d2 100644 --- a/src/sbt-test/scoverage/bad-coverage-total-branch/build.sbt +++ b/src/sbt-test/scoverage/bad-coverage-total-branch/build.sbt @@ -9,6 +9,11 @@ coverageMinimumBranchTotal := 80 coverageFailOnMinimum := true resolvers ++= { - if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots")) + if ( + sys.props + .get("plugin.version") + .map(_.endsWith("-SNAPSHOT")) + .getOrElse(false) + ) Seq(Resolver.sonatypeRepo("snapshots")) else Seq.empty } diff --git a/src/sbt-test/scoverage/bad-coverage-total-branch/project/plugins.sbt b/src/sbt-test/scoverage/bad-coverage-total-branch/project/plugins.sbt index 8f2837b3..8d349239 100644 --- a/src/sbt-test/scoverage/bad-coverage-total-branch/project/plugins.sbt +++ b/src/sbt-test/scoverage/bad-coverage-total-branch/project/plugins.sbt @@ -2,7 +2,9 @@ val pluginVersion = sys.props.getOrElse( "plugin.version", throw new RuntimeException( """|The system property 'plugin.version' is not defined. - |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin + ) +) addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) diff --git a/src/sbt-test/scoverage/bad-coverage-total-stmt/build.sbt b/src/sbt-test/scoverage/bad-coverage-total-stmt/build.sbt index fd782053..46ad59a2 100644 --- a/src/sbt-test/scoverage/bad-coverage-total-stmt/build.sbt +++ b/src/sbt-test/scoverage/bad-coverage-total-stmt/build.sbt @@ -9,6 +9,11 @@ coverageMinimumStmtTotal := 80 coverageFailOnMinimum := true resolvers ++= { - if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots")) + if ( + sys.props + .get("plugin.version") + .map(_.endsWith("-SNAPSHOT")) + .getOrElse(false) + ) Seq(Resolver.sonatypeRepo("snapshots")) else Seq.empty } diff --git a/src/sbt-test/scoverage/bad-coverage-total-stmt/project/plugins.sbt b/src/sbt-test/scoverage/bad-coverage-total-stmt/project/plugins.sbt index 8f2837b3..8d349239 100644 --- a/src/sbt-test/scoverage/bad-coverage-total-stmt/project/plugins.sbt +++ b/src/sbt-test/scoverage/bad-coverage-total-stmt/project/plugins.sbt @@ -2,7 +2,9 @@ val pluginVersion = sys.props.getOrElse( "plugin.version", throw new RuntimeException( """|The system property 'plugin.version' is not defined. - |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin + ) +) addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) diff --git a/src/sbt-test/scoverage/bad-coverage/project/plugins.sbt b/src/sbt-test/scoverage/bad-coverage/project/plugins.sbt index 8f2837b3..8d349239 100644 --- a/src/sbt-test/scoverage/bad-coverage/project/plugins.sbt +++ b/src/sbt-test/scoverage/bad-coverage/project/plugins.sbt @@ -2,7 +2,9 @@ val pluginVersion = sys.props.getOrElse( "plugin.version", throw new RuntimeException( """|The system property 'plugin.version' is not defined. - |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin + ) +) addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) diff --git a/src/sbt-test/scoverage/bad-coverage/src/main/scala/BadCoverage.scala b/src/sbt-test/scoverage/bad-coverage/src/main/scala/BadCoverage.scala index 9735241d..29663d06 100644 --- a/src/sbt-test/scoverage/bad-coverage/src/main/scala/BadCoverage.scala +++ b/src/sbt-test/scoverage/bad-coverage/src/main/scala/BadCoverage.scala @@ -7,4 +7,4 @@ object BadCoverage { def mult(num1: Int, num2: Int) = { num1 * num2 } -} \ No newline at end of file +} diff --git a/src/sbt-test/scoverage/coverage-off/project/plugins.sbt b/src/sbt-test/scoverage/coverage-off/project/plugins.sbt index 8f2837b3..8d349239 100644 --- a/src/sbt-test/scoverage/coverage-off/project/plugins.sbt +++ b/src/sbt-test/scoverage/coverage-off/project/plugins.sbt @@ -2,7 +2,9 @@ val pluginVersion = sys.props.getOrElse( "plugin.version", throw new RuntimeException( """|The system property 'plugin.version' is not defined. - |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin + ) +) addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) diff --git a/src/sbt-test/scoverage/good-coverage/project/plugins.sbt b/src/sbt-test/scoverage/good-coverage/project/plugins.sbt index 8f2837b3..8d349239 100644 --- a/src/sbt-test/scoverage/good-coverage/project/plugins.sbt +++ b/src/sbt-test/scoverage/good-coverage/project/plugins.sbt @@ -2,7 +2,9 @@ val pluginVersion = sys.props.getOrElse( "plugin.version", throw new RuntimeException( """|The system property 'plugin.version' is not defined. - |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin + ) +) addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) diff --git a/src/sbt-test/scoverage/preserve-set/project/plugins.sbt b/src/sbt-test/scoverage/preserve-set/project/plugins.sbt index 8f2837b3..8d349239 100644 --- a/src/sbt-test/scoverage/preserve-set/project/plugins.sbt +++ b/src/sbt-test/scoverage/preserve-set/project/plugins.sbt @@ -2,7 +2,9 @@ val pluginVersion = sys.props.getOrElse( "plugin.version", throw new RuntimeException( """|The system property 'plugin.version' is not defined. - |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin + ) +) addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) diff --git a/src/sbt-test/scoverage/scalac-plugin-version/project/plugins.sbt b/src/sbt-test/scoverage/scalac-plugin-version/project/plugins.sbt index 8f2837b3..8d349239 100644 --- a/src/sbt-test/scoverage/scalac-plugin-version/project/plugins.sbt +++ b/src/sbt-test/scoverage/scalac-plugin-version/project/plugins.sbt @@ -2,7 +2,9 @@ val pluginVersion = sys.props.getOrElse( "plugin.version", throw new RuntimeException( """|The system property 'plugin.version' is not defined. - |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin + ) +) addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) diff --git a/src/sbt-test/scoverage/scalajs/project/plugins.sbt b/src/sbt-test/scoverage/scalajs/project/plugins.sbt index 7687f56d..3529aa34 100644 --- a/src/sbt-test/scoverage/scalajs/project/plugins.sbt +++ b/src/sbt-test/scoverage/scalajs/project/plugins.sbt @@ -2,7 +2,9 @@ val pluginVersion = sys.props.getOrElse( "plugin.version", throw new RuntimeException( """|The system property 'plugin.version' is not defined. - |Specify this property using the scriptedLaunchOpts -D.""".stripMargin)) + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin + ) +) addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) diff --git a/src/sbt-test/scoverage/scalajs/sjstest/shared/src/main/scala/UnderTest.scala b/src/sbt-test/scoverage/scalajs/sjstest/shared/src/main/scala/UnderTest.scala index 66a31844..9b279395 100644 --- a/src/sbt-test/scoverage/scalajs/sjstest/shared/src/main/scala/UnderTest.scala +++ b/src/sbt-test/scoverage/scalajs/sjstest/shared/src/main/scala/UnderTest.scala @@ -1,4 +1,3 @@ - object UnderTest { def onJsAndJvm: String = "js and jvm" From 9d96252543582d977379918388c1806a0ac5cbb6 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Fri, 27 Aug 2021 22:33:14 +0200 Subject: [PATCH 44/49] Update scalafmt-core to 3.0.1 --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 334e29d7..2a30eb65 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1 +1 @@ -version = "3.0.0" +version = "3.0.1" From 9141cf7a45c0fea418649fc9fa508b511f69f7f0 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 4 Sep 2021 02:15:27 +0200 Subject: [PATCH 45/49] Update scalafmt-core to 3.0.2 --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 2a30eb65..ddb90c2d 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1 +1 @@ -version = "3.0.1" +version = "3.0.2" From 1839027092b54be0f3248d2f9d7e8efcc4e219a9 Mon Sep 17 00:00:00 2001 From: Peter Zhong Date: Wed, 8 Sep 2021 14:54:46 -0700 Subject: [PATCH 46/49] Allow for overriding location for coverage data and report --- README.md | 15 +++++++++++++++ src/main/scala/scoverage/ScoverageKeys.scala | 1 + .../scala/scoverage/ScoverageSbtPlugin.scala | 13 +++++++------ src/sbt-test/scoverage/data-dir/build.sbt | 17 +++++++++++++++++ .../scoverage/data-dir/project/build.properties | 1 + .../scoverage/data-dir/project/plugins.sbt | 16 ++++++++++++++++ .../data-dir/src/main/scala/GoodCoverage.scala | 6 ++++++ .../src/test/scala/GoodCoverageSpec.scala | 13 +++++++++++++ src/sbt-test/scoverage/data-dir/test | 7 +++++++ 9 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 src/sbt-test/scoverage/data-dir/build.sbt create mode 100644 src/sbt-test/scoverage/data-dir/project/build.properties create mode 100644 src/sbt-test/scoverage/data-dir/project/plugins.sbt create mode 100644 src/sbt-test/scoverage/data-dir/src/main/scala/GoodCoverage.scala create mode 100644 src/sbt-test/scoverage/data-dir/src/test/scala/GoodCoverageSpec.scala create mode 100644 src/sbt-test/scoverage/data-dir/test diff --git a/README.md b/README.md index ebc88679..f1ae2d31 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,21 @@ These settings will be enforced when the reports are generated. If you generate an aggregate report using `coverageAggregate` then these settings will apply to that report. +### Override Location for Coverage Data And Report + +If desired, one could override the default location for generating the sbt report and data through setting `coverageDataDir`: + +Example in data-dir test: +```scala +coverageDataDir := target.value / "custom-test" +``` + +Can also be set through the sbt set directive +```scala +set coverageDataDir := file("/tmp") +``` + + ## Trouble-shooting failing tests scoverage does a lot of file writing behind the scenes in order to track which diff --git a/src/main/scala/scoverage/ScoverageKeys.scala b/src/main/scala/scoverage/ScoverageKeys.scala index f846b277..2cc521b5 100644 --- a/src/main/scala/scoverage/ScoverageKeys.scala +++ b/src/main/scala/scoverage/ScoverageKeys.scala @@ -18,6 +18,7 @@ object ScoverageKeys { lazy val coverageOutputDebug = settingKey[Boolean]("turn on the debug report") lazy val coverageOutputTeamCity = settingKey[Boolean]("turn on teamcity reporting") lazy val coverageScalacPluginVersion = settingKey[String]("version of scalac-scoverage-plugin to use") + lazy val coverageDataDir = settingKey[File]("directory where the measurements will be stored to use") // format: on @deprecated("Use coverageMinimumStmtTotal instead", "v1.8.0") diff --git a/src/main/scala/scoverage/ScoverageSbtPlugin.scala b/src/main/scala/scoverage/ScoverageSbtPlugin.scala index 183b6868..59200f92 100644 --- a/src/main/scala/scoverage/ScoverageSbtPlugin.scala +++ b/src/main/scala/scoverage/ScoverageSbtPlugin.scala @@ -56,11 +56,12 @@ object ScoverageSbtPlugin extends AutoPlugin { addCommandAlias("coverageOn", ";set ThisBuild / coverageEnabled := true") ++ addCommandAlias("coverageOff", ";set ThisBuild / coverageEnabled := false") - override def projectSettings: Seq[Setting[_]] = Seq( + override def projectSettings: Seq[Setting[_]] = super.projectSettings ++ Seq( ivyConfigurations += ScoveragePluginConfig, coverageReport := coverageReport0.value, coverageAggregate := coverageAggregate0.value, - coverageAggregate / aggregate := false + coverageAggregate / aggregate := false, + coverageDataDir := crossTarget.value ) ++ coverageSettings ++ scalacSettings private lazy val coverageSettings = Seq( @@ -99,7 +100,7 @@ object ScoverageSbtPlugin extends AutoPlugin { Seq( Some(s"-Xplugin:${pluginPath.getAbsolutePath}"), Some( - s"-P:scoverage:dataDir:${crossTarget.value.getAbsolutePath}/scoverage-data" + s"-P:scoverage:dataDir:${coverageDataDir.value.getAbsolutePath}/scoverage-data" ), Option(coverageExcludedPackages.value.trim) .filter(_.nonEmpty) @@ -136,7 +137,7 @@ object ScoverageSbtPlugin extends AutoPlugin { } private lazy val coverageReport0 = Def.task { - val target = crossTarget.value + val target = coverageDataDir.value implicit val log = streams.value.log log.info(s"Waiting for measurement data to sync...") @@ -169,13 +170,13 @@ object ScoverageSbtPlugin extends AutoPlugin { implicit val log = streams.value.log log.info(s"Aggregating coverage from subprojects...") - val dataDirs = crossTarget + val dataDirs = coverageDataDir .all(aggregateFilter) .value map (_ / Constants.DataDir) filter (_.isDirectory) CoverageAggregator.aggregate(dataDirs) match { case Some(cov) => writeReports( - crossTarget.value, + coverageDataDir.value, sourceDirectories.all(aggregateFilter).value.flatten, cov, coverageOutputCobertura.value, diff --git a/src/sbt-test/scoverage/data-dir/build.sbt b/src/sbt-test/scoverage/data-dir/build.sbt new file mode 100644 index 00000000..c18a8d52 --- /dev/null +++ b/src/sbt-test/scoverage/data-dir/build.sbt @@ -0,0 +1,17 @@ +version := "0.1" + +scalaVersion := "2.13.6" + +libraryDependencies += "org.specs2" %% "specs2-core" % "4.12.10" % "test" + +coverageDataDir := target.value / "custom-test" + +coverageMinimum := 80 + +coverageFailOnMinimum := true + +resolvers ++= { + if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) + Seq(Resolver.sonatypeRepo("snapshots")) + else Seq.empty +} diff --git a/src/sbt-test/scoverage/data-dir/project/build.properties b/src/sbt-test/scoverage/data-dir/project/build.properties new file mode 100644 index 00000000..67d27a1d --- /dev/null +++ b/src/sbt-test/scoverage/data-dir/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.5.3 diff --git a/src/sbt-test/scoverage/data-dir/project/plugins.sbt b/src/sbt-test/scoverage/data-dir/project/plugins.sbt new file mode 100644 index 00000000..8d349239 --- /dev/null +++ b/src/sbt-test/scoverage/data-dir/project/plugins.sbt @@ -0,0 +1,16 @@ +val pluginVersion = sys.props.getOrElse( + "plugin.version", + throw new RuntimeException( + """|The system property 'plugin.version' is not defined. + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin + ) +) + +addSbtPlugin("org.scoverage" % "sbt-scoverage" % pluginVersion) + +resolvers ++= { + if (pluginVersion.endsWith("-SNAPSHOT")) + Seq(Resolver.sonatypeRepo("snapshots")) + else + Seq.empty +} diff --git a/src/sbt-test/scoverage/data-dir/src/main/scala/GoodCoverage.scala b/src/sbt-test/scoverage/data-dir/src/main/scala/GoodCoverage.scala new file mode 100644 index 00000000..f4f3ecae --- /dev/null +++ b/src/sbt-test/scoverage/data-dir/src/main/scala/GoodCoverage.scala @@ -0,0 +1,6 @@ +object GoodCoverage { + + def sum(num1: Int, num2: Int) = { + num1 + num2 + } +} \ No newline at end of file diff --git a/src/sbt-test/scoverage/data-dir/src/test/scala/GoodCoverageSpec.scala b/src/sbt-test/scoverage/data-dir/src/test/scala/GoodCoverageSpec.scala new file mode 100644 index 00000000..cbf6a70d --- /dev/null +++ b/src/sbt-test/scoverage/data-dir/src/test/scala/GoodCoverageSpec.scala @@ -0,0 +1,13 @@ +import org.specs2.mutable._ + +/** + * Created by tbarke001c on 7/8/14. + */ +class GoodCoverageSpec extends Specification { + + "GoodCoverage" should { + "sum two numbers" in { + GoodCoverage.sum(1, 2) mustEqual 3 + } + } +} diff --git a/src/sbt-test/scoverage/data-dir/test b/src/sbt-test/scoverage/data-dir/test new file mode 100644 index 00000000..a211a6f7 --- /dev/null +++ b/src/sbt-test/scoverage/data-dir/test @@ -0,0 +1,7 @@ +# run scoverage +> clean +> coverage +> test +> coverageReport +$ exists target/custom-test/scoverage-data +$ exists target/custom-test/scoverage-report \ No newline at end of file From 4324103419bd5d86420efbbbc8a97be542c29c9b Mon Sep 17 00:00:00 2001 From: Peter Zhong Date: Fri, 10 Sep 2021 12:06:14 -0700 Subject: [PATCH 47/49] Update src/main/scala/scoverage/ScoverageKeys.scala Co-authored-by: Chris Kipp --- src/main/scala/scoverage/ScoverageKeys.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/scoverage/ScoverageKeys.scala b/src/main/scala/scoverage/ScoverageKeys.scala index 2cc521b5..add12d0c 100644 --- a/src/main/scala/scoverage/ScoverageKeys.scala +++ b/src/main/scala/scoverage/ScoverageKeys.scala @@ -18,7 +18,7 @@ object ScoverageKeys { lazy val coverageOutputDebug = settingKey[Boolean]("turn on the debug report") lazy val coverageOutputTeamCity = settingKey[Boolean]("turn on teamcity reporting") lazy val coverageScalacPluginVersion = settingKey[String]("version of scalac-scoverage-plugin to use") - lazy val coverageDataDir = settingKey[File]("directory where the measurements will be stored to use") + lazy val coverageDataDir = settingKey[File]("directory where the measurements and report files will be stored") // format: on @deprecated("Use coverageMinimumStmtTotal instead", "v1.8.0") From 58ae1b39d81933d8aa802218837aab63b0a0f6c3 Mon Sep 17 00:00:00 2001 From: Peter Zhong Date: Fri, 10 Sep 2021 12:59:35 -0700 Subject: [PATCH 48/49] Update ScoverageSbtPlugin.scala --- src/main/scala/scoverage/ScoverageSbtPlugin.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/scoverage/ScoverageSbtPlugin.scala b/src/main/scala/scoverage/ScoverageSbtPlugin.scala index 59200f92..1e243a75 100644 --- a/src/main/scala/scoverage/ScoverageSbtPlugin.scala +++ b/src/main/scala/scoverage/ScoverageSbtPlugin.scala @@ -56,7 +56,7 @@ object ScoverageSbtPlugin extends AutoPlugin { addCommandAlias("coverageOn", ";set ThisBuild / coverageEnabled := true") ++ addCommandAlias("coverageOff", ";set ThisBuild / coverageEnabled := false") - override def projectSettings: Seq[Setting[_]] = super.projectSettings ++ Seq( + override def projectSettings: Seq[Setting[_]] = Seq( ivyConfigurations += ScoveragePluginConfig, coverageReport := coverageReport0.value, coverageAggregate := coverageAggregate0.value, From 12464424004aa94dd379edcd85935844eff9d9d2 Mon Sep 17 00:00:00 2001 From: Peter Zhong Date: Mon, 13 Sep 2021 12:16:39 -0700 Subject: [PATCH 49/49] Update build.sbt --- build.sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sbt b/build.sbt index f3b4aceb..c6f6b9bf 100644 --- a/build.sbt +++ b/build.sbt @@ -3,6 +3,7 @@ name := "sbt-scoverage" import sbt.ScriptedPlugin.autoImport.scriptedLaunchOpts def scoverageVersion = "1.4.8" +def version := "1.9.0-livongo-1.0.2" inThisBuild( List(