diff options
author | Paul Phillips <paulp@improving.org> | 2010-02-25 18:24:58 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-02-25 18:24:58 +0000 |
commit | 10d7b668b9e73c3390a172096197299f59cc8c86 (patch) | |
tree | cc656a50d1c556a310daa219b6635c3bda65bb7a /src | |
parent | 6ca74641f0b21ec3dca91741d14dfaf94abc753b (diff) | |
download | scala-10d7b668b9e73c3390a172096197299f59cc8c86.tar.gz scala-10d7b668b9e73c3390a172096197299f59cc8c86.tar.bz2 scala-10d7b668b9e73c3390a172096197299f59cc8c86.zip |
Working on making the bootstrap process transpa...
Working on making the bootstrap process transparent and consistent. And
removed a bunch of what is now cruft in partest. No review.
Diffstat (limited to 'src')
4 files changed, 52 insertions, 67 deletions
diff --git a/src/partest/scala/tools/partest/nest/AntRunner.scala b/src/partest/scala/tools/partest/nest/AntRunner.scala index 9219ed3305..16a7141653 100644 --- a/src/partest/scala/tools/partest/nest/AntRunner.scala +++ b/src/partest/scala/tools/partest/nest/AntRunner.scala @@ -19,7 +19,6 @@ class AntRunner extends DirectRunner { var JAVACMD: String = "java" var JAVAC_CMD: String = "javac" var CLASSPATH: String = _ - var EXT_CLASSPATH: String = _ var LATEST_LIB: String = _ val TESTROOT: String = "" } diff --git a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala index c5d67fb4e2..9c395c3d05 100644 --- a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala +++ b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala @@ -21,10 +21,6 @@ import ClassPath.{ join } import PathResolver.{ Environment, Defaults } import RunnerUtils._ -object ConsoleFileManager { - def testRootPropDir = Option(propOrElse("scalatest.root", null)) map (x => Directory(x)) -} -import ConsoleFileManager._ class ConsoleFileManager extends FileManager { implicit private def temporaryPath2File(x: Path): File = x.jfile @@ -61,46 +57,18 @@ class ConsoleFileManager extends FileManager { NestUI.verbose("CLASSPATH: "+CLASSPATH) - val prefixDir = PartestDefaults.prefixDir getOrElse error("user.dir property not set") - val srcDirName = PartestDefaults.srcDirName + val prefixDir = PathSettings.prefixDir val PREFIX = prefixDir.toAbsolute.path - -/* -if [ -d "$PREFIX/test" ]; then - TESTROOT="$PREFIX/test"; -elif [ -d "$PREFIX/misc/scala-test" ]; then - TESTROOT="$PREFIX/misc/scala-test"; -else - abort "Test directory not found"; -*/ - - val testRootDir = { - def isTestDir(d: Directory) = d.name == "test" && (d / "files" isDirectory) - - ( - testRootPropDir 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 = testRootDir.toAbsolute.path - - def testParent = testRootDir.parent - - val srcDir = (testRootDir / srcDirName).toDirectory + val testRootDir = PathSettings.testRoot + val TESTROOT = testRootDir.toAbsolute.path + def testParent = testRootDir.parent + val srcDir = PathSettings.srcDir if (!srcDir.isDirectory) { NestUI.failure("Source directory \"" + srcDir.path + "\" not found") exit(1) } - LIB_DIR = (testParent / "lib").normalize.toAbsolute.path CLASSPATH = { @@ -195,21 +163,10 @@ else latestFjbgFile = prefixFile("lib/fjbg.jar") } - BIN_DIR = latestFile.getAbsolutePath LATEST_LIB = latestLibFile.getAbsolutePath - LATEST_COMP = latestCompFile.getAbsolutePath - LATEST_PARTEST = latestPartestFile.getAbsolutePath - - SCALA = (latestFile / scalaCmd).toAbsolute.path - SCALAC_CMD = (latestFile / scalacCmd).toAbsolute.path } - var BIN_DIR: String = "" var LATEST_LIB: String = "" - var LATEST_COMP: String = "" - var LATEST_PARTEST: String = "" - var SCALA: String = "" - var SCALAC_CMD: String = "" var latestFile: File = _ var latestLibFile: File = _ diff --git a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala index fd25a9c8f3..0020581301 100644 --- a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala +++ b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala @@ -48,6 +48,7 @@ class ConsoleRunner extends DirectRunner { private var testFiles: List[File] = List() private val errors = PartestDefaults.errorCount + private val testSetKinds = testSets map (_.kind) private val testSetArgMap = testSets map (x => ("--" + x.loc) -> x) toMap private val testSetArgs = testSets map ("--" + _.loc) def denotesTestSet(arg: String) = testSetArgs contains arg @@ -175,25 +176,15 @@ class ConsoleRunner extends DirectRunner { */ def testCheckAll(enabledSets: List[TestSet]): (Int, Int) = { def runTestsFiles = if (!testFiles.isEmpty) { - def absName(f: File): String = f.getAbsoluteFile.getCanonicalPath - - def kindOf(f: File): String = { - val firstName = absName(f) - val len = fileManager.srcDirName.length - val filesPos = firstName.indexOf(fileManager.srcDirName) - if (filesPos == -1) { - NestUI.failure("invalid test file: "+firstName+"\n") + def kindOf(f: File) = { + val srcDirSegments = PathSettings.srcDir.segments + val segments = Path(f).normalize.toAbsolute.segments + lazy val kind = (segments drop srcDirSegments.size).head + + if ((segments startsWith srcDirSegments) && (testSetKinds contains kind)) kind + else { + NestUI.failure("invalid test file: "+f.getPath+"\n") Predef.exit(1) - } else { - val short = firstName drop (filesPos + len + 1) take 3 - val shortKinds = List("pos", "neg", "run", "jvm", "res") - if (shortKinds contains short) short - else short match { - case "sho" => "shootout" - case "scr" => "script" - case "sca" => "scalacheck" - case "bui" => "buildmanager" - } } } diff --git a/src/partest/scala/tools/partest/nest/PathSettings.scala b/src/partest/scala/tools/partest/nest/PathSettings.scala new file mode 100644 index 0000000000..17461b3d4d --- /dev/null +++ b/src/partest/scala/tools/partest/nest/PathSettings.scala @@ -0,0 +1,38 @@ +/* NEST (New Scala Test) + * Copyright 2007-2010 LAMP/EPFL + */ + +package scala.tools.partest +package nest + +import scala.tools.nsc.Properties.{ setProp, propOrEmpty, propOrNone, propOrElse } +import scala.tools.nsc.util.ClassPath +import scala.tools.nsc.io +import io.{ Path, File, Directory } +import RunnerUtils._ +import java.net.URLClassLoader + +object PathSettings { + private def isTestDirectory(d: Path) = + d.isDirectory && (d.name == "test") && (d / srcDirProperty isDirectory) + + def testRootProperty = propOrNone("scalatest.root") map (x => Directory(x)) + def srcDirProperty = propOrElse("partest.srcdir", "files") + + // XXX temp + def prefixDir = Directory.Current getOrElse error("user.dir property not set") + + 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.") + } + + lazy val srcDir = Directory((testRoot / srcDirProperty).normalize.toAbsolute) +} + +class PathSettings() { + // def classpathAsURLs: List[URL] +} |