aboutsummaryrefslogtreecommitdiff
path: root/project/Build.scala
diff options
context:
space:
mode:
authorvsalvis <salvisbergvera@gmail.com>2015-05-09 18:35:04 +0200
committervsalvis <salvisbergvera@gmail.com>2015-05-12 11:19:34 +0200
commitca3fc43bb3f9eb0068669acf6e64b3c6bd310511 (patch)
treeef7e0a16a5162d9f812b7e907b125944c3f1dd8e /project/Build.scala
parent2da8afdca1c357d6cada891c70e68e386c44c2f3 (diff)
downloaddotty-ca3fc43bb3f9eb0068669acf6e64b3c6bd310511.tar.gz
dotty-ca3fc43bb3f9eb0068669acf6e64b3c6bd310511.tar.bz2
dotty-ca3fc43bb3f9eb0068669acf6e64b3c6bd310511.zip
Run tests for partest
Diffstat (limited to 'project/Build.scala')
-rw-r--r--project/Build.scala44
1 files changed, 33 insertions, 11 deletions
diff --git a/project/Build.scala b/project/Build.scala
index 3f8a9b522..af8c51211 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -2,6 +2,7 @@ import sbt.Keys._
import sbt._
import java.io.{ RandomAccessFile, File }
import java.nio.channels.FileLock
+import scala.reflect.io.Path
object DottyBuild extends Build {
@@ -42,16 +43,16 @@ object DottyBuild extends Build {
// to get Scala 2.11
resolvers += Resolver.sonatypeRepo("releases"),
- // get reflect and xml onboard
- libraryDependencies ++= Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value,
- "org.scala-lang.modules" %% "scala-xml" % "1.0.1",
- "me.d-d" % "scala-compiler" % "2.11.5-20150506-175515-8fc7635b56",
+ // get libraries onboard
+ partestDeps := Seq("me.d-d" % "scala-compiler" % "2.11.5-20150506-175515-8fc7635b56",
+ "org.scala-lang" % "scala-reflect" % scalaVersion.value,
+ "org.scala-lang" % "scala-library" % scalaVersion.value % "test"),
+ libraryDependencies ++= partestDeps.value,
+ libraryDependencies ++= Seq("org.scala-lang.modules" %% "scala-xml" % "1.0.1",
"org.scala-lang.modules" %% "scala-partest" % "1.0.5" % "test",
+ "com.novocode" % "junit-interface" % "0.11" % "test",
"jline" % "jline" % "2.12"),
- // get junit onboard
- libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test",
-
// scalac options
scalacOptions in Global ++= Seq("-feature", "-deprecation", "-language:_"),
@@ -67,9 +68,18 @@ object DottyBuild extends Build {
// otherwise it just executes the tests directly
lockPartestFile := {
val partestLockFile = "." + File.separator + "tests" + File.separator + "partest.lock"
- partestLock = new RandomAccessFile(partestLockFile, "rw").getChannel.tryLock
+ try {
+ partestLock = new RandomAccessFile(partestLockFile, "rw").getChannel.tryLock
+ } catch {
+ case ex: java.nio.channels.OverlappingFileLockException => // locked already
+ }
+ },
+ runPartestRunner <<= Def.taskDyn {
+ val jars = Seq((packageBin in Compile).value.getAbsolutePath) ++
+ getJarPaths(partestDeps.value, ivyPaths.value.ivyHome)
+ val dottyJars = "-dottyJars " + jars.length + " " + jars.mkString(" ")
+ runTask(Test, "dotty.partest.DPConsoleRunner", dottyJars)
},
- runPartestRunner <<= runTask(Test, "dotty.partest.DPConsoleRunner", "") dependsOn (test in Test),
// Adjust classpath for running dotty
mainClass in (Compile, run) := Some("dotty.tools.dotc.Main"),
@@ -103,7 +113,7 @@ object DottyBuild extends Build {
tuning ::: agentOptions ::: travis_build ::: fullpath
}
- ) ++ addCommandAlias("partest", ";lockPartestFile;runPartestRunner")
+ ) ++ addCommandAlias("partest", ";test:compile;lockPartestFile;test:test;runPartestRunner")
lazy val dotty = Project(id = "dotty", base = file("."), settings = defaults)
@@ -156,5 +166,17 @@ object DottyBuild extends Build {
lazy val lockPartestFile = TaskKey[Unit]("lockPartestFile", "Creates the file lock on ./tests/partest.lock")
lazy val runPartestRunner = TaskKey[Unit]("runPartestRunner", "Runs partests")
-
+ 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")
+ }
}