diff options
author | 2016-12-06 17:06:41 +0000 | |
---|---|---|
committer | 2016-12-06 18:29:05 +0000 | |
commit | 12d766df10fbc5eba16ec1e6c20c8cd85f9c616f (patch) | |
tree | 9618560e185449c1ff7ac6b152f5e99d1daeab06 /src/test/java/com/google/devtools/build/lib | |
parent | 978c4a9f8ba0da990fa62a80570865be1d0d48b9 (diff) |
Provide deterministic order for split configured deps (roll forward)
Also:
- Make ConfiguredTargetFunction.getDynamicConfigurations more readable.
- Add a bit more testing coverage for configured dep resolution.
This is a roll forward of commit 7505d94c19727e3100ac5e16a960bff2cb324f23. The original changed failed on
Windows because "ppc" wasn't recognized as a valid cpu:
https://github.com/bazelbuild/bazel/issues/2191
This version uses "armeabi-v7a" instead.
--
PiperOrigin-RevId: 141185293
MOS_MIGRATED_REVID=141185293
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/skyframe/ConfigurationsForTargetsTest.java | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ConfigurationsForTargetsTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ConfigurationsForTargetsTest.java index e6bfebc8ac..64e54d92f0 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/ConfigurationsForTargetsTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/ConfigurationsForTargetsTest.java @@ -50,7 +50,8 @@ import com.google.devtools.build.skyframe.SkyFunctionException; import com.google.devtools.build.skyframe.SkyFunctionName; import com.google.devtools.build.skyframe.SkyKey; import com.google.devtools.build.skyframe.SkyValue; -import java.util.Collection; +import java.util.List; + import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -209,12 +210,12 @@ public class ConfigurationsForTargetsTest extends AnalysisTestCase { * * <p>Throws an exception if the attribute can't be found. */ - private Collection<ConfiguredTarget> getConfiguredDeps(String targetLabel, String attrName) + private List<ConfiguredTarget> getConfiguredDeps(String targetLabel, String attrName) throws Exception { Multimap<Attribute, ConfiguredTarget> allDeps = getConfiguredDeps(targetLabel); for (Attribute attribute : allDeps.keySet()) { if (attribute.getName().equals(attrName)) { - return allDeps.get(attribute); + return ImmutableList.copyOf(allDeps.get(attribute)); } } throw new AssertionError( @@ -261,6 +262,47 @@ public class ConfigurationsForTargetsTest extends AnalysisTestCase { assertThat(genIn.getConfiguration()).isNull(); } + @Test + public void targetDeps() throws Exception { + scratch.file( + "a/BUILD", + "cc_library(name = 'dep1', srcs = ['dep1.cc'])", + "cc_library(name = 'dep2', srcs = ['dep2.cc'])", + "cc_binary(name = 'binary', srcs = ['main.cc'], deps = [':dep1', ':dep2'])"); + List<ConfiguredTarget> deps = getConfiguredDeps("//a:binary", "deps"); + assertThat(deps).hasSize(2); + for (ConfiguredTarget dep : deps) { + assertThat(getTargetConfiguration().equalsOrIsSupersetOf(dep.getConfiguration())).isTrue(); + } + } + + @Test + public void hostDeps() throws Exception { + scratch.file( + "a/BUILD", + "cc_binary(name = 'host_tool', srcs = ['host_tool.cc'])", + "genrule(name = 'gen', srcs = [], cmd = '', outs = ['gen.out'], tools = [':host_tool'])"); + ConfiguredTarget toolDep = Iterables.getOnlyElement(getConfiguredDeps("//a:gen", "tools")); + assertThat(toolDep.getConfiguration().isHostConfiguration()).isTrue(); + } + + @Test + public void splitDeps() throws Exception { + scratch.file( + "java/a/BUILD", + "cc_library(name = 'lib', srcs = ['lib.cc'])", + "android_binary(name='a', manifest = 'mainfest.xml', deps = [':lib'])"); + useConfiguration("--fat_apk_cpu=k8,armeabi-v7a"); + List<ConfiguredTarget> deps = getConfiguredDeps("//java/a:a", "deps"); + assertThat(deps).hasSize(2); + assertThat( + ImmutableList.<String>of( + deps.get(0).getConfiguration().getCpu(), + deps.get(1).getConfiguration().getCpu())) + .containsExactly("armeabi-v7a", "k8") + .inOrder(); // We don't care what order split deps are listed, but it must be deterministic. + } + /** Runs the same test with trimmed dynamic configurations. */ @TestSpec(size = Suite.SMALL_TESTS) @RunWith(JUnit4.class) |