Skip to content

Commit e9e3940

Browse files
vsalvisDarkDimius
authored andcommitted
Partest command line options (same as scala) useable from sbt
1 parent cb5b6a0 commit e9e3940

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

project/Build.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,16 @@ object DottyBuild extends Build {
7474
partestLockFile.createNewFile
7575
partestLockFile.deleteOnExit
7676
},
77-
runPartestRunner <<= Def.taskDyn {
77+
runPartestRunner <<= Def.inputTaskDyn {
78+
// Magic! This is both an input task and a dynamic task. Apparently
79+
// command line arguments get passed to the last task in an aliased
80+
// sequence (see partest alias below), so this works.
81+
val args = Def.spaceDelimited("<arg>").parsed
7882
val jars = Seq((packageBin in Compile).value.getAbsolutePath) ++
7983
getJarPaths(partestDeps.value, ivyPaths.value.ivyHome)
8084
val dottyJars = "-dottyJars " + jars.length + " " + jars.mkString(" ")
8185
// Provide the jars required on the classpath of run tests
82-
runTask(Test, "dotty.partest.DPConsoleRunner", dottyJars)
86+
runTask(Test, "dotty.partest.DPConsoleRunner", dottyJars + " " + args.mkString(" "))
8387
},
8488

8589
// Adjust classpath for running dotty
@@ -170,7 +174,7 @@ object DottyBuild extends Build {
170174
lazy val partestLockFile = new File("." + File.separator + "tests" + File.separator + "locks" + File.separator + s"partest-$pid.lock")
171175
def pid = java.lang.Long.parseLong(java.lang.management.ManagementFactory.getRuntimeMXBean().getName().split("@")(0))
172176

173-
lazy val runPartestRunner = TaskKey[Unit]("runPartestRunner", "Runs partest")
177+
lazy val runPartestRunner = InputKey[Unit]("runPartestRunner", "Runs partest")
174178

175179
lazy val partestDeps = SettingKey[Seq[ModuleID]]("partestDeps", "Finds jars for partest dependencies")
176180
def getJarPaths(modules: Seq[ModuleID], ivyHome: Option[File]): Seq[String] = ivyHome match {

test/dotty/partest/DPConsoleRunner.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,24 @@ object DPConsoleRunner {
2323
// extra jars for run tests are passed with -dottyJars <count> <jar1> <jar2> ...
2424
val jarFinder = """-dottyJars (\d*) (.*)""".r
2525
val (jarList, otherArgs) = args.toList.partition(jarFinder.findFirstIn(_).isDefined)
26-
val extraJars = jarList match {
26+
val (extraJars, moreArgs) = jarList match {
2727
case Nil => sys.error("Error: DPConsoleRunner needs \"-dottyJars <jarCount> <jars>*\".")
2828
case jarFinder(nr, jarString) :: Nil =>
2929
val jars = jarString.split(" ").toList
30-
if (jars.length.toString != nr)
31-
sys.error("Error: DPConsoleRunner found wrong number of dottyJars: " + jars + ", expected: " + nr + ". Make sure the path doesn't contain any spaces.")
32-
else jars
30+
val count = nr.toInt
31+
if (jars.length < count)
32+
sys.error("Error: DPConsoleRunner found wrong number of dottyJars: " + jars + ", expected: " + nr)
33+
else (jars.take(count), jars.drop(count))
3334
case list => sys.error("Error: DPConsoleRunner found several -dottyJars options: " + list)
3435
}
35-
new DPConsoleRunner(otherArgs mkString (" "), extraJars).runPartest
36+
new DPConsoleRunner((otherArgs ::: moreArgs) mkString (" "), extraJars).runPartest
3637
}
3738
}
3839

3940
// console runner has a suite runner which creates a test runner for each test
4041
class DPConsoleRunner(args: String, extraJars: List[String]) extends ConsoleRunner(args) {
42+
println("ConsoleRunner options: " + args)
43+
4144
override val suiteRunner = new DPSuiteRunner (
4245
testSourcePath = optSourcePath getOrElse DPConfig.testRoot,
4346
fileManager = new DottyFileManager(extraJars),

0 commit comments

Comments
 (0)