Merge pull request #1450 from pvlugter/junit-tests

Select the first test fingerprint for a test name for forked tests
This commit is contained in:
Josh Suereth 2014-07-14 09:36:41 -04:00
commit e9fb853a7a
3 changed files with 15 additions and 10 deletions

View File

@ -150,7 +150,14 @@ object Tests {
def includeTest(test: TestDefinition) = !excludeTestsSet.contains(test.name) && testFilters.forall(filter => filter(test.name))
val filtered0 = discovered.filter(includeTest).toList.distinct
val tests = if (orderedFilters.isEmpty) filtered0 else orderedFilters.flatMap(f => filtered0.filter(d => f(d.name))).toList.distinct
new ProcessedOptions(tests, setup.toList, cleanup.toList, testListeners.toList)
val uniqueTests = distinctBy(tests)(_.name)
new ProcessedOptions(uniqueTests, setup.toList, cleanup.toList, testListeners.toList)
}
private[this] def distinctBy[T, K](in: Seq[T])(f: T => K): Seq[T] =
{
val seen = new collection.mutable.HashSet[K]
in.filter(t => seen.add(f(t)))
}
def apply(frameworks: Map[TestFramework, Framework], testLoader: ClassLoader, runners: Map[TestFramework, Runner], discovered: Seq[TestDefinition], config: Execution, log: Logger): Task[Output] =

View File

@ -5,4 +5,8 @@ $ absent succeed
# indicate to the test it should succeed
# it will fail if run via junit and succeed if run via specs
$ touch succeed
> test
> test
# also run with forked tests
> set fork in Test := true
> test

View File

@ -131,19 +131,13 @@ object TestFramework {
log: Logger,
listeners: Seq[TestReportListener]): (() => Unit, Seq[(String, TestFunction)], TestResult.Value => () => Unit) =
{
val unique = distinctBy(tests)(_.name)
val mappedTests = testMap(frameworks.values.toSeq, unique)
val mappedTests = testMap(frameworks.values.toSeq, tests)
if (mappedTests.isEmpty)
(() => (), Nil, _ => () => ())
else
createTestTasks(testLoader, runners.map { case (tf, r) => (frameworks(tf), new TestRunner(r, listeners, log)) }, mappedTests, unique, log, listeners)
createTestTasks(testLoader, runners.map { case (tf, r) => (frameworks(tf), new TestRunner(r, listeners, log)) }, mappedTests, tests, log, listeners)
}
private[this] def distinctBy[T, K](in: Seq[T])(f: T => K): Seq[T] =
{
val seen = new collection.mutable.HashSet[K]
in.filter(t => seen.add(f(t)))
}
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)