From 95f9b8129d1b877523359ca26539cb254ae5a8d7 Mon Sep 17 00:00:00 2001 From: Damien Martin-Guillerez Date: Tue, 6 Dec 2016 20:41:47 +0000 Subject: Rollback of commit 12d766df10fbc5eba16ec1e6c20c8cd85f9c616f. *** Reason for rollback *** Still fails bazel-tests See http://ci.bazel.io/job/bazel-tests/BAZEL_VERSION=HEAD,PLATFORM_NAME=ubuntu_15.10-x86_64/lastCompletedBuild/testReport/ for instance *** Original change description *** 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: 141212457 MOS_MIGRATED_REVID=141212457 --- .../lib/skyframe/ConfigurationsForTargetsTest.java | 48 ++-------------------- 1 file changed, 3 insertions(+), 45 deletions(-) (limited to 'src/test/java/com/google/devtools/build/lib/skyframe/ConfigurationsForTargetsTest.java') 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 64e54d92f0..e6bfebc8ac 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,8 +50,7 @@ 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.List; - +import java.util.Collection; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -210,12 +209,12 @@ public class ConfigurationsForTargetsTest extends AnalysisTestCase { * *

Throws an exception if the attribute can't be found. */ - private List getConfiguredDeps(String targetLabel, String attrName) + private Collection getConfiguredDeps(String targetLabel, String attrName) throws Exception { Multimap allDeps = getConfiguredDeps(targetLabel); for (Attribute attribute : allDeps.keySet()) { if (attribute.getName().equals(attrName)) { - return ImmutableList.copyOf(allDeps.get(attribute)); + return allDeps.get(attribute); } } throw new AssertionError( @@ -262,47 +261,6 @@ 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 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 deps = getConfiguredDeps("//java/a:a", "deps"); - assertThat(deps).hasSize(2); - assertThat( - ImmutableList.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) -- cgit v1.2.3