From 5a679984906a0b5b8e537010c5dcb077df3dd94e Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Wed, 6 Apr 2011 20:55:30 -0400 Subject: [PATCH] options specific to each test task, consolidates streams to the right task --- main/Defaults.scala | 15 ++++++++++----- main/Keys.scala | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/main/Defaults.scala b/main/Defaults.scala index 84aa35757..fdaf684fe 100755 --- a/main/Defaults.scala +++ b/main/Defaults.scala @@ -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 => diff --git a/main/Keys.scala b/main/Keys.scala index 417bc065a..d3cd5a8fa 100644 --- a/main/Keys.scala +++ b/main/Keys.scala @@ -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]]