Skip to content
This repository was archived by the owner on May 3, 2018. It is now read-only.

Commit d72eddc

Browse files
committed
Merge pull request #5 from gourlaysama/wip/runner-args
Pass down the TestFramework's arguments to SBTRunner
2 parents bfacd5d + 46cb937 commit d72eddc

File tree

1 file changed

+8
-31
lines changed

1 file changed

+8
-31
lines changed

src/main/scala/tools/partest/TestingInterface.scala

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,8 @@ class Framework extends sbt.testing.Framework {
2727
/** Represents one run of a suite of tests.
2828
*/
2929
case class Runner(args: Array[String], remoteArgs: Array[String], testClassLoader: ClassLoader) extends sbt.testing.Runner {
30-
/** Returns an array of tasks that when executed will run tests and suites determined by the
31-
* passed <code>TaskDef</code>s.
32-
*
33-
* <p>
34-
* Each returned task, when executed, will run tests and suites determined by the
35-
* test class name, fingerprints, "explicitly specified" field, and selectors of one of the passed <code>TaskDef</code>s.
36-
* </p>
37-
*
38-
* <p>
39-
* This <code>tasks</code> method may be called with <code>TaskDef</code>s containing the same value for <code>testClassName</code> but
40-
* different fingerprints. For example, if both a class and its companion object were test classes, the <code>tasks</code> method could be
41-
* passed an array containing <code>TaskDef</code>s with the same name but with a different value for <code>fingerprint.isModule</code>.
42-
* </p>
43-
*
44-
* <p>
45-
* A test framework may "reject" a requested task by returning no <code>Task</code> for that <code>TaskDef</code>.
46-
* </p>
47-
*
48-
* @param taskDefs the <code>TaskDef</code>s for requested tasks
49-
* @return an array of <code>Task</code>s
50-
* @throws IllegalStateException if invoked after <code>done</code> has been invoked.
51-
*/
52-
def tasks(taskDefs: Array[TaskDef]): Array[sbt.testing.Task] = taskDefs map (SbtPartestTask(_): sbt.testing.Task)
30+
31+
def tasks(taskDefs: Array[TaskDef]): Array[sbt.testing.Task] = taskDefs map (SbtPartestTask(_, args): sbt.testing.Task)
5332

5433
/** Indicates the client is done with this <code>Runner</code> instance.
5534
*
@@ -59,20 +38,18 @@ case class Runner(args: Array[String], remoteArgs: Array[String], testClassLoade
5938
}
6039

6140
/** Run partest in this VM. Assumes we're running in a forked VM!
62-
*
63-
* TODO: make configurable
6441
*/
65-
case class SbtPartestTask(taskDef: TaskDef) extends Task {
42+
case class SbtPartestTask(taskDef: TaskDef, args: Array[String]) extends Task {
6643
/** Executes this task, possibly returning to the client new tasks to execute. */
6744
def execute(eventHandler: EventHandler, loggers: Array[Logger]): Array[Task] = {
6845
val forkedCp = scala.util.Properties.javaClassPath
6946
val classLoader = new URLClassLoader(forkedCp.split(java.io.File.pathSeparator).map(new File(_).toURI.toURL))
70-
val runner = SBTRunner(Framework.fingerprint, eventHandler, loggers, "files", classLoader, null, null, Array.empty[String])
47+
val runner = SBTRunner(Framework.fingerprint, eventHandler, loggers, "files", classLoader, null, null, Array.empty[String], args)
7148

7249
if (Runtime.getRuntime().maxMemory() / (1024*1024) < 800)
7350
loggers foreach (_.warn(s"""Low heap size detected (~ ${Runtime.getRuntime().maxMemory() / (1024*1024)}M). Please add the following to your build.sbt: javaOptions in Test += "-Xmx1G""""))
7451

75-
try runner execute Array("scalacheck", "instrumented", "pos", "neg", "run", "jvm", "res", "scalap", "specialized", "presentation")
52+
try runner run
7653
catch {
7754
case ex: ClassNotFoundException =>
7855
loggers foreach { l => l.error("Please make sure partest is running in a forked VM by including the following line in build.sbt:\nfork in Test := true") }
@@ -82,13 +59,13 @@ case class SbtPartestTask(taskDef: TaskDef) extends Task {
8259
Array()
8360
}
8461

85-
type SBTRunner = { def execute(kinds: Array[String]): String }
62+
type SBTRunner = { def run(): Unit }
8663

8764
// use reflection to instantiate scala.tools.partest.nest.SBTRunner,
8865
// casting to the structural type SBTRunner above so that method calls on the result will be invoked reflectively as well
89-
private def SBTRunner(partestFingerprint: Fingerprint, eventHandler: EventHandler, loggers: Array[Logger], srcDir: String, testClassLoader: URLClassLoader, javaCmd: File, javacCmd: File, scalacArgs: Array[String]): SBTRunner = {
66+
private def SBTRunner(partestFingerprint: Fingerprint, eventHandler: EventHandler, loggers: Array[Logger], srcDir: String, testClassLoader: URLClassLoader, javaCmd: File, javacCmd: File, scalacArgs: Array[String], args: Array[String]): SBTRunner = {
9067
val runnerClass = Class.forName("scala.tools.partest.nest.SBTRunner")
91-
runnerClass.getConstructors()(0).newInstance(partestFingerprint, eventHandler, loggers, srcDir, testClassLoader, javaCmd, javacCmd, scalacArgs).asInstanceOf[SBTRunner]
68+
runnerClass.getConstructors()(0).newInstance(partestFingerprint, eventHandler, loggers, srcDir, testClassLoader, javaCmd, javacCmd, scalacArgs, args).asInstanceOf[SBTRunner]
9269
}
9370

9471
/** A possibly zero-length array of string tags associated with this task. */

0 commit comments

Comments
 (0)