diff --git a/build.xml b/build.xml index 483f2b022..eb7ad1e15 100644 --- a/build.xml +++ b/build.xml @@ -257,10 +257,10 @@ INITIALISATION - + @@ -342,12 +342,12 @@ LOCAL REFERENCE BUILD (LOCKER) - - + + @@ -374,10 +374,10 @@ LOCAL REFERENCE BUILD (LOCKER) - + @@ -570,12 +570,12 @@ QUICK BUILD (QUICK) - - + - + + @@ -616,8 +616,8 @@ QUICK BUILD (QUICK) - + @@ -684,11 +684,11 @@ QUICK BUILD (QUICK) - + @@ -729,10 +729,10 @@ QUICK BUILD (QUICK) - + @@ -1013,12 +1013,12 @@ BOOTSTRAPPING BUILD (STRAP) - - + - + + @@ -1059,8 +1059,8 @@ BOOTSTRAPPING BUILD (STRAP) - + @@ -1587,9 +1587,9 @@ STABLE REFERENCE (STARR) - + diff --git a/src/partest/scala/tools/partest/nest/AntRunner.scala b/src/partest/scala/tools/partest/nest/AntRunner.scala index 7e222cbe2..2b1f491c6 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 a83fe78f6..72119deb2 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 = { @@ -194,22 +162,11 @@ 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 171649e40..fd90ddfc3 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 000000000..308d19666 --- /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] +}