Skip to content

Build fixes. Tests compatible with Scala 2.10 and 2.11 (previously only with 2.11) #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
*.class
*.log

.idea
.idea_modules

# sbt specific
dist/*
# SBT specific
target/
lib_managed/
src_managed/
project/boot/
project/plugins/project/
credentials.sbt
*.icode

# Eclipse specific
.classpath
.project
.settings/

# Scala-IDE specific
.scala_dependencies
.cache-main
.cache-tests

# IntelliJ IDEA specific
.idea
.idea_modules
*.iml
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
language: scala

scala:
- 2.11.4
- 2.10.6
- 2.11.8

script:
- "sbt clean test"
- sbt ++$TRAVIS_SCALA_VERSION test

jdk:
- oraclejdk7
49 changes: 0 additions & 49 deletions project/EnvSupport.scala

This file was deleted.

14 changes: 4 additions & 10 deletions project/Scoverage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
object Scoverage extends Build {

val Org = "org.scoverage"
val Scala = "2.11.7"
val MockitoVersion = "1.9.5"
val ScalatestVersion = "3.0.0-M15"
val ScalatestVersion = "3.0.0"

lazy val LocalTest = config("local") extend Test

val appSettings = Seq(
organization := Org,
scalaVersion := Scala,
crossScalaVersions := Seq("2.10.6", "2.11.7"),
scalaVersion := "2.11.8",
crossScalaVersions := Seq("2.10.6", "2.11.8"),
fork in Test := false,
publishMavenStyle := true,
publishArtifact in Test := false,
Expand Down Expand Up @@ -70,7 +69,6 @@ object Scoverage extends Build {
.settings(name := "scalac-scoverage")
.settings(appSettings: _*)
.settings(publishArtifact := false)
.settings(javaOptions += "-XX:MaxMetaspaceSize=2048m")
.aggregate(plugin, runtime.jvm, runtime.js)

lazy val runtime = CrossProject("scalac-scoverage-runtime", file("scalac-scoverage-runtime"), CrossType.Full)
Expand All @@ -80,8 +78,7 @@ object Scoverage extends Build {
libraryDependencies ++= Seq(
"org.mockito" % "mockito-all" % MockitoVersion % "test",
"org.scalatest" %% "scalatest" % ScalatestVersion % "test"
),
javaOptions += "-XX:MaxMetaspaceSize=2048m"
)
)
.jsSettings(
libraryDependencies += "org.scalatest" %%% "scalatest" % ScalatestVersion,
Expand All @@ -95,7 +92,6 @@ object Scoverage extends Build {
.dependsOn(`scalac-scoverage-runtimeJVM` % "test")
.settings(name := "scalac-scoverage-plugin")
.settings(appSettings: _*)
.settings(javaOptions += "-XX:MaxMetaspaceSize=2048m")
.settings(libraryDependencies ++= Seq(
"org.mockito" % "mockito-all" % MockitoVersion % "test",
"org.scalatest" %% "scalatest" % ScalatestVersion % "test",
Expand All @@ -107,10 +103,8 @@ object Scoverage extends Build {
)).settings(libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, scalaMajor)) if scalaMajor == 11 =>
EnvSupport.setEnv("CrossBuildScalaVersion", "2.11.7")
Seq("org.scala-lang.modules" %% "scala-xml" % "1.0.4")
case _ =>
EnvSupport.setEnv("CrossBuildScalaVersion", "2.10.6")
Nil
}
})
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.11
sbt.version=0.13.12
70 changes: 0 additions & 70 deletions project/scales-build.iml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ class CoberturaXmlWriterTest extends FunSuite with BeforeAndAfter with OneInstan

val xml = XML.loadFile(fileIn(dir))

assert(xml \\ "coverage" \@ "line-rate" === "0.33", "line-rate")
assert(xml \\ "coverage" \@ "branch-rate" === "0.50", "branch-rate")
assert((xml \\ "coverage" \ "@line-rate").text === "0.33", "line-rate")
assert((xml \\ "coverage" \ "@branch-rate").text === "0.50", "branch-rate")

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package scoverage
import java.io.{File, FileWriter}
import java.util.UUID

import org.scalatest.mock.MockitoSugar
import org.scalatest.mockito.MockitoSugar
import org.scalatest.{FreeSpec, Matchers, OneInstancePerTest}

/** @author Stephen Samuel */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package scoverage

import org.scalatest.mock.MockitoSugar
import org.scalatest.mockito.MockitoSugar
import org.scalatest._

/** @author Stephen Samuel */
Expand Down Expand Up @@ -98,7 +98,7 @@ class PluginASTSupportTest
compiler.compileCodeSnippet( """object Foo {
| final val foo = 1L
|}
|@SerialVersionUID(value = Foo.foo)
|@SerialVersionUID(Foo.foo)
|class Bar
|""".stripMargin)
assert(!compiler.reporter.hasErrors)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package scoverage

import org.scalatest.mock.MockitoSugar
import org.scalatest.mockito.MockitoSugar
import org.scalatest.{BeforeAndAfterEachTestData, FunSuite, OneInstancePerTest}

/** @author Stephen Samuel */
Expand All @@ -27,7 +27,19 @@ class PluginCoverageTest

test("scoverage should skip macros") {
val compiler = ScoverageCompiler.default
val code = """
val code = if (ScoverageCompiler.ShortScalaVersion == "2.10")
"""
import scala.language.experimental.macros
import scala.reflect.macros.Context
object Impl {
def poly[T: c.WeakTypeTag](c: Context) = c.literal(c.weakTypeOf[T].toString)
}

object Macros {
def poly[T] = macro Impl.poly[T]
}"""
else
"""
import scala.language.experimental.macros
import scala.reflect.macros.Context
class Impl(val c: Context) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package scoverage

import org.mockito.Mockito
import org.scalatest.mock.MockitoSugar
import org.scalatest.mockito.MockitoSugar
import org.scalatest.{FreeSpec, Matchers}

import scala.reflect.internal.util._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import scala.tools.nsc.transform.{Transform, TypingTransformers}
/** @author Stephen Samuel */
object ScoverageCompiler {

val ScalaVersion = "2.11.7"
val ScalaVersion = scala.util.Properties.versionNumberString
val ShortScalaVersion = ScalaVersion.dropRight(2)

def classPath = getScalaJars.map(_.getAbsolutePath) :+ sbtCompileDir.getAbsolutePath :+ runtimeClasses.getAbsolutePath
Expand Down Expand Up @@ -45,13 +45,13 @@ object ScoverageCompiler {
}

private def sbtCompileDir: File = {
val dir = new File("./scalac-scoverage-plugin/target/scala-" + ShortScalaVersion + "/classes")
val dir = new File(s"./scalac-scoverage-plugin/target/scala-$ShortScalaVersion/classes")
if (!dir.exists)
throw new FileNotFoundException(s"Could not locate SBT compile directory for plugin files [$dir]")
dir
}

private def runtimeClasses: File = new File("./scalac-scoverage-runtime/jvm/target/scala-2.11/classes")
private def runtimeClasses: File = new File(s"./scalac-scoverage-runtime/jvm/target/scala-$ShortScalaVersion/classes")

private def findScalaJar(artifactId: String): File = findIvyJar("org.scala-lang", artifactId, ScalaVersion)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package scoverage
import java.io.StringWriter

import org.scalatest.{OneInstancePerTest, FunSuite}
import org.scalatest.mock.MockitoSugar
import org.scalatest.mockito.MockitoSugar

import scala.xml.Utility

Expand Down