summaryrefslogtreecommitdiff
path: root/src/partest
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-03-22 04:28:21 +0000
committerPaul Phillips <paulp@improving.org>2011-03-22 04:28:21 +0000
commit063e8a9dfee3d2c889f9e2e28cda2e8a28aa61cc (patch)
tree6b71b04f71cc2eacea4f0464c22b29c823337e96 /src/partest
parent971653e40d8273d300bba17e1d25bf282dad6e5e (diff)
downloadscala-063e8a9dfee3d2c889f9e2e28cda2e8a28aa61cc.tar.gz
scala-063e8a9dfee3d2c889f9e2e28cda2e8a28aa61cc.tar.bz2
scala-063e8a9dfee3d2c889f9e2e28cda2e8a28aa61cc.zip
Not yet learned my lesson about partest and emp...
Not yet learned my lesson about partest and empty directories. Rather than reapply that bandaid, went after partest. Attempts to make partest ignore empty directories. Discover directory tests aren't run when the command line tool is used, make them run like everyone else. Find more tests which due to misplacement are silently ignored, move them into tested locations. No review.
Diffstat (limited to 'src/partest')
-rw-r--r--src/partest/scala/tools/partest/nest/ConsoleRunner.scala39
-rw-r--r--src/partest/scala/tools/partest/nest/DirectRunner.scala17
2 files changed, 31 insertions, 25 deletions
diff --git a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala
index b79c2bbbdb..e2afc5644f 100644
--- a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala
+++ b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala
@@ -21,22 +21,23 @@ class ConsoleRunner extends DirectRunner {
import PathSettings.{ srcDir, testRoot }
case class TestSet(kind: String, filter: Path => Boolean, msg: String)
+ def stdFilter(p: Path) = p.isDirectory || (p hasExtension "scala")
val testSets = {
- val pathFilter: Path => Boolean = _ hasExtension "scala"
+ val pathFilter: Path => Boolean = x => x.isDirectory || (x hasExtension "scala")
List(
- TestSet("pos", pathFilter, "Testing compiler (on files whose compilation should succeed)"),
- TestSet("neg", pathFilter, "Testing compiler (on files whose compilation should fail)"),
- TestSet("run", pathFilter, "Testing interpreter and backend"),
- TestSet("jvm", pathFilter, "Testing JVM backend"),
+ TestSet("pos", stdFilter, "Testing compiler (on files whose compilation should succeed)"),
+ TestSet("neg", stdFilter, "Testing compiler (on files whose compilation should fail)"),
+ TestSet("run", stdFilter, "Testing interpreter and backend"),
+ TestSet("jvm", stdFilter, "Testing JVM backend"),
TestSet("res", x => x.isFile && (x hasExtension "res"), "Testing resident compiler"),
TestSet("buildmanager", _.isDirectory, "Testing Build Manager"),
- TestSet("shootout", pathFilter, "Testing shootout tests"),
- TestSet("script", pathFilter, "Testing script tests"),
- TestSet("scalacheck", x => pathFilter(x) || x.isDirectory, "Testing ScalaCheck tests"),
+ TestSet("shootout", stdFilter, "Testing shootout tests"),
+ TestSet("script", stdFilter, "Testing script tests"),
+ TestSet("scalacheck", stdFilter, "Testing ScalaCheck tests"),
TestSet("scalap", _.isDirectory, "Run scalap decompiler tests"),
- TestSet("specialized", pathFilter, "Testing specialized tests"),
+ TestSet("specialized", stdFilter, "Testing specialized tests"),
TestSet("presentation", _.isDirectory, "Testing presentation compiler tests.")
)
}
@@ -49,10 +50,7 @@ class ConsoleRunner extends DirectRunner {
private val testSetArgs = testSets map ("--" + _.kind)
private val testSetArgMap = testSetArgs zip testSets toMap
- def denotesTestSet(arg: String) = testSetArgs contains arg
- def denotesTestFile(arg: String) = (arg endsWith ".scala") || (arg endsWith ".res")
- def denotesTestDir(arg: String) = Path(arg).isDirectory
- def denotesTestPath(arg: String) = denotesTestDir(arg) || denotesTestFile(arg)
+ def denotesTestSet(arg: String) = testSetArgs contains arg
private def printVersion { NestUI outline (versionMsg + "\n") }
@@ -72,22 +70,17 @@ class ConsoleRunner extends DirectRunner {
(path.isFile && pred(path)) ||
(path.isDirectory && srcs.exists(pred)) ||
- (pred(Path(path.toAbsolute.stripExtension + ".check")))
+ (pred(path changeExtension "check"))
}
def main(argstr: String) {
val parsed = CommandLineParser(argstr) withUnaryArgs unaryArgs withBinaryArgs binaryArgs
- val args = parsed.residualArgs
+ val args = onlyValidTestPaths(parsed.residualArgs)
/** Early return on no args, version, or invalid args */
if (argstr == "") return NestUI.usage()
if (parsed isSet "--version") return printVersion
if (parsed isSet "--help") return NestUI.usage()
- if (args exists (x => !denotesTestPath(x))) {
- val invalid = (args filterNot denotesTestPath).head
- NestUI.failure("Invalid argument '%s'\n" format invalid)
- return NestUI.usage()
- }
parsed get "--srcpath" foreach (x => setProp("partest.srcdir", x))
@@ -97,7 +90,7 @@ class ConsoleRunner extends DirectRunner {
else if (parsed isSet "--pack") new ConsoleFileManager("build/pack")
else new ConsoleFileManager // auto detection, see ConsoleFileManager.findLatest
- def argNarrowsTests(x: String) = denotesTestSet(x) || denotesTestFile(x) || denotesTestDir(x)
+ def argNarrowsTests(x: String) = denotesTestSet(x) || denotesTestPath(x)
NestUI._verbose = parsed isSet "--verbose"
fileManager.showDiff = true
@@ -126,7 +119,7 @@ class ConsoleRunner extends DirectRunner {
val grepOption = parsed get "--grep"
val grepPaths = grepOption.toList flatMap { expr =>
val subjectDirs = testSetKinds map (srcDir / _ toDirectory)
- val testPaths = subjectDirs flatMap (_.files filter (x => x.hasExtension("scala") || x.isDirectory))
+ val testPaths = subjectDirs flatMap (_.files filter stdFilter)
val paths = testPaths filter (p => pathMatchesExpr(p, expr))
if (paths.isEmpty)
@@ -168,7 +161,7 @@ class ConsoleRunner extends DirectRunner {
"Java options are: " + vmOpts,
"Source directory is: " + srcDir,
""
- ) foreach (x => NestUI outline (x + "\n"))
+ ) foreach (x => NestUI verbose (x + "\n"))
NestUI.verbose("available processors: " + Runtime.getRuntime().availableProcessors())
diff --git a/src/partest/scala/tools/partest/nest/DirectRunner.scala b/src/partest/scala/tools/partest/nest/DirectRunner.scala
index 96b0c5bea6..d4b1c8dcb1 100644
--- a/src/partest/scala/tools/partest/nest/DirectRunner.scala
+++ b/src/partest/scala/tools/partest/nest/DirectRunner.scala
@@ -26,6 +26,20 @@ trait DirectRunner {
import PartestDefaults.numActors
+ def denotesTestFile(arg: String) = Path(arg).hasExtension("scala", "res")
+ def denotesTestDir(arg: String) = Path(arg).ifDirectory(_.files.nonEmpty) exists (x => x)
+ def denotesTestPath(arg: String) = denotesTestDir(arg) || denotesTestFile(arg)
+
+ /** No duplicate, no empty directories, don't mess with this unless
+ * you like partest hangs.
+ */
+ def onlyValidTestPaths[T](args: List[T]): List[T] = {
+ args.distinct filter (arg => denotesTestPath("" + arg) || {
+ NestUI.warning("Discarding invalid test path '%s'\n" format arg)
+ false
+ })
+ }
+
def setProperties() {
if (isPartestDebug)
scala.actors.Debug.level = 3
@@ -37,8 +51,7 @@ trait DirectRunner {
}
def runTestsForFiles(_kindFiles: List[File], kind: String): immutable.Map[String, Int] = {
- /** NO DUPLICATES, or partest will blow the count and hang forever. */
- val kindFiles = _kindFiles.distinct
+ val kindFiles = onlyValidTestPaths(_kindFiles)
val groupSize = (kindFiles.length / numActors) + 1
val consFM = new ConsoleFileManager