11package io .bazel .rulesscala .specs2
22
3- import java .util
4- import java .util .regex .Pattern
5-
63import io .bazel .rulesscala .test_discovery .FilteredRunnerBuilder .FilteringRunnerBuilder
74import io .bazel .rulesscala .test_discovery ._
85import org .junit .runner .notification .RunNotifier
@@ -11,13 +8,16 @@ import org.junit.runners.Suite
118import org .junit .runners .model .RunnerBuilder
129import org .specs2 .concurrent .ExecutionEnv
1310import org .specs2 .control .Action
14- import org .specs2 .data . Trees . _
11+ import org .specs2 .fp . Tree . Node
1512import org .specs2 .fp .{Tree , TreeLoc }
1613import org .specs2 .main .{Arguments , CommandLine , Select }
1714import org .specs2 .specification .core .{Env , Fragment , SpecStructure }
1815import org .specs2 .specification .process .Stats
1916
17+ import java .util
18+ import java .util .regex .Pattern
2019import scala .collection .JavaConverters ._
20+ import scala .collection .immutable .Iterable
2121import scala .language .reflectiveCalls
2222import scala .util .Try
2323import scala .util .control .NonFatal
@@ -63,14 +63,21 @@ class FilteredSpecs2ClassRunner(testClass: Class[_], testFilter: Pattern)
6363
6464 private def createFilteredDescription (specStructure : SpecStructure , ee : ExecutionEnv ): Description = {
6565 val descTree = createDescriptionTree(ee).map(_._2)
66- descTree.toTree.bottomUp {
67- (description : Description , children : Stream [Description ]) =>
66+
67+ def bottomUp [A , B ](t : Tree [A ], f : ((A , Iterable [B ]) => B )): Tree [B ] = {
68+ val tbs = t.subForest.map(t => bottomUp(t, f))
69+ Node (f(t.rootLabel, tbs.map(_.rootLabel)), tbs)
70+ }
71+
72+ bottomUp(descTree.toTree, {
73+ (description : Description , children : Iterable [Description ]) =>
6874 children.filter(matchingFilter).foreach {
6975 child => description.addChild(child)
7076 }
7177 description
72- }.rootLabel
78+ }) .rootLabel
7379
80+ descTree.getLabel
7481 }
7582
7683 def matchesFilter : Boolean = {
@@ -118,7 +125,7 @@ class FilteredSpecs2ClassRunner(testClass: Class[_], testFilter: Pattern)
118125 * "Do stuff" in {
119126 * ...
120127 * }
121- * }
128+ * }
122129 * }
123130 *
124131 * Is represented as the following description:
0 commit comments