Skip to content

Commit

Permalink
Merge pull request #347 from ckipp01/scripted
Browse files Browse the repository at this point in the history
Update tests in scripted.
  • Loading branch information
ckipp01 authored May 7, 2021
2 parents 464cb01 + 6225254 commit db352b8
Show file tree
Hide file tree
Showing 23 changed files with 137 additions and 151 deletions.
18 changes: 9 additions & 9 deletions src/sbt-test/scoverage/aggregate-only/build.sbt
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
/*
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
)
}

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
}
Original file line number Diff line number Diff line change
@@ -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)
}
}
Original file line number Diff line number Diff line change
@@ -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)
}
}

10 changes: 5 additions & 5 deletions src/sbt-test/scoverage/aggregate-only/test
Original file line number Diff line number Diff line change
Expand Up @@ -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
$ exists target/scala-2.13/scoverage-report
18 changes: 9 additions & 9 deletions src/sbt-test/scoverage/aggregate/build.sbt
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
/*
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
)
}

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
}
Original file line number Diff line number Diff line change
@@ -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)
}
}
Original file line number Diff line number Diff line change
@@ -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)
}
}

10 changes: 5 additions & 5 deletions src/sbt-test/scoverage/aggregate/test
Original file line number Diff line number Diff line change
Expand Up @@ -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
$ exists target/scala-2.13/scoverage-report
7 changes: 4 additions & 3 deletions src/sbt-test/scoverage/bad-coverage/build.sbt
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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)
}
}
7 changes: 4 additions & 3 deletions src/sbt-test/scoverage/coverage-off/build.sbt
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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)
}
}
7 changes: 4 additions & 3 deletions src/sbt-test/scoverage/good-coverage/build.sbt
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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)
}
}
28 changes: 19 additions & 9 deletions src/sbt-test/scoverage/preserve-set/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Loading

0 comments on commit db352b8

Please sign in to comment.