Skip to content

Commit 0e70049

Browse files
gkossakowskiadriaanm
authored andcommitted
test/it:test runs partest regression tests
Partest tests are defined in Integration configuration. This means you need to run them with `test/it:test` command. We put them in separate configuration because they are slow to run so user needs to ask explicitly for partest to run. Introduce a common way of setting jar location so it can be reused between `scalaSubprojectSettings` and `partestJavaAgent`.
1 parent dbb5274 commit 0e70049

File tree

1 file changed

+60
-2
lines changed

1 file changed

+60
-2
lines changed

build.sbt

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@ val bootstrapScalaVersion = "2.11.5"
5656
val scalaParserCombinatorsDep = "org.scala-lang.modules" %% "scala-parser-combinators" % versionNumber("scala-parser-combinators") exclude("org.scala-lang", "scala-library")
5757
val scalaXmlDep = "org.scala-lang.modules" %% "scala-xml" % versionNumber("scala-xml") exclude("org.scala-lang", "scala-library")
5858
val partestDep = "org.scala-lang.modules" %% "scala-partest" % versionNumber("partest") exclude("org.scala-lang", "scala-library")
59+
val partestInterfaceDep = "org.scala-lang.modules" %% "scala-partest-interface" % "0.5.0" exclude("org.scala-lang", "scala-library")
5960
val junitDep = "junit" % "junit" % "4.11"
6061
val junitIntefaceDep = "com.novocode" % "junit-interface" % "0.11" % "test"
6162
val jlineDep = "jline" % "jline" % versionProps("jline.version")
6263
val antDep = "org.apache.ant" % "ant" % "1.9.4"
64+
val scalacheckDep = "org.scalacheck" %% "scalacheck" % "1.11.4" exclude("org.scala-lang", "scala-library")
6365

6466
lazy val commonSettings = clearSourceAndResourceDirectories ++ Seq[Setting[_]](
6567
organization := "org.scala-lang",
@@ -111,7 +113,7 @@ val disableDocsAndPublishingTasks = Seq[Setting[_]](
111113
packageBin in Compile := file("!!! NO PACKAGING !!!")
112114
)
113115

114-
lazy val scalaSubprojectSettings = commonSettings ++ Seq[Setting[_]](
116+
lazy val setJarLocation: Setting[_] =
115117
artifactPath in packageBin in Compile := {
116118
// two lines below are copied over from sbt's sources:
117119
// https://github.com/sbt/sbt/blob/0.13/main/src/main/scala/sbt/Defaults.scala#L628
@@ -123,7 +125,7 @@ lazy val scalaSubprojectSettings = commonSettings ++ Seq[Setting[_]](
123125
val resolvedArtifactName = s"${resolvedArtifact.name}.${resolvedArtifact.extension}"
124126
buildDirectory.value / "pack/lib" / resolvedArtifactName
125127
}
126-
)
128+
lazy val scalaSubprojectSettings: Seq[Setting[_]] = commonSettings :+ setJarLocation
127129

128130
lazy val generatePropertiesFileSettings = Seq[Setting[_]](
129131
copyrightString := "Copyright 2002-2013, LAMP/EPFL",
@@ -179,6 +181,10 @@ lazy val compiler = configureAsSubproject(project)
179181

180182
lazy val interactive = configureAsSubproject(project)
181183
.settings(disableDocsAndPublishingTasks: _*)
184+
.settings(
185+
scalaVersion := bootstrapScalaVersion,
186+
ivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) }
187+
)
182188
.dependsOn(compiler)
183189

184190
lazy val repl = configureAsSubproject(project)
@@ -230,6 +236,58 @@ lazy val junit = project.in(file("test") / "junit")
230236
unmanagedSourceDirectories in Test := List(baseDirectory.value)
231237
)
232238

239+
lazy val partestJavaAgent = (project in file(".") / "src" / "partest-javaagent").
240+
dependsOn(asm).
241+
settings(commonSettings: _*).
242+
settings(
243+
doc := file("!!! NO DOCS !!!"),
244+
publishLocal := {},
245+
publish := {},
246+
scalaVersion := bootstrapScalaVersion,
247+
ivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) },
248+
// Setting name to "scala-partest-javaagent" so that the jar file gets that name, which the Runner relies on
249+
name := "scala-partest-javaagent",
250+
// writing jar file to $buildDirectory/pack/lib because that's where it's expected to be found
251+
setJarLocation,
252+
// add required manifest entry - previously included from file
253+
packageOptions in (Compile, packageBin) +=
254+
Package.ManifestAttributes( "Premain-Class" -> "scala.tools.partest.javaagent.ProfilingAgent" ),
255+
// we need to build this to a JAR
256+
exportJars := true
257+
)
258+
259+
lazy val test = project.
260+
dependsOn(compiler, interactive, actors, repl, scalap, partestExtras, partestJavaAgent, asm, scaladoc).
261+
configs(IntegrationTest).
262+
settings(disableDocsAndPublishingTasks: _*).
263+
settings(commonSettings: _*).
264+
settings(Defaults.itSettings: _*).
265+
settings(
266+
scalaVersion := bootstrapScalaVersion,
267+
ivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) },
268+
libraryDependencies ++= Seq(partestDep, scalaXmlDep, partestInterfaceDep, scalacheckDep),
269+
unmanagedBase in Test := baseDirectory.value / "files" / "lib",
270+
unmanagedJars in Test <+= (unmanagedBase) (j => Attributed.blank(j)) map(identity),
271+
// no main sources
272+
sources in Compile := Seq.empty,
273+
// test sources are compiled in partest run, not here
274+
sources in IntegrationTest := Seq.empty,
275+
fork in IntegrationTest := true,
276+
javaOptions in IntegrationTest += "-Xmx1G",
277+
testFrameworks += new TestFramework("scala.tools.partest.Framework"),
278+
testOptions in IntegrationTest += Tests.Setup( () => root.base.getAbsolutePath + "/pull-binary-libs.sh" ! ),
279+
definedTests in IntegrationTest += (
280+
new sbt.TestDefinition(
281+
"partest",
282+
// marker fingerprint since there are no test classes
283+
// to be discovered by sbt:
284+
new sbt.testing.AnnotatedFingerprint {
285+
def isModule = true
286+
def annotationName = "partest"
287+
}, true, Array())
288+
)
289+
)
290+
233291
lazy val root = (project in file(".")).
234292
aggregate(library, forkjoin, reflect, compiler, asm, interactive, repl,
235293
scaladoc, scalap, actors, partestExtras, junit).settings(

0 commit comments

Comments
 (0)