aboutsummaryrefslogtreecommitdiff
path: root/project/Build.scala
diff options
context:
space:
mode:
Diffstat (limited to 'project/Build.scala')
-rw-r--r--project/Build.scala138
1 files changed, 80 insertions, 58 deletions
diff --git a/project/Build.scala b/project/Build.scala
index ce560d8e4..bb02416cc 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -47,6 +47,9 @@ object Build {
// Spawns a repl with the correct classpath
lazy val repl = inputKey[Unit]("run the REPL with correct classpath")
+ // Run tests with filter
+ lazy val filterTest = inputKey[Unit]("runs integration test with the supplied filter")
+
// Used to compile files similar to ./bin/dotc script
lazy val dotc =
inputKey[Unit]("run the compiler using the correct classpath, or the user supplied classpath")
@@ -276,23 +279,57 @@ object Build {
com.typesafe.sbteclipse.plugin.EclipsePlugin.EclipseKeys.withSource := true,
// get libraries onboard
- partestDeps := Seq(scalaCompiler,
- "org.scala-lang" % "scala-reflect" % scalacVersion,
- "org.scala-lang" % "scala-library" % scalacVersion % "test"),
- libraryDependencies ++= partestDeps.value,
- libraryDependencies ++= Seq("org.scala-lang.modules" %% "scala-xml" % "1.0.1",
- "org.scala-lang.modules" %% "scala-partest" % "1.0.11" % "test",
- "com.novocode" % "junit-interface" % "0.11" % "test"),
-
resolvers += Resolver.typesafeIvyRepo("releases"), // For org.scala-sbt:interface
- libraryDependencies += "org.scala-sbt" % "interface" % sbtVersion.value,
+ libraryDependencies ++= Seq(scalaCompiler,
+ "org.scala-sbt" % "interface" % sbtVersion.value,
+ "org.scala-lang.modules" %% "scala-xml" % "1.0.1",
+ "com.novocode" % "junit-interface" % "0.11" % "test",
+ "org.scala-lang" % "scala-reflect" % scalacVersion,
+ "org.scala-lang" % "scala-library" % scalacVersion % "test"),
+
+ // start partest specific settings:
+ libraryDependencies += "org.scala-lang.modules" %% "scala-partest" % "1.0.11" % "test",
+ testOptions in Test += Tests.Cleanup({ () => partestLockFile.delete }),
+ // this option is needed so that partest doesn't run
+ partestDeps := Seq(
+ scalaCompiler,
+ "org.scala-lang" % "scala-reflect" % scalacVersion,
+ "org.scala-lang" % "scala-library" % scalacVersion % "test"
+ ),
+ lockPartestFile := {
+ // When this file is present, running `test` generates the files for
+ // partest. Otherwise it just executes the tests directly.
+ val lockDir = partestLockFile.getParentFile
+ lockDir.mkdirs
+ // Cannot have concurrent partests as they write to the same directory.
+ if (lockDir.list.size > 0)
+ throw new RuntimeException("ERROR: sbt partest: another partest is already running, pid in lock file: " + lockDir.list.toList.mkString(" "))
+ partestLockFile.createNewFile
+ partestLockFile.deleteOnExit
+ },
+ runPartestRunner := Def.inputTaskDyn {
+ // Magic! This is both an input task and a dynamic task. Apparently
+ // command line arguments get passed to the last task in an aliased
+ // sequence (see partest alias below), so this works.
+ val args = Def.spaceDelimited("<arg>").parsed
+ val jars = List(
+ (packageBin in Compile).value.getAbsolutePath,
+ packageAll.value("dotty-library"),
+ packageAll.value("dotty-interfaces")
+ ) ++ getJarPaths(partestDeps.value, ivyPaths.value.ivyHome)
+ val dottyJars =
+ s"""-dottyJars ${jars.length + 2} dotty.jar dotty-lib.jar ${jars.mkString(" ")}"""
+ // Provide the jars required on the classpath of run tests
+ runTask(Test, "dotty.partest.DPConsoleRunner", dottyJars + " " + args.mkString(" "))
+ }.evaluated,
+ // end partest specific settings
// enable improved incremental compilation algorithm
incOptions := incOptions.value.withNameHashing(true),
// For convenience, change the baseDirectory when running the compiler
baseDirectory in (Compile, run) := baseDirectory.value / "..",
- // .. but not when running partest
+ // .. but not when running test
baseDirectory in (Test, run) := baseDirectory.value,
repl := Def.inputTaskDyn {
@@ -303,6 +340,14 @@ object Build {
)
}.evaluated,
+ filterTest := Def.inputTaskDyn {
+ val args: Seq[String] = spaceDelimited("<arg>").parsed
+ testOptions := Seq()
+ (testOnly in Test).toTask(
+ " dotty.tools.dotc.CompilationTests -- -Ddotty.partest.filter=" + args.head
+ )
+ }.evaluated,
+
// Override run to be able to run compiled classfiles
dotr := {
val args: Seq[String] = spaceDelimited("<arg>").parsed
@@ -343,34 +388,6 @@ object Build {
TestFrameworks.JUnit, "-a", "-v",
"--run-listener=dotty.tools.ContextEscapeDetector"
),
- testOptions in Test += Tests.Cleanup({ () => partestLockFile.delete }),
-
- lockPartestFile := {
- // When this file is present, running `test` generates the files for
- // partest. Otherwise it just executes the tests directly.
- val lockDir = partestLockFile.getParentFile
- lockDir.mkdirs
- // Cannot have concurrent partests as they write to the same directory.
- if (lockDir.list.size > 0)
- throw new RuntimeException("ERROR: sbt partest: another partest is already running, pid in lock file: " + lockDir.list.toList.mkString(" "))
- partestLockFile.createNewFile
- partestLockFile.deleteOnExit
- },
- runPartestRunner := Def.inputTaskDyn {
- // Magic! This is both an input task and a dynamic task. Apparently
- // command line arguments get passed to the last task in an aliased
- // sequence (see partest alias below), so this works.
- val args = Def.spaceDelimited("<arg>").parsed
- val jars = List(
- (packageBin in Compile).value.getAbsolutePath,
- packageAll.value("dotty-library"),
- packageAll.value("dotty-interfaces")
- ) ++ getJarPaths(partestDeps.value, ivyPaths.value.ivyHome)
- val dottyJars =
- s"""-dottyJars ${jars.length + 2} dotty.jar dotty-lib.jar ${jars.mkString(" ")}"""
- // Provide the jars required on the classpath of run tests
- runTask(Test, "dotty.partest.DPConsoleRunner", dottyJars + " " + args.mkString(" "))
- }.evaluated,
/* Add the sources of scalajs-ir.
* To guarantee that dotty can bootstrap without depending on a version
@@ -458,6 +475,31 @@ object Build {
}
)
+ // Partest tasks
+ lazy val partestDeps =
+ SettingKey[Seq[ModuleID]]("partestDeps", "Finds jars for partest dependencies")
+ lazy val runPartestRunner =
+ InputKey[Unit]("runPartestRunner", "Runs partest")
+ lazy val lockPartestFile =
+ TaskKey[Unit]("lockPartestFile", "Creates the lock file at ./tests/locks/partest-<pid>.lock")
+ lazy val partestLockFile =
+ new File("." + File.separator + "tests" + File.separator + "locks" + File.separator + s"partest-$pid.lock")
+
+ def pid = java.lang.Long.parseLong(java.lang.management.ManagementFactory.getRuntimeMXBean().getName().split("@")(0))
+
+ def getJarPaths(modules: Seq[ModuleID], ivyHome: Option[File]): Seq[String] = ivyHome match {
+ case Some(home) =>
+ modules.map({ module =>
+ val file = Path(home) / Path("cache") /
+ Path(module.organization) / Path(module.name) / Path("jars") /
+ Path(module.name + "-" + module.revision + ".jar")
+ if (!file.isFile) throw new RuntimeException("ERROR: sbt getJarPaths: dependency jar not found: " + file)
+ else file.jfile.getAbsolutePath
+ })
+ case None => throw new RuntimeException("ERROR: sbt getJarPaths: ivyHome not defined")
+ }
+ // end partest tasks
+
lazy val `dotty-compiler` = project.in(file("compiler")).
dependsOn(`dotty-interfaces`).
dependsOn(`dotty-library`).
@@ -793,26 +835,6 @@ object DottyInjectedPlugin extends AutoPlugin {
)
)
- // Partest tasks
- lazy val lockPartestFile = TaskKey[Unit]("lockPartestFile", "Creates the lock file at ./tests/locks/partest-<pid>.lock")
- lazy val partestLockFile = new File("." + File.separator + "tests" + File.separator + "locks" + File.separator + s"partest-$pid.lock")
- def pid = java.lang.Long.parseLong(java.lang.management.ManagementFactory.getRuntimeMXBean().getName().split("@")(0))
-
- lazy val runPartestRunner = InputKey[Unit]("runPartestRunner", "Runs partest")
-
- lazy val partestDeps = SettingKey[Seq[ModuleID]]("partestDeps", "Finds jars for partest dependencies")
- def getJarPaths(modules: Seq[ModuleID], ivyHome: Option[File]): Seq[String] = ivyHome match {
- case Some(home) =>
- modules.map({ module =>
- val file = Path(home) / Path("cache") /
- Path(module.organization) / Path(module.name) / Path("jars") /
- Path(module.name + "-" + module.revision + ".jar")
- if (!file.isFile) throw new RuntimeException("ERROR: sbt getJarPaths: dependency jar not found: " + file)
- else file.jfile.getAbsolutePath
- })
- case None => throw new RuntimeException("ERROR: sbt getJarPaths: ivyHome not defined")
- }
-
// Compile with dotty
lazy val compileWithDottySettings = {
inConfig(Compile)(inTask(compile)(Defaults.runnerTask) ++ Seq(