summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-04-06 23:57:11 +0000
committerPaul Phillips <paulp@improving.org>2010-04-06 23:57:11 +0000
commit9a8ba0c87747c50994c4465c04d6f65f23c77752 (patch)
treedd3869923b973aba457b49dcc69200399a7a1ae0
parentd5b8082ce9269f6657d6d3b5467f57fa746f7e76 (diff)
downloadscala-9a8ba0c87747c50994c4465c04d6f65f23c77752.tar.gz
scala-9a8ba0c87747c50994c4465c04d6f65f23c77752.tar.bz2
scala-9a8ba0c87747c50994c4465c04d6f65f23c77752.zip
And another partest gap is filled.
partest it really will use quick as the build dir. No review.
-rw-r--r--src/compiler/scala/tools/nsc/util/CommandLineSpec.scala29
-rw-r--r--src/partest/scala/tools/partest/BuildContributors.scala2
-rw-r--r--src/partest/scala/tools/partest/Config.scala14
-rw-r--r--src/partest/scala/tools/partest/Entities.scala2
-rw-r--r--src/partest/scala/tools/partest/Partest.scala5
-rw-r--r--src/partest/scala/tools/partest/PartestSpec.scala21
-rw-r--r--src/partest/scala/tools/partest/io/Logging.scala4
7 files changed, 54 insertions, 23 deletions
diff --git a/src/compiler/scala/tools/nsc/util/CommandLineSpec.scala b/src/compiler/scala/tools/nsc/util/CommandLineSpec.scala
index 4835506a47..826255e86f 100644
--- a/src/compiler/scala/tools/nsc/util/CommandLineSpec.scala
+++ b/src/compiler/scala/tools/nsc/util/CommandLineSpec.scala
@@ -22,6 +22,8 @@ trait CommandLineSpec {
def isPassthroughProperty(name: String): Boolean = false
def isSysPropOption(key: String): Option[String] = None
+ protected var _expandingOptions: Map[String, List[String]] = Map()
+
private var _helpMessage: String = ""
private var _unaryOptions: List[String] = Nil
private var _binaryOptions: List[String] = Nil
@@ -40,11 +42,14 @@ trait CommandLineSpec {
/** The various operators:
* val isCond1 = "cond1" ? // --cond1 is unary, cond1 is boolean
* "cond2" ?> body // --cond2 is unary, body is executed if it is given
+ * "cond3" ?+> List(x1, x2...) // --cond3 is unary, arguments on rhs will be substituted in as if given
* val val1 = "val1" |> "alt" // --val1 is binary, val1 is String, alt used if none given
* val val2 = "val2" >> // --val2 is binary, val2 is Option[String], None if none given
*/
protected class OptionStringAdditions(name: String) {
val s = toOpt(name)
+ def ?+>(args: List[String]): Unit = { _unaryOptions +:= s ; if (isReferenceSpec) _expandingOptions += (name -> args) }
+
def ? : Boolean = { _unaryOptions +:= s ; if (isReferenceSpec) false else parsed isSet s }
def ?>(body: => Unit): Unit = { _unaryOptions +:= s ; if (isReferenceSpec) () else if (parsed isSet s) body }
def |>(alt: String): String = { _binaryOptions +:= s ; if (isReferenceSpec) "" else parsed.getOrElse(s, alt) }
@@ -59,12 +64,14 @@ trait CommandLineSpec {
}
protected implicit def stringAdditions(s: String) = new OptionStringAdditions(s)
- lazy val unaryOptions = _unaryOptions.distinct
- lazy val binaryOptions = _binaryOptions.distinct
- lazy val helpMsg = _helpMessage
+ lazy val unaryOptions = _unaryOptions.distinct
+ lazy val binaryOptions = _binaryOptions.distinct
+ lazy val expandingOptions = _expandingOptions.keys.toList
+ lazy val helpMsg = _helpMessage
- def isUnaryOption(s: String) = unaryOptions contains toOpt(s)
- def isBinaryOption(s: String) = binaryOptions contains toOpt(s)
+ def isUnaryOption(s: String) = unaryOptions contains toOpt(s)
+ def isBinaryOption(s: String) = binaryOptions contains toOpt(s)
+ def isExpandingOption(s: String) = expandingOptions contains toOpt(s)
private def sysPropToOptions(k: String, v: String): List[String] = {
if (isPassthroughProperty(k)) toArgs(v)
@@ -100,6 +107,18 @@ trait CommandLineSpec {
}
}
+trait CommandLineReferenceSpec extends CommandLineSpec {
+ final override def isReferenceSpec: Boolean = true
+ final def apply(args: String*) = creator(args.toList flatMap expandArg)
+
+ protected lazy val expansionMap = _expandingOptions
+ protected def creator(args: List[String]) = new ThisCommandLine(args)
+ protected def expandArg(arg: String) = expansionMap.getOrElse(fromOpt(arg), List(arg))
+
+ class ThisCommandLine(args: List[String]) extends CommandLine(args, unaryOptions, binaryOptions) {
+ }
+}
+
object CommandLineSpec {
def toOpt(s: String) = if (s startsWith "--") s else "--" + s
def fromOpt(s: String) = s stripPrefix "--"
diff --git a/src/partest/scala/tools/partest/BuildContributors.scala b/src/partest/scala/tools/partest/BuildContributors.scala
index abd3bb318b..64c7e07bc3 100644
--- a/src/partest/scala/tools/partest/BuildContributors.scala
+++ b/src/partest/scala/tools/partest/BuildContributors.scala
@@ -48,7 +48,7 @@ trait BuildContributors {
* !!! TODO - this should adjust itself depending on the build
* being tested, because pack and quick at least need different jars.
*/
- def classpathPaths = List[Path](library, compiler, partest, fjbg)
+ def classpathPaths = List[Path](library, compiler, partest, fjbg) ++ forkJoinPath
def buildProperties = List(
"scala.home" -> testBuildDir,
"partest.lib" -> library, // used in jvm/inner
diff --git a/src/partest/scala/tools/partest/Config.scala b/src/partest/scala/tools/partest/Config.scala
index 8023574ae4..7d8bb80835 100644
--- a/src/partest/scala/tools/partest/Config.scala
+++ b/src/partest/scala/tools/partest/Config.scala
@@ -57,6 +57,20 @@ trait Config {
*/
val scalaBin = testBuildDir / "bin"
+ /** A hack for now to get quick running.
+ */
+ def needsForkJoin = {
+ val loader = nsc.util.ScalaClassLoader.fromURLs(List(library.toURL))
+ val fjMarker = "scala.concurrent.forkjoin.ForkJoinTask"
+ val clazz = loader.tryToLoadClass(fjMarker)
+
+ if (clazz.isDefined) debug("Loaded ForkJoinTask OK, don't need jar.")
+ else debug("Could not load ForkJoinTask, putting jar on classpath.")
+
+ clazz.isEmpty
+ }
+ lazy val forkJoinPath: List[Path] = if (needsForkJoin) List(forkjoin) else Nil
+
/** Internal **/
private def repo = partestDir.parent.normalize
// XXX - is this needed? Where?
diff --git a/src/partest/scala/tools/partest/Entities.scala b/src/partest/scala/tools/partest/Entities.scala
index ceed145148..658cfdee12 100644
--- a/src/partest/scala/tools/partest/Entities.scala
+++ b/src/partest/scala/tools/partest/Entities.scala
@@ -23,7 +23,7 @@ trait Entities {
def category: TestCategory
lazy val label = location.stripExtension
- lazy val testClasspath = createClasspathString()
+ lazy val testClasspath = returning(createClasspathString())(vtrace)
/** Was this test successful? Calling this for the first time forces
* lazy val "process" which actually runs the test.
diff --git a/src/partest/scala/tools/partest/Partest.scala b/src/partest/scala/tools/partest/Partest.scala
index b3580d0f1c..019ed270e5 100644
--- a/src/partest/scala/tools/partest/Partest.scala
+++ b/src/partest/scala/tools/partest/Partest.scala
@@ -15,10 +15,7 @@ import category.AllCategories
* for the complete list.
*/
class Partest(args: List[String]) extends {
- val parsed = new CommandLine(args, PartestSpecReference.unary, PartestSpecReference.binary) {
- override def onlyKnownOptions = true
- override def errorFn(msg: String) = printAndExit("Error: " + msg)
- }
+ val parsed = PartestSpecReference(args: _*)
} with Universe with PartestSpec with AllCategories {
debug("Partest object created with args: " + (args mkString " "))
diff --git a/src/partest/scala/tools/partest/PartestSpec.scala b/src/partest/scala/tools/partest/PartestSpec.scala
index a1f7d4ef28..a8a1d9b0cb 100644
--- a/src/partest/scala/tools/partest/PartestSpec.scala
+++ b/src/partest/scala/tools/partest/PartestSpec.scala
@@ -8,7 +8,7 @@ package partest
import Properties._
import nsc.io._
-import nsc.util.{ CommandLine, CommandLineSpec }
+import nsc.util.{ CommandLine, CommandLineSpec, CommandLineReferenceSpec }
/** This takes advantage of bits of scala goodness to fully define a command
* line program with a minimum of duplicated code. When the specification object
@@ -59,8 +59,8 @@ trait PartestSpec extends CommandLineSpec {
val javaOpts = "javaopts" / "flags to java on all runs (overrides JAVA_OPTS)" |> envOrElse("JAVA_OPTS", "")
val scalacOpts = "scalacopts" / "flags to scalac on all tests (overrides SCALAC_OPTS)" |> envOrElse("SCALAC_OPTS", "")
- ("pack" / "alias for --builddir build/pack") ?> setProp("partest.build", "build/pack")
- ("quick" / "alias for --builddir build/quick") ?> setProp("partest.build", "build/quick")
+ ("pack" / "alias for --builddir build/pack") ?+> List("--builddir", "build/pack")
+ ("quick" / "alias for --builddir build/quick") ?+> List("--builddir", "build/quick")
heading ("Options influencing output:")
val isTrace = "trace" / "show the individual steps taken by each test" ?
@@ -89,18 +89,15 @@ trait PartestSpec extends CommandLineSpec {
val isInsideAnt = ("is-in-ant" ?)
}
-object PartestSpecReference extends PartestSpec {
+object PartestSpecReference extends PartestSpec with CommandLineReferenceSpec {
import CommandLineSpec._
def parsed: CommandLine = null
- override def isReferenceSpec = true
-
- def unary = unaryOptions
- def binary = binaryOptions
- def allArgs = unary ++ binary
-
- def isunaryOption(s: String) = unary contains toOpt(s)
- def isbinaryOption(s: String) = binary contains toOpt(s)
+ override def creator(args: List[String]) =
+ new ThisCommandLine(args) {
+ override def onlyKnownOptions = true
+ override def errorFn(msg: String) = printAndExit("Error: " + msg)
+ }
def main(args: Array[String]): Unit = println(bashCompletion("partest"))
diff --git a/src/partest/scala/tools/partest/io/Logging.scala b/src/partest/scala/tools/partest/io/Logging.scala
index 2d67ac5ae4..3d1b0fa0b4 100644
--- a/src/partest/scala/tools/partest/io/Logging.scala
+++ b/src/partest/scala/tools/partest/io/Logging.scala
@@ -65,6 +65,10 @@ trait Logging {
def trace(msg: String) = if (isTrace || isDryRun) System.err.println(">> [%s] %s".format(label, msg))
def tracePath(path: Path) = if (isVerbose) path.path else path.name
+ /** v == verbose.
+ */
+ def vtrace(msg: String) = if (isVerbose) trace(msg)
+
/** Run body, writes result to logFile. Any throwable is
* caught, stringified, and written to the log.
*/