// Copyright 2015 The Bazel Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package com.google.devtools.build.lib.skyframe; import com.google.common.collect.ImmutableSet; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.cmdline.PackageIdentifier; import com.google.devtools.build.lib.cmdline.ResolvedTargets; import com.google.devtools.build.lib.packages.NoSuchTargetException; import com.google.devtools.build.lib.packages.Package; import com.google.devtools.build.lib.packages.Target; import com.google.devtools.build.lib.packages.TargetUtils; import com.google.devtools.build.lib.skyframe.TestSuiteExpansionValue.TestSuiteExpansionKey; import com.google.devtools.build.skyframe.SkyFunction; import com.google.devtools.build.skyframe.SkyKey; import com.google.devtools.build.skyframe.SkyValue; import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; import javax.annotation.Nullable; /** * TestSuiteExpansionFunction takes a list of targets and expands all test suites in those targets. */ final class TestSuiteExpansionFunction implements SkyFunction { @Override public SkyValue compute(SkyKey key, Environment env) throws InterruptedException { TestSuiteExpansionKey expansion = (TestSuiteExpansionKey) key.argument(); ResolvedTargets targets = labelsToTargets(env, expansion.getTargets(), false); List testsInSuitesKeys = new ArrayList<>(); for (Target target : targets.getTargets()) { if (TargetUtils.isTestSuiteRule(target)) { testsInSuitesKeys.add(TestsInSuiteValue.key(target, true)); } } Map testsInSuites = env.getValues(testsInSuitesKeys); if (env.valuesMissing()) { return null; } Set