diff --git a/main/actions/src/main/scala/sbt/Tests.scala b/main/actions/src/main/scala/sbt/Tests.scala index 22ae552cc..9dee65e78 100644 --- a/main/actions/src/main/scala/sbt/Tests.scala +++ b/main/actions/src/main/scala/sbt/Tests.scala @@ -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] = diff --git a/sbt/src/sbt-test/tests/one-class-multi-framework/test b/sbt/src/sbt-test/tests/one-class-multi-framework/test index 1ae08f6fb..2f6f758e7 100644 --- a/sbt/src/sbt-test/tests/one-class-multi-framework/test +++ b/sbt/src/sbt-test/tests/one-class-multi-framework/test @@ -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 \ No newline at end of file +> test + +# also run with forked tests +> set fork in Test := true +> test diff --git a/testing/src/main/scala/sbt/TestFramework.scala b/testing/src/main/scala/sbt/TestFramework.scala index 0c296fa7e..6595fd472 100644 --- a/testing/src/main/scala/sbt/TestFramework.scala +++ b/testing/src/main/scala/sbt/TestFramework.scala @@ -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)