mirror of https://github.com/sbt/sbt.git
Added code to tag test task using Array[String] returned from Task.tags method.
This commit is contained in:
parent
f862e64911
commit
ad18b4f3ae
|
|
@ -11,7 +11,7 @@ package sbt
|
|||
import xsbti.api.Definition
|
||||
import ConcurrentRestrictions.Tag
|
||||
|
||||
import testing.{AnnotatedFingerprint, Fingerprint, Framework, SubclassFingerprint, Runner}
|
||||
import testing.{AnnotatedFingerprint, Fingerprint, Framework, SubclassFingerprint, Runner, Task => TestTask}
|
||||
|
||||
import java.io.File
|
||||
|
||||
|
|
@ -120,11 +120,12 @@ object Tests
|
|||
cleanupTasks map { _ => results }
|
||||
}
|
||||
}
|
||||
type TestRunnable = (String, () => SuiteResult)
|
||||
type TestRunnable = (String, TestFunction)
|
||||
def makeParallel(runnables: Iterable[TestRunnable], setupTasks: Task[Unit], tags: Seq[(Tag,Int)]) =
|
||||
runnables map { case (name, test) => task { (name, test()) } tagw(tags : _*) dependsOn setupTasks named name }
|
||||
runnables map { case (name, test) => task { (name, test.apply()) } tagw(tags : _*) tag(test.tags map (ConcurrentRestrictions.Tag(_)) : _*) dependsOn setupTasks named name }
|
||||
|
||||
def makeSerial(runnables: Seq[TestRunnable], setupTasks: Task[Unit], tags: Seq[(Tag,Int)]) =
|
||||
task { runnables map { case (name, test) => (name, test()) } } dependsOn(setupTasks)
|
||||
task { runnables map { case (name, test) => (name, test.apply()) } } dependsOn(setupTasks)
|
||||
|
||||
def processResults(results: Iterable[(String, SuiteResult)]): Output =
|
||||
Output(overall(results.map(_._2.result)), results.toMap, Iterable.empty)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ package sbt
|
|||
|
||||
import java.io.File
|
||||
import java.net.URLClassLoader
|
||||
import testing.{Logger=>TLogger, _}
|
||||
import testing.{Logger=>TLogger, Task => TestTask, _}
|
||||
import org.scalatools.testing.{Framework => OldFramework}
|
||||
import classpath.{ClasspathUtilities, DualLoader, FilteredLoader}
|
||||
import scala.annotation.tailrec
|
||||
|
|
@ -65,7 +65,10 @@ final class TestDefinition(val name: String, val fingerprint: Fingerprint)
|
|||
|
||||
final class TestRunner(delegate: Runner, listeners: Seq[TestReportListener], log: Logger) {
|
||||
|
||||
final def run(testDefinition: TestDefinition): SuiteResult =
|
||||
final def task(testDefinition: TestDefinition): TestTask =
|
||||
delegate.task(testDefinition.name, testDefinition.fingerprint, false, Array(new SuiteSelector)) // TODO: To pass in correct explicitlySpecified and selectors
|
||||
|
||||
final def run(testDefinition: TestDefinition, testTask: TestTask): SuiteResult =
|
||||
{
|
||||
log.debug("Running " + testDefinition)
|
||||
val name = testDefinition.name
|
||||
|
|
@ -75,10 +78,7 @@ final class TestRunner(delegate: Runner, listeners: Seq[TestReportListener], log
|
|||
val results = new scala.collection.mutable.ListBuffer[Event]
|
||||
val handler = new EventHandler { def handle(e:Event){ results += e } }
|
||||
val loggers = listeners.flatMap(_.contentLogger(testDefinition))
|
||||
try {
|
||||
// TODO: To pass in correct explicitlySpecified and selectors
|
||||
delegate.task(testDefinition.name, testDefinition.fingerprint, false, Array(new SuiteSelector)).execute(handler, loggers.map(_.log).toArray)
|
||||
}
|
||||
try testTask.execute(handler, loggers.map(_.log).toArray)
|
||||
finally loggers.foreach( _.flush() )
|
||||
val event = TestEvent(results)
|
||||
safeListenersCall(_.testEvent( event ))
|
||||
|
|
@ -148,7 +148,7 @@ object TestFramework
|
|||
log: Logger,
|
||||
listeners: Seq[TestReportListener],
|
||||
testArgsByFramework: Map[Framework, Seq[String]]):
|
||||
(() => Unit, Seq[(String, () => SuiteResult)], TestResult.Value => () => Unit) =
|
||||
(() => Unit, Seq[(String, TestFunction)], TestResult.Value => () => Unit) =
|
||||
{
|
||||
val arguments = testArgsByFramework withDefaultValue Nil
|
||||
val mappedTests = testMap(frameworks.values.toSeq, tests, arguments)
|
||||
|
|
@ -158,7 +158,7 @@ object TestFramework
|
|||
createTestTasks(testLoader, runners.map { case (tf, r) => (frameworks(tf), new TestRunner(r, listeners, log))}, mappedTests, tests, log, listeners)
|
||||
}
|
||||
|
||||
private[this] def order(mapped: Map[String, () => SuiteResult], inputs: Seq[TestDefinition]): Seq[(String, () => SuiteResult)] =
|
||||
private[this] def order(mapped: Map[String, TestFunction], inputs: Seq[TestDefinition]): Seq[(String, TestFunction)] =
|
||||
for( d <- inputs; act <- mapped.get(d.name) ) yield (d.name, act)
|
||||
|
||||
private[this] def testMap(frameworks: Seq[Framework], tests: Seq[TestDefinition], args: Map[Framework, Seq[String]]):
|
||||
|
|
@ -204,8 +204,9 @@ object TestFramework
|
|||
val runner = runners(framework)
|
||||
for(testDefinition <- testDefinitions) yield
|
||||
{
|
||||
val runTest = () => withContextLoader(loader) { runner.run(testDefinition) }
|
||||
(testDefinition.name, runTest)
|
||||
val task = withContextLoader(loader) { runner.task(testDefinition) }
|
||||
val testFunction = new TestFunction(() => withContextLoader(loader) { runner.run(testDefinition, task) }) { def tags = task.tags }
|
||||
(testDefinition.name, testFunction)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -228,3 +229,7 @@ object TestFramework
|
|||
ClasspathUtilities.filterByClasspath(interfaceJar +: classpath, main)
|
||||
}
|
||||
}
|
||||
|
||||
abstract class TestFunction(val apply: () => SuiteResult) {
|
||||
def tags: Array[String]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue