mirror of https://github.com/sbt/sbt.git
Extract common code to a separate method.
This commit is contained in:
parent
75dfccf098
commit
f122b95e46
|
|
@ -14,7 +14,7 @@ package sbt
|
||||||
import complete._
|
import complete._
|
||||||
import std.TaskExtra._
|
import std.TaskExtra._
|
||||||
import inc.{FileValueCache, Locate}
|
import inc.{FileValueCache, Locate}
|
||||||
import org.scalatools.testing.{AnnotatedFingerprint, SubclassFingerprint}
|
import org.scalatools.testing.{Framework, AnnotatedFingerprint, SubclassFingerprint}
|
||||||
|
|
||||||
import sys.error
|
import sys.error
|
||||||
import scala.xml.NodeSeq
|
import scala.xml.NodeSeq
|
||||||
|
|
@ -287,19 +287,7 @@ object Defaults extends BuildCommon
|
||||||
testOptions in GlobalScope :== Nil,
|
testOptions in GlobalScope :== Nil,
|
||||||
testFilter in testOnly :== (selectedFilter _),
|
testFilter in testOnly :== (selectedFilter _),
|
||||||
testFilter in testQuick <<= testQuickFilter,
|
testFilter in testQuick <<= testQuickFilter,
|
||||||
executeTests <<= (streams in test, loadedTestFrameworks, testLoader, testGrouping in test, testExecution in test, fullClasspath in test, javaHome in test) flatMap {
|
executeTests <<= (streams in test, loadedTestFrameworks, testLoader, testGrouping in test, testExecution in test, fullClasspath in test, javaHome in test) flatMap allTestGroupsTask,
|
||||||
(s, frameworkMap, loader, groups, config, cp, javaHome) =>
|
|
||||||
val tasks = groups map {
|
|
||||||
case Tests.Group(name, tests, runPolicy) =>
|
|
||||||
runPolicy match {
|
|
||||||
case Tests.SubProcess(javaOpts) =>
|
|
||||||
ForkTests(frameworkMap.keys.toSeq, tests.toList, config, cp.files, javaHome, javaOpts, s.log) tag Tags.ForkedTestGroup
|
|
||||||
case Tests.InProcess =>
|
|
||||||
Tests(frameworkMap, loader, tests, config, s.log)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Tests.foldTasks(tasks)
|
|
||||||
},
|
|
||||||
test <<= (executeTests, streams, resolvedScoped, state) map {
|
test <<= (executeTests, streams, resolvedScoped, state) map {
|
||||||
(results, s, scoped, st) =>
|
(results, s, scoped, st) =>
|
||||||
implicit val display = Project.showContextKey(st)
|
implicit val display = Project.showContextKey(st)
|
||||||
|
|
@ -378,19 +366,23 @@ object Defaults extends BuildCommon
|
||||||
(streams, loadedTestFrameworks, testFilter in key, testGrouping in key, testExecution in key, testLoader, resolvedScoped, result, fullClasspath in key, javaHome in key, state) flatMap {
|
(streams, loadedTestFrameworks, testFilter in key, testGrouping in key, testExecution in key, testLoader, resolvedScoped, result, fullClasspath in key, javaHome in key, state) flatMap {
|
||||||
case (s, frameworks, filter, groups, config, loader, scoped, (selected, frameworkOptions), cp, javaHome, st) =>
|
case (s, frameworks, filter, groups, config, loader, scoped, (selected, frameworkOptions), cp, javaHome, st) =>
|
||||||
implicit val display = Project.showContextKey(st)
|
implicit val display = Project.showContextKey(st)
|
||||||
val tasks = groups map {
|
|
||||||
case Tests.Group(name, tests, runPolicy) =>
|
|
||||||
val modifiedOpts = Tests.Filter(filter(selected)) +: Tests.Argument(frameworkOptions : _*) +: config.options
|
val modifiedOpts = Tests.Filter(filter(selected)) +: Tests.Argument(frameworkOptions : _*) +: config.options
|
||||||
val newConfig = config.copy(options = modifiedOpts)
|
val newConfig = config.copy(options = modifiedOpts)
|
||||||
|
allTestGroupsTask(s, frameworks, loader, groups, newConfig, cp, javaHome) map (Tests.showResults(s.log, _, noTestsMessage(scoped)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def allTestGroupsTask(s: TaskStreams, frameworks: Map[TestFramework,Framework], loader: ClassLoader, groups: Seq[Tests.Group], config: Tests.Execution, cp: Classpath, javaHome: Option[File]): Task[Tests.Output] = {
|
||||||
|
val groupTasks = groups map {
|
||||||
|
case Tests.Group(name, tests, runPolicy) =>
|
||||||
runPolicy match {
|
runPolicy match {
|
||||||
case Tests.SubProcess(javaOpts) =>
|
case Tests.SubProcess(javaOpts) =>
|
||||||
ForkTests(frameworks.keys.toSeq, tests.toList, newConfig, cp.files, javaHome, javaOpts, s.log) tag Tags.ForkedTestGroup
|
ForkTests(frameworks.keys.toSeq, tests.toList, config, cp.files, javaHome, javaOpts, s.log) tag Tags.ForkedTestGroup
|
||||||
case Tests.InProcess =>
|
case Tests.InProcess =>
|
||||||
Tests(frameworks, loader, tests, newConfig, s.log)
|
Tests(frameworks, loader, tests, config, s.log)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Tests.foldTasks(tasks) map (Tests.showResults(s.log, _, noTestsMessage(scoped)))
|
Tests.foldTasks(groupTasks)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def selectedFilter(args: Seq[String]): String => Boolean =
|
def selectedFilter(args: Seq[String]): String => Boolean =
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue