Skip to content

sbt-test to verify that scala.js is supported by scoverage #167

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
Jun 1, 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
12 changes: 12 additions & 0 deletions src/sbt-test/scoverage/scalajs/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
lazy val root = (project in file(".")).aggregate(crossJS, crossJVM)

lazy val cross = crossProject.in(file("sjstest")).settings(
scalaVersion := "2.11.7",
libraryDependencies ++= Seq(
"org.scalatest" %%% "scalatest" % "3.0.0-M15" % "test"
)
)


lazy val crossJS = cross.js
lazy val crossJVM = cross.jvm
15 changes: 15 additions & 0 deletions src/sbt-test/scoverage/scalajs/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

//scoverage needs this
resolvers += Classpaths.sbtPluginReleases

{
val pluginVersion = System.getProperty("plugin.version")
if(pluginVersion == null)
throw new RuntimeException("""|The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin)
else addSbtPlugin("org.scoverage" %% "sbt-scoverage" % pluginVersion)
}

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.8")
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import org.scalatest.{FlatSpec, Matchers}

class JsTest extends FlatSpec with Matchers {

"JS UnderTest" should "work on JS" in {
UnderTest.jsMethod shouldBe "js"
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import org.scalatest.{FlatSpec, Matchers}

class JvmTest extends FlatSpec with Matchers {

"JVM UnderTest" should "work on JVM" in {
UnderTest.jvmMethod shouldBe "jvm"
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

object UnderTest {
def onJsAndJvm: String = "js and jvm"

def jsMethod: String = "js"

def jvmMethod: String = "jvm"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import org.scalatest.{FlatSpec, Matchers}

class SharedTest extends FlatSpec with Matchers {

"Shared UnderTest" should "return where it works" in {
UnderTest.onJsAndJvm shouldBe "js and jvm"
}

}
11 changes: 11 additions & 0 deletions src/sbt-test/scoverage/scalajs/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# run scoverage using the coverage task
> clean
> coverage
> test
# There should be scoverage-data directory
$ exists sjstest/js/target/scala-2.11/scoverage-data
$ exists sjstest/jvm/target/scala-2.11/scoverage-data
> coverageReport
# There should be scoverage-report directory
$ exists sjstest/js/target/scala-2.11/scoverage-report
$ exists sjstest/jvm/target/scala-2.11/scoverage-report