aboutsummaryrefslogtreecommitdiff
path: root/project
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2017-03-27 14:11:23 +0200
committerFelix Mulder <felix.mulder@gmail.com>2017-03-29 10:33:26 +0200
commitf7e3b7002d1eefbeaac3970be4ac729843d6a939 (patch)
tree30858a140e475153c9b6e18a10a5e5159ba615be /project
parent1ab7c038e7daed1f05aafa000a284d76ddacb381 (diff)
downloaddotty-f7e3b7002d1eefbeaac3970be4ac729843d6a939.tar.gz
dotty-f7e3b7002d1eefbeaac3970be4ac729843d6a939.tar.bz2
dotty-f7e3b7002d1eefbeaac3970be4ac729843d6a939.zip
Restore partest and enable it to run alongside new partest
Diffstat (limited to 'project')
-rw-r--r--project/Build.scala87
1 files changed, 85 insertions, 2 deletions
diff --git a/project/Build.scala b/project/Build.scala
index ae7672248..baebaedf5 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -131,7 +131,27 @@ object Build {
settings(
triggeredMessage in ThisBuild := Watched.clearWhenTriggered,
- addCommandAlias("run", "dotty-compiler/run")
+ addCommandAlias("run", "dotty-compiler/run") ++
+ addCommandAlias(
+ "partest",
+ ";publishLocal" + // Non-bootstrapped dotty needs to be published first
+ ";dotty-compiler-bootstrapped/lockPartestFile" +
+ ";dotty-compiler-bootstrapped/test:test" +
+ ";dotty-compiler-bootstrapped/runPartestRunner"
+ ) ++
+ addCommandAlias(
+ "partest-only",
+ ";publishLocal" + // Non-bootstrapped dotty needs to be published first
+ ";dotty-compiler-bootstrapped/lockPartestFile" +
+ ";dotty-compiler-bootstrapped/test:test-only dotc.tests" +
+ ";dotty-compiler-bootstrapped/runPartestRunner"
+ ) ++
+ addCommandAlias(
+ "partest-only-no-bootstrap",
+ ";dotty-compiler/lockPartestFile" +
+ ";dotty-compiler/test:test-only dotc.tests" +
+ ";dotty-compiler/runPartestRunner"
+ )
).
settings(publishing)
@@ -264,6 +284,44 @@ object Build {
"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
+ testOptions += Tests.Argument(TestFrameworks.JUnit, "--exclude-categories=dotty.tools.dotc.ParallelTesting"),
+ 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),
@@ -403,10 +461,35 @@ object Build {
"-Ddotty.tests.classes.compiler=" + pA("dotty-compiler")
)
- jars ::: tuning ::: agentOptions ::: ci_build ::: path.toList
+ ("-DpartestParentID=" + pid) :: jars ::: tuning ::: agentOptions ::: ci_build ::: path.toList
}
)
+ // 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`).