From 22d05ebc9f4ce3194233e7dfd12bf079ce88ee07 Mon Sep 17 00:00:00 2001 From: ajmichael Date: Wed, 31 May 2017 22:34:34 +0200 Subject: Add //external:has_androidsdk config_setting. This will be used to add some tests and targets to the Bazel codebase that build and run successfully when android_sdk_repository is in the WORKSPACE and silently skip if it is not. Example deps of a library that links against dx.jar: ``` deps = select({ "//external:has_androidsdk": ["//external:android/dx_jar_import"], "//conditions:default": [], }), ``` Also adds tests that config_setting works as expected when propagated through an alias or bind rule. RELNOTES: None PiperOrigin-RevId: 157627472 --- .../analysis/ConfiguredAttributeMapperTest.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/test/java/com/google/devtools/build/lib/analysis') diff --git a/src/test/java/com/google/devtools/build/lib/analysis/ConfiguredAttributeMapperTest.java b/src/test/java/com/google/devtools/build/lib/analysis/ConfiguredAttributeMapperTest.java index bff9d57b0e..72bef74866 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/ConfiguredAttributeMapperTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/ConfiguredAttributeMapperTest.java @@ -265,4 +265,26 @@ public class ConfiguredAttributeMapperTest extends BuildViewTestCase { assertThat(getMapper("//a:lib").isAttributeValueExplicitlySpecified("linkstamp")).isFalse(); assertThat(getMapper("//a:lib").get("linkstamp", BuildType.LABEL)).isNull(); } + + @Test + public void testAliasedConfigSetting() throws Exception { + writeConfigRules(); + scratch.file( + "a/BUILD", + "alias(", + " name = 'aliased_a',", + " actual = '//conditions:a',", + ")", + "genrule(", + " name = 'gen',", + " srcs = [],", + " outs = ['out'],", + " cmd = '',", + " message = select({", + " ':aliased_a': 'defined message',", + " '//conditions:default': None,", + " }))"); + useConfiguration("--define", "mode=a"); + assertThat(getMapper("//a:gen").get("message", Type.STRING)).isEqualTo("defined message"); + } } -- cgit v1.2.3