summaryrefslogtreecommitdiff
path: root/src/partest
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-11-13 01:56:10 +0000
committerPaul Phillips <paulp@improving.org>2011-11-13 01:56:10 +0000
commitb6a300f3ac965285583ed39348ad43abb6df019e (patch)
tree9e919340b1ab94d9b849ca1d49b7437924404bf1 /src/partest
parentea5aac152dab47e7e4aa37224a0b8a609b6d9a0c (diff)
downloadscala-b6a300f3ac965285583ed39348ad43abb6df019e.tar.gz
scala-b6a300f3ac965285583ed39348ad43abb6df019e.tar.bz2
scala-b6a300f3ac965285583ed39348ad43abb6df019e.zip
Working on the runners.
Removed assumption that bash is in /bin. Removed --posix option to bash. Modernized shell constructs: $() instead of ``, [[ ]] instead of [ ]. Added -debug option for all runners which will show you the exact java command line being run before running it. Added -usebootcp to complement -nobootcp, and made regular classpath the default on cygwin. Quoted more things to give us a fighting chance against spaces and parens in paths. I took the waste-half-a-day step of installing vmware fusion so I could install windows so I could install cygwin so I could install scala under cygwin so I could see if it still worked. Seems to. We still desperately need some way of testing not only everything I'm attempting to address in this pile of patches but everything which is most likely now regressing. :javap now sort of works on windows (not for repl-defined classes as yet) if JAVA_HOME is set such that I can find tools.jar. Closes SI-4959. (Risks breaking and) references SI-2092. References SI-622 since that shouldn't be hard to get working.
Diffstat (limited to 'src/partest')
-rw-r--r--src/partest/scala/tools/partest/nest/Worker.scala40
1 files changed, 23 insertions, 17 deletions
diff --git a/src/partest/scala/tools/partest/nest/Worker.scala b/src/partest/scala/tools/partest/nest/Worker.scala
index 711e3f0935..5403e1954f 100644
--- a/src/partest/scala/tools/partest/nest/Worker.scala
+++ b/src/partest/scala/tools/partest/nest/Worker.scala
@@ -12,6 +12,7 @@ import java.io._
import java.net.URL
import java.util.{ Timer, TimerTask }
+import scala.tools.nsc.Properties.{ jdkHome, javaHome, propOrElse }
import scala.util.Properties.{ isWin }
import scala.tools.nsc.{ Settings, CompilerCommand, Global }
import scala.tools.nsc.io.{ AbstractFile, PlainFile, Path, Directory, File => SFile }
@@ -105,14 +106,9 @@ class Worker(val fileManager: FileManager, params: TestRunParams) extends Actor
val scalaCheckFileManager = new ScalaCheckFileManager(fileManager)
var reporter: ConsoleReporter = _
- val timer = new Timer
-
- val javacCmd = if ((fileManager.JAVAC_CMD.indexOf("${env.JAVA_HOME}") != -1) ||
- fileManager.JAVAC_CMD.equals("/bin/javac") ||
- fileManager.JAVAC_CMD.equals("\\bin\\javac")) "javac"
- else
- fileManager.JAVAC_CMD
-
+ val timer = new Timer
+ val javaCmd = propOrElse("partest.javacmd", Path(javaHome) / "bin" / "java" path)
+ val javacCmd = propOrElse("partest.javac_cmd", Path(jdkHome) / "bin" / "javac" path)
def cancelTimerTask() = if (currentTimerTask != null) currentTimerTask.cancel()
def updateTimerTask(body: => Unit) = {
@@ -272,15 +268,16 @@ class Worker(val fileManager: FileManager, params: TestRunParams) extends Actor
def javac(outDir: File, files: List[File], output: File): Boolean = {
// compile using command-line javac compiler
- val cmd = "%s -d %s -classpath %s %s".format(
+ val args = Seq(
javacCmd,
+ "-d",
outDir.getAbsolutePath,
- join(outDir.toString, CLASSPATH),
- files mkString " "
- )
+ "-classpath",
+ join(outDir.toString, CLASSPATH)
+ ) ++ files.map("" + _)
- try runCommand(cmd, output)
- catch exHandler(output, "javac command '" + cmd + "' failed:\n")
+ try runCommand(args, output)
+ catch exHandler(output, "javac command failed:\n" + args.map(" " + _ + "\n").mkString + "\n")
}
/** Runs command redirecting standard out and
@@ -290,7 +287,15 @@ class Worker(val fileManager: FileManager, params: TestRunParams) extends Actor
NestUI.verbose("running command:\n"+command)
(command #> outFile !) == 0
}
+ def runCommand(args: Seq[String], outFile: File): Boolean = {
+ NestUI.verbose("running command:\n"+args.map(" " + _ + "\n").mkString)
+ (Process(args) #> outFile !) == 0
+ }
+ private def q(s: String) = {
+ val quot = "\""
+ if ((s == "") || (s.head == '"')) s else quot + s + quot
+ }
def execTest(outDir: File, logFile: File, classpathPrefix: String = ""): Boolean = {
// check whether there is a ".javaopts" file
val argsFile = new File(logFile.getParentFile, fileBase + ".javaopts")
@@ -325,7 +330,7 @@ class Worker(val fileManager: FileManager, params: TestRunParams) extends Actor
"-Dpartest.cwd="+outDir.getParent,
"-Dpartest.test-path="+testFullPath,
"-Dpartest.testname="+fileBase,
- "-Djavacmd="+JAVACMD,
+ "-Djavacmd="+javaCmd,
"-Djavaccmd="+javacCmd,
"-Duser.language=en -Duser.country=US"
) ++ extras
@@ -333,10 +338,11 @@ class Worker(val fileManager: FileManager, params: TestRunParams) extends Actor
val classpath = if (classpathPrefix != "") join(classpathPrefix, CLASSPATH) else CLASSPATH
val cmd = (
List(
- JAVACMD,
+ javaCmd,
JAVA_OPTS,
argString,
- "-classpath " + join(outDir.toString, classpath)
+ "-classpath",
+ join(outDir.toString, classpath)
) ++ propertyOptions ++ List(
"scala.tools.nsc.MainGenericRunner",
"-usejavacp",