Ensure that TestsFunction produces unique results given unique inputs.
RELNOTES: None
@@ -68,16 +68,26 @@ public class TestsFunction implements QueryFunction {
List<Argument> args,
final Callback<T> callback) {
final Closure<T> closure = new Closure<>(expression, env);
+ final Uniquifier<T> uniquifier = env.createUniquifier();
- return env.eval(args.get(0).getExpression(), context, new Callback<T>() {
+ return env.eval(
+ args.get(0).getExpression(),
+ context,
+ new Callback<T>() {
@Override
- public void process(Iterable<T> partialResult) throws QueryException, InterruptedException {
+ public void process(Iterable<T> partialResult)
+ throws QueryException, InterruptedException {
for (T target : partialResult) {
if (env.getAccessor().isTestRule(target)) {
+ if (uniquifier.unique(target)) {
callback.process(ImmutableList.of(target));
+ }
} else if (env.getAccessor().isTestSuite(target)) {
for (T test : closure.getTestsInSuite(target)) {
- callback.process(ImmutableList.of(env.getOrCreate(test)));
+ T testTarget = env.getOrCreate(test);
+ if (uniquifier.unique(testTarget)) {
+ callback.process(ImmutableList.of(testTarget));
+ }
}
}
}
