options specific to each test task, consolidates streams to the right task

This commit is contained in:
Mark Harrah 2011-04-06 20:55:30 -04:00
parent 1e7d628dbb
commit 5a67998490
2 changed files with 11 additions and 6 deletions

View File

@ -187,7 +187,7 @@ object Defaults
}
def resourcesTask(dirs: Seq[File], excl: FileFilter, gen: Seq[File], genDir: File) = gen ++ (dirs --- genDir).descendentsExcept("*",excl).getFiles
lazy val testTasks = Seq(
lazy val testTasks = testTaskOptions(test) ++ testTaskOptions(testOnly) ++ Seq(
testLoader <<= (fullClasspath, scalaInstance) map { (cp, si) => TestFramework.createTestLoader(data(cp), si) },
testFrameworks in GlobalScope :== {
import sbt.TestFrameworks._
@ -201,18 +201,23 @@ object Defaults
IO.writeLines(s.text(CompletionsID), tests.map(_.name).distinct)
tests
},
testListeners <<= (streams in test) map ( s => TestLogger(s.log) :: Nil ),
testOptions <<= testListeners map { listeners => Tests.Listeners(listeners) :: Nil },
executeTests <<= (streams in test, loadedTestFrameworks, testOptions, testLoader, definedTests) flatMap {
testListeners :== Nil,
testOptions :== Nil,
executeTests <<= (streams in test, loadedTestFrameworks, testOptions in test, testLoader, definedTests) flatMap {
(s, frameworkMap, options, loader, discovered) => Tests(frameworkMap, loader, discovered, options, s.log)
},
test <<= (executeTests, streams) map { (results, s) => Tests.showResults(s.log, results) },
testOnly <<= testOnlyTask
)
def testTaskOptions(key: Scoped): Seq[Setting[_]] = inTask(key)( Seq(
testListeners <<= (streams, testListeners) map { (s, ls) => TestLogger(s.log) +: ls },
testOptions <<= (testOptions, testListeners) map { (options, ls) => Tests.Listeners(ls) +: options }
) )
def testOnlyTask =
InputTask(resolvedScoped(testOnlyParser)) ( result =>
(streams, loadedTestFrameworks, testOptions, testLoader, definedTests, result) flatMap {
(streams, loadedTestFrameworks, testOptions in testOnly, testLoader, definedTests, result) flatMap {
case (s, frameworks, opts, loader, discovered, (tests, frameworkOptions)) =>
val modifiedOpts = Tests.Filter(if(tests.isEmpty) _ => true else tests.toSet ) +: Tests.Argument(frameworkOptions : _*) +: opts
Tests(frameworks, loader, discovered, modifiedOpts, s.log) map { results =>

View File

@ -126,7 +126,7 @@ object Keys
val testOnly = InputKey[Unit]("test-only")
val testOptions = TaskKey[Seq[TestOption]]("test-options")
val testFrameworks = SettingKey[Seq[TestFramework]]("test-frameworks")
val testListeners = TaskKey[Iterable[TestReportListener]]("test-listeners")
val testListeners = TaskKey[Seq[TestReportListener]]("test-listeners")
// Classpath/Dependency Management Keys
type Classpath = Seq[Attributed[File]]