diff options
Diffstat (limited to 'project/PartestUtil.scala')
-rw-r--r-- | project/PartestUtil.scala | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/project/PartestUtil.scala b/project/PartestUtil.scala index 0bbbc3dc69..40031192e4 100644 --- a/project/PartestUtil.scala +++ b/project/PartestUtil.scala @@ -1,3 +1,5 @@ +package scala.build + import sbt._ import sbt.complete._, Parser._, Parsers._ @@ -24,18 +26,22 @@ object PartestUtil { isParentOf(testBase / srcPath, f, 2) || isParentOf(f, testBase / srcPath, Int.MaxValue) } } + + def testFilePaths(globalBase: File, testBase: File): Seq[java.io.File] = + (new TestFiles("files", globalBase, testBase)).allTestCases.map(_._1) + /** A parser for the custom `partest` command */ def partestParser(globalBase: File, testBase: File): Parser[String] = { val knownUnaryOptions = List( "--pos", "--neg", "--run", "--jvm", "--res", "--ant", "--scalap", "--specialized", - "--scalacheck", "--instrumented", "--presentation", "--failed", "--update-check", + "--instrumented", "--presentation", "--failed", "--update-check", "--show-diff", "--show-log", "--verbose", "--terse", "--debug", "--version", "--self-test", "--help") val srcPathOption = "--srcpath" val grepOption = "--grep" - // HACK: if we parse `--srpath scaladoc`, we overwrite this var. The parser for test file paths + // HACK: if we parse `--srcpath scaladoc`, we overwrite this var. The parser for test file paths // then lazily creates the examples based on the current value. - // TODO is there a cleaner way to do this with SBT's parser infrastructure? + // TODO is there a cleaner way to do this with sbt's parser infrastructure? var srcPath = "files" var _testFiles: TestFiles = null def testFiles = { @@ -64,9 +70,9 @@ object PartestUtil { } val matchingFileName = try { val filter = GlobFilter("*" + x + "*") - testFiles.allTestCases.filter(x => filter.accept(x._1.name)) + testFiles.allTestCases.filter(x => filter.accept(x._1.asFile.getPath)) } catch { - case t: Throwable => Nil + case _: Throwable => Nil } (matchingFileContent ++ matchingFileName).map(_._2).distinct.sorted } @@ -81,12 +87,15 @@ object PartestUtil { token(grepOption <~ Space) ~> token(globOrPattern, tokenCompletion) } - val SrcPath = ((token(srcPathOption) <~ Space) ~ token(StringBasic.examples(Set("files", "pending", "scaladoc")))) map { + val SrcPath = ((token(srcPathOption) <~ Space) ~ token(StringBasic.examples(Set("files", "scaladoc")))) map { case opt ~ path => srcPath = path opt + " " + path } - val P = oneOf(knownUnaryOptions.map(x => token(x))) | SrcPath | TestPathParser | Grep - (Space ~> repsep(P, oneOrMore(Space))).map(_.mkString(" ")).?.map(_.getOrElse("")) <~ OptSpace + + val ScalacOptsParser = (token("-Dpartest.scalac_opts=") ~ token(NotSpace)) map { case opt ~ v => opt + v } + + val P = oneOf(knownUnaryOptions.map(x => token(x))) | SrcPath | TestPathParser | Grep | ScalacOptsParser + (Space ~> repsep(P, oneOrMore(Space))).map(_.mkString(" ")).?.map(_.getOrElse("")) } } |