Search in sources :

Example 1 with TestSuiteExpansion

use of com.google.devtools.build.lib.skyframe.TestSuiteExpansionValue.TestSuiteExpansion in project bazel by bazelbuild.

the class TestSuiteExpansionFunction method compute.

@Override
public SkyValue compute(SkyKey key, Environment env) throws InterruptedException {
    TestSuiteExpansion expansion = (TestSuiteExpansion) key.argument();
    ResolvedTargets<Target> targets = labelsToTargets(env, expansion.getTargets(), false);
    List<SkyKey> testsInSuitesKeys = new ArrayList<>();
    for (Target target : targets.getTargets()) {
        if (TargetUtils.isTestSuiteRule(target)) {
            testsInSuitesKeys.add(TestsInSuiteValue.key(target, true));
        }
    }
    Map<SkyKey, SkyValue> testsInSuites = env.getValues(testsInSuitesKeys);
    if (env.valuesMissing()) {
        return null;
    }
    Set<Target> result = new LinkedHashSet<>();
    boolean hasError = targets.hasError();
    for (Target target : targets.getTargets()) {
        if (TargetUtils.isTestRule(target)) {
            result.add(target);
        } else if (TargetUtils.isTestSuiteRule(target)) {
            TestsInSuiteValue value = (TestsInSuiteValue) testsInSuites.get(TestsInSuiteValue.key(target, true));
            if (value != null) {
                result.addAll(value.getTargets().getTargets());
                hasError |= value.getTargets().hasError();
            }
        } else {
            result.add(target);
        }
    }
    if (env.valuesMissing()) {
        return null;
    }
    // any filtered targets.
    return new TestSuiteExpansionValue(new ResolvedTargets<Target>(result, hasError));
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) LinkedHashSet(java.util.LinkedHashSet) TestSuiteExpansion(com.google.devtools.build.lib.skyframe.TestSuiteExpansionValue.TestSuiteExpansion) ArrayList(java.util.ArrayList) SkyValue(com.google.devtools.build.skyframe.SkyValue) Target(com.google.devtools.build.lib.packages.Target)

Aggregations

Target (com.google.devtools.build.lib.packages.Target)1 TestSuiteExpansion (com.google.devtools.build.lib.skyframe.TestSuiteExpansionValue.TestSuiteExpansion)1 SkyKey (com.google.devtools.build.skyframe.SkyKey)1 SkyValue (com.google.devtools.build.skyframe.SkyValue)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1