Skip to content

Commit e212757

Browse files
committed
Merge pull request #113 from gregsymons/coverage-off
Coverage off
2 parents 4af7a7a + e6dfe0c commit e212757

File tree

15 files changed

+81
-17
lines changed

15 files changed

+81
-17
lines changed

.travis.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
language: scala
22

3+
script: sbt ++$TRAVIS_SCALA_VERSION test scripted
4+
35
after_script:
4-
- if [[ $TRAVIS_TEST_RESULT == 0 && "$TRAVIS_BRANCH" == "master" ]]; then sbt "^publish"; fi
6+
- if [[ $TRAVIS_TEST_RESULT == 0 &&
7+
"$TRAVIS_REPO_SLUG" == "scoverage/sbt-scoverage" &&
8+
"$TRAVIS_BRANCH" == "master" ]]; then sbt "^publish"; fi
59

610
scala:
7-
- "2.10.4"
11+
- "2.10.4"

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ $ sbt coverageReport
3434

3535
to generate the reports. You will find the coverage reports inside `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.
3636

37+
If you're running the coverage reports from within an sbt console session (as
38+
opposed to one command per sbt launch), then the `coverage` task is sticky. To
39+
turn it back off when you're done running reports, use the `coverageOff` task.
40+
3741
If you want to see a project that is already setup to use scoverage in both sbt and maven, then clone [the scoverage samples project](https://github.com/scoverage/scoverage-samples).
3842

3943
## Notes on upgrading to version 1.0.0

build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name := "sbt-scoverage"
22

33
organization := "org.scoverage"
44

5-
scalaVersion := "2.10.4"
5+
scalaVersion := "2.10.5"
66

77
scalacOptions := Seq("-unchecked", "-deprecation", "-feature", "-encoding", "utf8")
88

@@ -16,7 +16,7 @@ resolvers <++= isSnapshot(
1616
)
1717

1818
libraryDependencies ++= Seq(
19-
"org.scoverage" %% "scalac-scoverage-plugin" % "1.0.5-SNAPSHOT"
19+
"org.scoverage" %% "scalac-scoverage-plugin" % "1.1.0"
2020
)
2121

2222
publishTo := {

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.13.5
1+
sbt.version=0.13.7

src/main/scala/scoverage/ScoverageSbtPlugin.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ class ScoverageSbtPlugin extends sbt.AutoPlugin {
1111
val OrgScoverage = "org.scoverage"
1212
val ScalacRuntimeArtifact = "scalac-scoverage-runtime"
1313
val ScalacPluginArtifact = "scalac-scoverage-plugin"
14-
val ScoverageVersion = "1.0.5-SNAPSHOT"
14+
val ScoverageVersion = "1.1.0"
1515

1616
object ScoverageKeys {
1717
lazy val coverage = taskKey[Unit]("enable compiled code with instrumentation")
18+
lazy val coverageOff = taskKey[Unit]("disable compiled code with instrumentation")
1819
lazy val coverageReport = taskKey[Unit]("run report generation")
1920
lazy val coverageAggregate = taskKey[Unit]("aggregate reports from subprojects")
2021
val coverageExcludedPackages = settingKey[String]("regex for excluded packages")
@@ -42,6 +43,10 @@ class ScoverageSbtPlugin extends sbt.AutoPlugin {
4243
enabled = true
4344
},
4445

46+
coverageOff := {
47+
enabled = false
48+
},
49+
4550
coverageReport := {
4651
val target = crossTarget.value
4752
val s = (streams in Global).value

src/sbt-test/scoverage/bad-coverage/build.sbt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ scalaVersion := "2.10.4"
44

55
libraryDependencies += "org.specs2" %% "specs2" % "2.3.13" % "test"
66

7-
instrumentSettings
7+
ScoverageSbtPlugin.ScoverageKeys.coverageMinimum := 80
88

9-
ScoverageKeys.minimumCoverage := 80
10-
11-
ScoverageKeys.failOnMinimumCoverage := true
9+
ScoverageSbtPlugin.ScoverageKeys.coverageFailOnMinimum := true
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# run scoverage
22
> clean
3-
-> scoverage:test
3+
> coverage
4+
-> test
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version := "0.1"
2+
3+
scalaVersion := "2.10.4"
4+
5+
libraryDependencies += "org.specs2" %% "specs2" % "2.3.13" % "test"
6+
7+
ScoverageSbtPlugin.ScoverageKeys.coverageMinimum := 80
8+
9+
ScoverageSbtPlugin.ScoverageKeys.coverageFailOnMinimum := true
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// The Typesafe repository
2+
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
3+
4+
//scoverage needs this
5+
resolvers += Classpaths.sbtPluginReleases
6+
7+
{
8+
val pluginVersion = System.getProperty("plugin.version")
9+
if(pluginVersion == null)
10+
throw new RuntimeException("""|The system property 'plugin.version' is not defined.
11+
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin)
12+
else addSbtPlugin("org.scoverage" %% "sbt-scoverage" % pluginVersion)
13+
}
14+
15+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object GoodCoverage {
2+
3+
def sum(num1: Int, num2: Int) = {
4+
num1 + num2
5+
}
6+
}

0 commit comments

Comments
 (0)