From ae71711ffdda619e393bf9f7b9f6581bb81c1fd4 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 25 Feb 2010 19:50:28 +0000 Subject: More partest cleanups, and putting back a coupl... More partest cleanups, and putting back a couple lines in build.xml which were left a little too commented out. No review. --- build.xml | 4 ++-- src/compiler/scala/tools/nsc/io/Directory.scala | 1 + src/compiler/scala/tools/nsc/io/File.scala | 2 +- src/compiler/scala/tools/nsc/io/Path.scala | 2 +- .../tools/partest/nest/ConsoleFileManager.scala | 22 +++++++++++----------- .../scala/tools/partest/nest/ConsoleRunner.scala | 2 +- .../scala/tools/partest/nest/PathSettings.scala | 20 +++++++------------- src/partest/scala/tools/partest/package.scala | 6 ++++-- 8 files changed, 28 insertions(+), 31 deletions(-) diff --git a/build.xml b/build.xml index acdb4281d4..e706467a69 100644 --- a/build.xml +++ b/build.xml @@ -570,7 +570,7 @@ QUICK BUILD (QUICK) - + @@ -1013,7 +1013,7 @@ BOOTSTRAPPING BUILD (STRAP) - + diff --git a/src/compiler/scala/tools/nsc/io/Directory.scala b/src/compiler/scala/tools/nsc/io/Directory.scala index 709ffdc1e0..3268a0363f 100644 --- a/src/compiler/scala/tools/nsc/io/Directory.scala +++ b/src/compiler/scala/tools/nsc/io/Directory.scala @@ -42,6 +42,7 @@ class Directory(jfile: JFile) extends Path(jfile) override def toDirectory: Directory = this override def toFile: File = new File(jfile) override def isValid = jfile.isDirectory() || !jfile.exists() + override def normalize: Directory = super.normalize.toDirectory /** An iterator over the contents of this directory. */ diff --git a/src/compiler/scala/tools/nsc/io/File.scala b/src/compiler/scala/tools/nsc/io/File.scala index 4f27f4f8a5..d19b2cc269 100644 --- a/src/compiler/scala/tools/nsc/io/File.scala +++ b/src/compiler/scala/tools/nsc/io/File.scala @@ -55,7 +55,7 @@ with Streamable.Chars def withCodec(codec: Codec): File = new File(jfile)(codec) override def toDirectory: Directory = new Directory(jfile) override def toFile: File = this - + override def normalize: File = super.normalize.toFile override def isValid = jfile.isFile() || !jfile.exists() override def length = super[Path].length diff --git a/src/compiler/scala/tools/nsc/io/Path.scala b/src/compiler/scala/tools/nsc/io/Path.scala index 15550d2445..824e74efdc 100644 --- a/src/compiler/scala/tools/nsc/io/Path.scala +++ b/src/compiler/scala/tools/nsc/io/Path.scala @@ -140,7 +140,7 @@ class Path private[io] (val jfile: JFile) Directory(x) } } - def parents: List[Path] = { + def parents: List[Directory] = { val p = parent if (p isSame this) Nil else p :: p.parents } diff --git a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala index 9c395c3d05..617ef642de 100644 --- a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala +++ b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala @@ -51,28 +51,28 @@ class ConsoleFileManager extends FileManager { SCALAC_OPTS = SCALAC_OPTS+" "+moreOpts } - var CLASSPATH = PartestDefaults.classPath - var JAVACMD = PartestDefaults.javaCmd - var JAVAC_CMD = PartestDefaults.javacCmd - - NestUI.verbose("CLASSPATH: "+CLASSPATH) - - val prefixDir = PathSettings.prefixDir - val PREFIX = prefixDir.toAbsolute.path val testRootDir = PathSettings.testRoot + val srcDir = PathSettings.srcDir + + var CLASSPATH = PartestDefaults.classPath + var JAVACMD = PartestDefaults.javaCmd + var JAVAC_CMD = PartestDefaults.javacCmd val TESTROOT = testRootDir.toAbsolute.path + def testParent = testRootDir.parent - val srcDir = PathSettings.srcDir + + NestUI.verbose("CLASSPATH: "+CLASSPATH) + if (!srcDir.isDirectory) { NestUI.failure("Source directory \"" + srcDir.path + "\" not found") exit(1) } - LIB_DIR = (testParent / "lib").normalize.toAbsolute.path + LIB_DIR = (testParent / "lib").normalize.path CLASSPATH = { - val libs = (srcDir / Directory("lib")).files filter (_ hasExtension "jar") map (_.normalize.toAbsolute.path) + val libs = (srcDir / Directory("lib")).files filter (_ hasExtension "jar") map (_.normalize.path) // add all jars in libs (CLASSPATH :: libs.toList) mkString pathSeparator diff --git a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala index 0020581301..467aa7dc60 100644 --- a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala +++ b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala @@ -178,7 +178,7 @@ class ConsoleRunner extends DirectRunner { def runTestsFiles = if (!testFiles.isEmpty) { def kindOf(f: File) = { val srcDirSegments = PathSettings.srcDir.segments - val segments = Path(f).normalize.toAbsolute.segments + val segments = Path(f).normalize.segments lazy val kind = (segments drop srcDirSegments.size).head if ((segments startsWith srcDirSegments) && (testSetKinds contains kind)) kind diff --git a/src/partest/scala/tools/partest/nest/PathSettings.scala b/src/partest/scala/tools/partest/nest/PathSettings.scala index 17461b3d4d..e0099e71e1 100644 --- a/src/partest/scala/tools/partest/nest/PathSettings.scala +++ b/src/partest/scala/tools/partest/nest/PathSettings.scala @@ -13,24 +13,18 @@ import RunnerUtils._ import java.net.URLClassLoader object PathSettings { - private def isTestDirectory(d: Path) = - d.isDirectory && (d.name == "test") && (d / srcDirProperty isDirectory) + import PartestDefaults.{ testRootDir, srcDirName } - def testRootProperty = propOrNone("scalatest.root") map (x => Directory(x)) - def srcDirProperty = propOrElse("partest.srcdir", "files") + private def cwd = Directory.Current getOrElse error("user.dir property not set") + private def isPartestDir(d: Directory) = (d.name == "test") && (d / srcDirName isDirectory) - // XXX temp - def prefixDir = Directory.Current getOrElse error("user.dir property not set") + lazy val testRoot: Directory = testRootDir getOrElse { + val candidates: List[Directory] = (cwd :: cwd.parents) flatMap (d => List(d, Directory(d / "test"))) - lazy val testRoot: Directory = testRootProperty getOrElse { - // val cwd = Directory.Current getOrElse error("user.dir property not set") - val cwd = prefixDir - val candidates = (cwd :: cwd.parents) flatMap (d => List(d, d / "test")) - - candidates find isTestDirectory map (_.toDirectory) getOrElse error("Directory 'test' not found.") + candidates find isPartestDir getOrElse error("Directory 'test' not found.") } - lazy val srcDir = Directory((testRoot / srcDirProperty).normalize.toAbsolute) + lazy val srcDir = Directory(testRoot / srcDirName normalize) } class PathSettings() { diff --git a/src/partest/scala/tools/partest/package.scala b/src/partest/scala/tools/partest/package.scala index 8dcbe20ed7..68598f6594 100644 --- a/src/partest/scala/tools/partest/package.scala +++ b/src/partest/scala/tools/partest/package.scala @@ -22,8 +22,10 @@ package object partest { private def wrapAccessControl[T](body: => Option[T]): Option[T] = try body catch { case _: java.security.AccessControlException => None } - def prefixDir = Directory.Current map (_.normalize.toDirectory) - def srcDirName = propOrElse("partest.srcdir", "files") + def testRootName = propOrNone("scalatest.root") + def srcDirName = propOrElse("partest.srcdir", "files") + def testRootDir = testRootName map (x => Directory(x)) + def classPath = PathResolver.Environment.javaUserClassPath // XXX def javaCmd = propOrElse("scalatest.javacmd", "java") -- cgit v1.2.3