summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreePrinters.scala6
-rw-r--r--src/compiler/scala/tools/nsc/util/Position.scala2
-rw-r--r--src/library/scala/runtime/RichString.scala33
-rw-r--r--src/partest/scala/tools/partest/MasterActor.scala2
-rw-r--r--src/partest/scala/tools/partest/TestRunner.scala17
-rw-r--r--src/partest/scala/tools/partest/WorkerActor.scala30
-rw-r--r--src/partest/scala/tools/partest/utils/PrintMgr.scala2
-rw-r--r--src/partest/scala/tools/partest/utils/Properties.scala57
8 files changed, 109 insertions, 40 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala
index 2fa44c2dc8..7f1816c7a2 100644
--- a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala
@@ -229,7 +229,7 @@ abstract class TreePrinters {
selectorType = selectorType1
case CaseDef(pat, guard, body) =>
- print("case ");
+ print("case ")
def patConstr(pat: Tree): Tree = pat match {
case Apply(fn, args) => patConstr(fn)
case _ => pat
@@ -362,7 +362,9 @@ abstract class TreePrinters {
print(tpt);
printColumn(whereClauses, " forSome { ", ";", "}")
- case tree : StubTree => print(tree.toString)
+ case tree: StubTree =>
+ print(tree.toString)
+
case tree =>
print("<unknown tree of class "+tree.getClass+">")
}
diff --git a/src/compiler/scala/tools/nsc/util/Position.scala b/src/compiler/scala/tools/nsc/util/Position.scala
index a895780d1c..91c437ee8a 100644
--- a/src/compiler/scala/tools/nsc/util/Position.scala
+++ b/src/compiler/scala/tools/nsc/util/Position.scala
@@ -68,7 +68,7 @@ trait Position {
}
-object NoPosition extends Position
+case object NoPosition extends Position
case class FakePos(msg: String) extends Position
case class LinePosition(source0: SourceFile, line0: Int) extends Position {
diff --git a/src/library/scala/runtime/RichString.scala b/src/library/scala/runtime/RichString.scala
index 187f77e5d3..40fccab5ba 100644
--- a/src/library/scala/runtime/RichString.scala
+++ b/src/library/scala/runtime/RichString.scala
@@ -22,10 +22,16 @@ final class RichString(val self: String) extends Proxy with RandomAccessSeq[Char
override def mkString = self
override def slice(from: Int, until: Int): RichString = {
- val from0 = if (from < 0) 0 else from
- val until0 = if (from >= until || from >= self.length) return new RichString("")
- else if (until > self.length) self.length else until
- new RichString(self.substring(from0, until0))
+ val len = self.length
+ new RichString(
+ if (from >= until || from >= len)
+ ""
+ else {
+ val from0 = if (from < 0) 0 else from
+ val until0 = if (until > len) len else until
+ self.substring(from0, until0)
+ }
+ )
}
//override def ++ [B >: A](that: Iterable[B]): Seq[B] = {
@@ -159,25 +165,6 @@ final class RichString(val self: String) extends Proxy with RandomAccessSeq[Char
*/
def stripMargin: String = stripMargin('|')
- /** <p>
- * Remove white space from both ends of each line and add
- * a blank (" ") between lines before merging them.
- * </p>
- * <p>
- * Equivalent to: <code>mergeLines(_.trim, " ")</code>.
- * </p>
- */
- def mergeLines: String = mergeLines(_.trim, " ")
-
- /** <p>
- * Apply function <code>f</code> to each line and add
- * the string <code>eol</code> between lines before
- * merging them.
- * </p>
- */
- def mergeLines(f: String => String, eol: String): String =
- lines map f mkString eol
-
private def escape(ch: Char): String = ch match {
case '.' | '$' | '^' | '\\' => "\\" + ch
case _ => "" + ch
diff --git a/src/partest/scala/tools/partest/MasterActor.scala b/src/partest/scala/tools/partest/MasterActor.scala
index 90c081418f..8ead5e5ea8 100644
--- a/src/partest/scala/tools/partest/MasterActor.scala
+++ b/src/partest/scala/tools/partest/MasterActor.scala
@@ -6,7 +6,7 @@
** |/ **
\* */
-// $Id: $
+// $Id$
package scala.tools.partest
diff --git a/src/partest/scala/tools/partest/TestRunner.scala b/src/partest/scala/tools/partest/TestRunner.scala
index 623b0ae28a..36c1d13722 100644
--- a/src/partest/scala/tools/partest/TestRunner.scala
+++ b/src/partest/scala/tools/partest/TestRunner.scala
@@ -6,7 +6,7 @@
** |/ **
\* */
-// $Id: $
+// $Id$
package scala.tools.partest
@@ -134,18 +134,24 @@ object TestRunner {
private def printUsage {
println("Usage: TestRunner [<options>] <testdir> [<resfile>]")
- println(" --pos ...")
- println(" --neg ...")
- println(" --jvm ...")
- println(" --run ...")
+ println(" --pos next files test a compilation success")
+ println(" --neg next files test a compilation failure")
+ println(" --jvm next files test the JVM backend")
+ println(" --run next files test the interpreter and all backends")
println(" --shootout ...")
println(" --conservative ...")
println(" --verbose display progress information")
+ println(" --version output version information and exit")
println
println("Send bugs to <scala@listes.epfl.ch>")
exit(1)
}
+ private def printVersion {
+ println(util.Properties.versionMsg)
+ exit(0)
+ }
+
final def printVerbose(msg: String) {
if (verbose) {
printOutline("debug : ")
@@ -166,6 +172,7 @@ object TestRunner {
case "--shootout" => shootoutCheck = true
case "--conservative" => conservative = true
case "--verbose" => verbose = true
+ case "--version" => printVersion
case _ =>
if (testDir eq null) {
val dir = new File(arg)
diff --git a/src/partest/scala/tools/partest/WorkerActor.scala b/src/partest/scala/tools/partest/WorkerActor.scala
index d0cf133c82..a76a728f56 100644
--- a/src/partest/scala/tools/partest/WorkerActor.scala
+++ b/src/partest/scala/tools/partest/WorkerActor.scala
@@ -6,7 +6,7 @@
** |/ **
\* */
-// $Id: $
+// $Id$
package scala.tools.partest
@@ -53,6 +53,10 @@ class WorkerActor(val master: MasterActor, val settings: Settings, var reporter:
dir.delete
}
+ private val PATH_SEP = java.io.File.pathSeparatorChar
+ private val CLASSPATH = System.getProperty("CLASSPATH", "")
+ private val EXT_CLASSPATH = System.getProperty("JVMEXTCP", "")
+
def act() {
var compiler = newGlobal
val bufferSize = 1024
@@ -175,7 +179,11 @@ class WorkerActor(val master: MasterActor, val settings: Settings, var reporter:
case _ => {}
}
- var classpath: List[URL] = outDir.toURL :: List((new File(test.dir)).toURL) ::: List.fromString(System.getProperty("CLASSPATH"), ':').map(x => (new File(x)).toURL) ::: List.fromString(System.getProperty("JVMEXTCP"), ':').map(x => (new File(x)).toURL)
+ var classpath: List[URL] =
+ outDir.toURL ::
+ List((new File(test.dir)).toURL) :::
+ (List.fromString(CLASSPATH, PATH_SEP) map { x => (new File(x)).toURL }) :::
+ (List.fromString(EXT_CLASSPATH, PATH_SEP) map { x => (new File(x)).toURL })
try {
//println(this.toString + " " + "Launching test " + test.fileBase)
@@ -230,13 +238,21 @@ class WorkerActor(val master: MasterActor, val settings: Settings, var reporter:
case (_, NegTest(_)) =>
case (true, _) =>
result = true
- var javaoptsFile = new File(test.dir, test.fileBase + ".javaopts")
+ //var javaoptsFile = new File(test.dir, test.fileBase + ".javaopts")
//var javaNewOpts = (new BufferedFileReader(javaoptsFile)).readLine
//if (javaoptsFile.exists && javaNewOpts != null) {}
- //Use Runtime.exec to execute the compiled file and pipe the standard system out and the console out to the logfile
- var cmd = "env JAVACMD=java JAVA_OPTS=-Djava.library.path="+test.dir+" "+System.getProperty("SCALA")+" -Dscalatest.lib="+System.getProperty("scalatest.lib")+" -Dscalatest.cwd="+test.dir+" -Dscalatest.output="+outDir+" -classpath "+outDir+":"+System.getProperty("CLASSPATH")+":"+System.getProperty("JVMEXTCP")+" Test jvm"
-
- //println(cmd)
+ //Use Runtime.exec to execute the compiled file and pipe the standard system
+ //out and the console out to the logfile
+ var cmd =
+ "env JAVACMD=java JAVA_OPTS=-Djava.library.path=\"" + test.dir + "\" " +
+ System.getProperty("SCALA")+
+ " -Dscalatest.lib=\"" + System.getProperty("scalatest.lib") + "\" " +
+ "-Dscalatest.cwd=\"" + test.dir + "\" " +
+ "-Dscalatest.output=" + outDir +
+ " -classpath " + outDir + PATH_SEP + CLASSPATH + PATH_SEP + EXT_CLASSPATH +
+ " Test jvm"
+
+ TestRunner.printVerbose("Worker command: " + cmd)
var execution = Runtime.getRuntime.exec(cmd)
diff --git a/src/partest/scala/tools/partest/utils/PrintMgr.scala b/src/partest/scala/tools/partest/utils/PrintMgr.scala
index a47657d611..96ab7823ae 100644
--- a/src/partest/scala/tools/partest/utils/PrintMgr.scala
+++ b/src/partest/scala/tools/partest/utils/PrintMgr.scala
@@ -6,7 +6,7 @@
** |/ **
\* */
-// $Id: $
+// $Id$
package scala.tools.partest.utils
diff --git a/src/partest/scala/tools/partest/utils/Properties.scala b/src/partest/scala/tools/partest/utils/Properties.scala
new file mode 100644
index 0000000000..3fd2a29575
--- /dev/null
+++ b/src/partest/scala/tools/partest/utils/Properties.scala
@@ -0,0 +1,57 @@
+/* __ *\
+** ________ ___ / / ___ Scala Parallel Testing **
+** / __/ __// _ | / / / _ | (c) 2007-2008, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id$
+
+package scala.tools.partest.util
+
+/** A utility to load the library properties from a Java properties file
+ * included in the jar.
+ *
+ * @author Stephane Micheloud
+ */
+object Properties {
+
+ /** The name of the properties file */
+ private val propFilename = "/partest.properties"
+
+ /** The loaded properties */
+ private val props = {
+ val props = new java.util.Properties
+ val stream = classOf[Application].getResourceAsStream(propFilename)
+ if (stream != null)
+ props.load(stream)
+ props
+ }
+
+ /** The version number of the jar this was loaded from, or
+ * "(unknown)" if it cannot be determined.
+ */
+ val versionString: String = {
+ val defaultString = "(unknown)"
+ "version " + props.getProperty("version.number")
+ }
+
+ val copyrightString: String = {
+ val defaultString = "(c) 2002-2007 LAMP/EPFL"
+ props.getProperty("copyright.string", defaultString)
+ }
+
+ val encodingString: String = {
+ val defaultString = "ISO-8859-1"
+ props.getProperty("file.encoding", defaultString)
+ }
+
+ private val writer = new java.io.PrintWriter(Console.err, true)
+
+ val versionMsg = "Scala partest " + versionString + " -- " + copyrightString
+
+ def main(args: Array[String]) {
+ writer.println(versionMsg)
+ }
+}