mirror of https://github.com/sbt/sbt.git
tab complete scripted tests
This commit is contained in:
parent
4816991b18
commit
c62dd99ddf
|
|
@ -142,7 +142,7 @@ object Sbt extends Build
|
||||||
normalizedName := "sbt"
|
normalizedName := "sbt"
|
||||||
)
|
)
|
||||||
|
|
||||||
def scriptedTask: Initialize[InputTask[Unit]] = inputTask { result =>
|
def scriptedTask: Initialize[InputTask[Unit]] = InputTask(scriptedSource(dir => (s: State) => scriptedParser(dir))) { result =>
|
||||||
(proguard in Proguard, fullClasspath in scriptedSbtSub in Test, scalaInstance in scriptedSbtSub, publishAll, version, scalaVersion, scriptedScalaVersion, scriptedSource, result) map {
|
(proguard in Proguard, fullClasspath in scriptedSbtSub in Test, scalaInstance in scriptedSbtSub, publishAll, version, scalaVersion, scriptedScalaVersion, scriptedSource, result) map {
|
||||||
(launcher, scriptedSbtClasspath, scriptedSbtInstance, _, v, sv, ssv, sourcePath, args) =>
|
(launcher, scriptedSbtClasspath, scriptedSbtInstance, _, v, sv, ssv, sourcePath, args) =>
|
||||||
val loader = classpath.ClasspathUtilities.toLoader(scriptedSbtClasspath.files, scriptedSbtInstance.loader)
|
val loader = classpath.ClasspathUtilities.toLoader(scriptedSbtClasspath.files, scriptedSbtInstance.loader)
|
||||||
|
|
@ -154,6 +154,23 @@ object Sbt extends Build
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import sbt.complete._
|
||||||
|
import DefaultParsers._
|
||||||
|
def scriptedParser(scriptedBase: File): Parser[Seq[String]] =
|
||||||
|
{
|
||||||
|
val pairs = (scriptedBase * AllPassFilter * AllPassFilter * "test").get map { (f: File) =>
|
||||||
|
val p = f.getParentFile
|
||||||
|
(p.getParentFile.getName, p.getName)
|
||||||
|
};
|
||||||
|
val pairMap = pairs.groupBy(_._1).mapValues(_.map(_._2).toSet) ;
|
||||||
|
|
||||||
|
val id = charClass(c => !c.isWhitespace && c != '/').+.string
|
||||||
|
val groupP = token(id.examples(pairMap.keySet.toSet)) <~ token('/')
|
||||||
|
def nameP(group: String) = "*".id | id.examples(pairMap(group))
|
||||||
|
val testID = for( group <- groupP; name <- nameP(group) ) yield (group, name)
|
||||||
|
(token(Space) ~> matched(testID)).*
|
||||||
|
}
|
||||||
|
|
||||||
lazy val scriptedScalaVersion = SettingKey[String]("scripted-scala-version")
|
lazy val scriptedScalaVersion = SettingKey[String]("scripted-scala-version")
|
||||||
lazy val scripted = InputKey[Unit]("scripted")
|
lazy val scripted = InputKey[Unit]("scripted")
|
||||||
lazy val scriptedSource = SettingKey[File]("scripted-source")
|
lazy val scriptedSource = SettingKey[File]("scripted-source")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue