mirror of https://github.com/sbt/sbt.git
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:
commit
e9fb853a7a
|
|
@ -150,7 +150,14 @@ object Tests {
|
||||||
def includeTest(test: TestDefinition) = !excludeTestsSet.contains(test.name) && testFilters.forall(filter => filter(test.name))
|
def includeTest(test: TestDefinition) = !excludeTestsSet.contains(test.name) && testFilters.forall(filter => filter(test.name))
|
||||||
val filtered0 = discovered.filter(includeTest).toList.distinct
|
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
|
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] =
|
def apply(frameworks: Map[TestFramework, Framework], testLoader: ClassLoader, runners: Map[TestFramework, Runner], discovered: Seq[TestDefinition], config: Execution, log: Logger): Task[Output] =
|
||||||
|
|
|
||||||
|
|
@ -6,3 +6,7 @@ $ absent succeed
|
||||||
# it will fail if run via junit and succeed if run via specs
|
# it will fail if run via junit and succeed if run via specs
|
||||||
$ touch succeed
|
$ touch succeed
|
||||||
> test
|
> test
|
||||||
|
|
||||||
|
# also run with forked tests
|
||||||
|
> set fork in Test := true
|
||||||
|
> test
|
||||||
|
|
|
||||||
|
|
@ -131,19 +131,13 @@ object TestFramework {
|
||||||
log: Logger,
|
log: Logger,
|
||||||
listeners: Seq[TestReportListener]): (() => Unit, Seq[(String, TestFunction)], TestResult.Value => () => Unit) =
|
listeners: Seq[TestReportListener]): (() => Unit, Seq[(String, TestFunction)], TestResult.Value => () => Unit) =
|
||||||
{
|
{
|
||||||
val unique = distinctBy(tests)(_.name)
|
val mappedTests = testMap(frameworks.values.toSeq, tests)
|
||||||
val mappedTests = testMap(frameworks.values.toSeq, unique)
|
|
||||||
if (mappedTests.isEmpty)
|
if (mappedTests.isEmpty)
|
||||||
(() => (), Nil, _ => () => ())
|
(() => (), Nil, _ => () => ())
|
||||||
else
|
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)] =
|
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)
|
for (d <- inputs; act <- mapped.get(d.name)) yield (d.name, act)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue