summaryrefslogtreecommitdiff
path: root/src/partest
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-02-18 18:49:21 +0000
committerPaul Phillips <paulp@improving.org>2010-02-18 18:49:21 +0000
commit388a0c0d1db3e41e3acbebd6e1e4c79f7d176ca3 (patch)
treef1f5df26496c614446cea6b970f48c6659ad803d /src/partest
parent23e5428008fc88377e59a1a5c20d5476c586d62e (diff)
downloadscala-388a0c0d1db3e41e3acbebd6e1e4c79f7d176ca3.tar.gz
scala-388a0c0d1db3e41e3acbebd6e1e4c79f7d176ca3.tar.bz2
scala-388a0c0d1db3e41e3acbebd6e1e4c79f7d176ca3.zip
The first reasonably satisfying classpath commit.
there with this one. Documentation to come. Review by community.
Diffstat (limited to 'src/partest')
-rw-r--r--src/partest/scala/tools/partest/nest/CompileManager.scala4
-rw-r--r--src/partest/scala/tools/partest/nest/ConsoleFileManager.scala62
-rw-r--r--src/partest/scala/tools/partest/nest/ConsoleRunner.scala4
-rw-r--r--src/partest/scala/tools/partest/nest/TestFile.scala6
-rw-r--r--src/partest/scala/tools/partest/package.scala14
5 files changed, 36 insertions, 54 deletions
diff --git a/src/partest/scala/tools/partest/nest/CompileManager.scala b/src/partest/scala/tools/partest/nest/CompileManager.scala
index 3ef5a0f723..63acf654e2 100644
--- a/src/partest/scala/tools/partest/nest/CompileManager.scala
+++ b/src/partest/scala/tools/partest/nest/CompileManager.scala
@@ -45,7 +45,7 @@ class DirectCompiler(val fileManager: FileManager) extends SimpleCompiler {
settings.deprecation.value = true
settings.nowarnings.value = false
settings.encoding.value = "iso-8859-1"
- settings.classpath.value += fileManager.LATEST_LIB
+ settings.classpath.value += (pathSeparator + fileManager.LATEST_LIB)
// XXX
// settings.javabootAppend.value = fileManager.LATEST_LIB
@@ -113,7 +113,7 @@ class DirectCompiler(val fileManager: FileManager) extends SimpleCompiler {
out map { outDir =>
command.settings.outdir.value = outDir.getAbsolutePath
- command.settings appendToClasspath outDir.getAbsolutePath
+ command.settings.classpath.value += (pathSeparator + outDir.getAbsolutePath)
}
val toCompile = files map (_.getPath)
diff --git a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
index cd5023573b..258651e0ce 100644
--- a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
+++ b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala
@@ -14,6 +14,7 @@ import scala.tools.util.PathResolver
import scala.tools.nsc.io
import io.{ Path, Directory }
import File.pathSeparator
+import PathResolver.{ propOrElse }
class ConsoleFileManager extends FileManager {
implicit private def tempPathConversion(x: Path): File = x.jfile
@@ -47,17 +48,11 @@ class ConsoleFileManager extends FileManager {
NestUI.verbose("CLASSPATH: "+CLASSPATH)
- var JAVACMD = System.getProperty("scalatest.javacmd", "java")
- var JAVAC_CMD = System.getProperty("scalatest.javac_cmd", "javac")
+ var JAVACMD = propOrElse("scalatest.javacmd", "java")
+ var JAVAC_CMD = propOrElse("scalatest.javac_cmd", "javac")
- val prefixFile = {
- val cwd = System.getProperty("user.dir")
- if (cwd != null)
- (new File(cwd)).getCanonicalFile
- else
- error("user.dir property not set")
- }
- val PREFIX = prefixFile.getAbsolutePath
+ val prefixDir = Directory.Current map (_.normalize.toDirectory) getOrElse error("user.dir property not set")
+ val PREFIX = prefixDir.toAbsolute.path
/*
if [ -d "$PREFIX/test" ]; then
@@ -68,38 +63,31 @@ else
abort "Test directory not found";
*/
- val testRootFile = {
- val testRootProp = System.getProperty("scalatest.root")
- val testroot =
- if (testRootProp != null)
- new File(testRootProp)
- else {
- // case 1: cwd is `test`
- if (prefixFile.getName == "test" && (new File(prefixFile, "files")).exists)
- prefixFile
- else {
- // case 2: cwd is `test/..`
- val test = new File(prefixFile, "test")
- val scalaTest = new File(new File(prefixFile, "misc"), "scala-test")
- if (test.isDirectory)
- test
- else if (scalaTest.isDirectory)
- scalaTest
- else
- error("Test directory not found")
- }
- }
- testroot.getCanonicalFile
+ val testRootDir = {
+ val testRootProp = Option(propOrElse("scalatest.root", null)) map (x => Directory(x))
+ def isTestDir(d: Directory) = d.name == "test" && (d / "files" isDirectory)
+
+ (
+ testRootProp orElse (
+ if (isTestDir(prefixDir)) Some(prefixDir) else None // cwd is `test`
+ ) orElse (
+ (prefixDir / "test") ifDirectory (x => x) // cwd is `test/..`
+ ) orElse (
+ (prefixDir / "misc" / "scala-test") ifDirectory (x => x)
+ ) getOrElse (
+ error("Test directory not found")
+ )
+ ).normalize
}
- val TESTROOT = testRootFile.getAbsolutePath
+ val TESTROOT = testRootDir.toAbsolute.path
- def testParent = Path(testRootFile).parent
+ def testParent = testRootDir.parent
var srcDirName: String = ""
val srcDir: io.Directory = {
srcDirName = Option(System.getProperty("partest.srcdir")) getOrElse "files"
- val src = Path(testRootFile) / srcDirName
+ val src = testRootDir / srcDirName
if (src.isDirectory) src.toDirectory
else {
@@ -108,7 +96,7 @@ else
}
}
- LIB_DIR = (Path(testRootFile.getParentFile) / "lib").normalize.toAbsolute.path
+ LIB_DIR = (testParent / "lib").normalize.toAbsolute.path
CLASSPATH = {
val libs = (srcDir / Directory("lib")).files filter (_ hasExtension "jar") map (_.normalize.toAbsolute.path)
@@ -177,7 +165,7 @@ else
val dists = testParent / "dists"
val build = testParent / "build"
- // in case of an installed dist, testRootFile is one level deeper
+ // in case of an installed dist, testRootDir is one level deeper
val bin = testParent.parent / "bin"
def mostRecentOf(base: String, names: String*) =
diff --git a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala
index 373da5e3db..1ba2ce61a4 100644
--- a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala
+++ b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala
@@ -128,8 +128,8 @@ class ConsoleRunner extends DirectRunner with RunnerUtils {
val dir =
if (!fileManager.testClasses.isEmpty)
fileManager.testClassesDir
- else if (fileManager.testBuild != null)
- fileManager.testBuildFile
+ else if (fileManager.testBuildFile.isDefined)
+ fileManager.testBuildFile.get
else
fileManager.latestCompFile.getParentFile.getParentFile.getCanonicalFile
NestUI.outline("Scala compiler classes in: "+dir+"\n")
diff --git a/src/partest/scala/tools/partest/nest/TestFile.scala b/src/partest/scala/tools/partest/nest/TestFile.scala
index 90d8db936f..e4f1d98c06 100644
--- a/src/partest/scala/tools/partest/nest/TestFile.scala
+++ b/src/partest/scala/tools/partest/nest/TestFile.scala
@@ -22,8 +22,7 @@ abstract class TestFile(kind: String) {
val fileBase: String = basename(file.getName)
def objDir = fileBase + "-" + kind + ".obj"
- // @mutates settings
- protected def baseSettings(settings: Settings) {
+ def defineSettings(settings: Settings) {
settings appendToClasspath dirpath
if (createOutDir) {
@@ -34,10 +33,7 @@ abstract class TestFile(kind: String) {
// add additional flags found in 'testname.flags'
def flagsPath = Path(dir) / (fileBase + ".flags")
flagsPath ifFile { _.slurp().trim } foreach (settings processArgumentString _)
- }
- def defineSettings(settings: Settings) {
- baseSettings(settings)
settings appendToClasspath fileManager.CLASSPATH
}
diff --git a/src/partest/scala/tools/partest/package.scala b/src/partest/scala/tools/partest/package.scala
index 017974c232..d814fc4fc7 100644
--- a/src/partest/scala/tools/partest/package.scala
+++ b/src/partest/scala/tools/partest/package.scala
@@ -7,23 +7,21 @@ package scala.tools
package object partest {
import nest.NestUI
- def showVMArgs {
+ def vmArgString = {
import scala.tools.nsc.io.Process
val str = Process.javaVmArguments mkString " "
- NestUI.verbose("Java VM started with arguments: '%s'" format str)
+ "Java VM started with arguments: '%s'" format str
}
- def showAllProperties {
+ def allPropertiesString = {
import collection.JavaConversions._
- for ((k, v) <- System.getProperties.toList.sorted) {
- NestUI.verbose("%s -> %s".format(k, v))
- }
+ System.getProperties.toList.sorted map { case (k, v) => "%s -> %s\n".format(k, v) } mkString
}
def showAllJVMInfo {
- showVMArgs
- showAllProperties
+ NestUI.verbose(vmArgString)
+ NestUI.verbose(allPropertiesString)
}
def isPartestDebug = {