aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/test/java/com/google/devtools/build/lib/BUILD57
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/apple/BUILD2
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/apple/XcodeConfigTest.java716
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/apple/XcodeVersionTest.java105
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/cpp/BUILD72
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/cpp/LinkBuildVariablesTest.java73
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/cpp/LinkBuildVariablesTestCase.java110
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/objc/BUILD8
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/objc/ObjcBuildVariablesTest.java247
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoAspectTest.java3
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoLibraryTest.java42
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoProviderTest.java3
12 files changed, 1281 insertions, 157 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/BUILD b/src/test/java/com/google/devtools/build/lib/BUILD
index e16db89f2e..df4393214f 100644
--- a/src/test/java/com/google/devtools/build/lib/BUILD
+++ b/src/test/java/com/google/devtools/build/lib/BUILD
@@ -49,6 +49,7 @@ filegroup(
"//src/test/java/com/google/devtools/build/lib/rules/android:srcs",
"//src/test/java/com/google/devtools/build/lib/rules/apple:srcs",
"//src/test/java/com/google/devtools/build/lib/rules/config:srcs",
+ "//src/test/java/com/google/devtools/build/lib/rules/cpp:srcs",
"//src/test/java/com/google/devtools/build/lib/rules/objc:srcs",
"//src/test/java/com/google/devtools/build/lib/rules/platform:srcs",
"//src/test/java/com/google/devtools/build/lib/rules/repository:srcs",
@@ -957,62 +958,6 @@ java_test(
)
java_test(
- name = "cpp-rules-tests",
- srcs = glob(["rules/cpp/*.java"]),
- tags = ["rules"],
- test_class = "com.google.devtools.build.lib.AllTests",
- deps = [
- ":actions_testutil",
- ":analysis_testutil",
- ":testutil",
- "//src/main/java/com/google/devtools/build/lib:bazel-main",
- "//src/main/java/com/google/devtools/build/lib:bazel-rules",
- "//src/main/java/com/google/devtools/build/lib:build-base",
- "//src/main/java/com/google/devtools/build/lib:core-rules",
- "//src/main/java/com/google/devtools/build/lib:io",
- "//src/main/java/com/google/devtools/build/lib:packages-internal",
- "//src/main/java/com/google/devtools/build/lib:util",
- "//src/main/java/com/google/devtools/build/lib/actions",
- "//src/main/java/com/google/devtools/build/lib/analysis/platform",
- "//src/main/java/com/google/devtools/build/lib/cmdline",
- "//src/main/java/com/google/devtools/build/lib/collect/nestedset",
- "//src/main/java/com/google/devtools/build/lib/concurrent",
- "//src/main/java/com/google/devtools/build/lib/rules/cpp",
- "//src/main/java/com/google/devtools/build/lib/vfs",
- "//src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs",
- "//src/main/java/com/google/devtools/common/options",
- "//src/main/java/com/google/devtools/common/options:invocation_policy",
- "//src/main/protobuf:crosstool_config_java_proto",
- "//src/main/protobuf:extra_actions_base_java_proto",
- "//src/test/java/com/google/devtools/build/lib:packages_testutil",
- "//third_party:guava",
- "//third_party:guava-testlib",
- "//third_party:jsr305",
- "//third_party:junit4",
- "//third_party:truth",
- "//third_party/protobuf:protobuf_java",
- ],
-)
-
-java_test(
- name = "CcProtoLibraryTest",
- srcs = glob(["rules/cpp/proto/CcProtoLibraryTest.java"]),
- tags = ["rules"],
- deps = [
- ":actions_testutil",
- ":analysis_testutil",
- "//src/main/java/com/google/devtools/build/lib:build-base",
- "//src/main/java/com/google/devtools/build/lib/actions",
- "//src/main/java/com/google/devtools/build/lib/rules/cpp",
- "//src/main/java/com/google/devtools/build/lib/rules/cpp/proto:ProtoCcHeaderProvider",
- "//src/main/java/com/google/devtools/build/lib/vfs",
- "//third_party:guava",
- "//third_party:junit4",
- "//third_party:truth",
- ],
-)
-
-java_test(
name = "test-rules-tests",
srcs = ["rules/test/SkylarkTestingModuleTest.java"],
tags = ["rules"],
diff --git a/src/test/java/com/google/devtools/build/lib/rules/apple/BUILD b/src/test/java/com/google/devtools/build/lib/rules/apple/BUILD
index 1753c230b7..73c02b132b 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/apple/BUILD
+++ b/src/test/java/com/google/devtools/build/lib/rules/apple/BUILD
@@ -46,6 +46,8 @@ java_library(
),
deps = [
"//src/main/java/com/google/devtools/build/lib:build-base",
+ "//src/main/java/com/google/devtools/build/lib:packages-internal",
+ "//src/main/java/com/google/devtools/build/lib:syntax",
"//src/main/java/com/google/devtools/build/lib/rules/apple",
"//src/test/java/com/google/devtools/build/lib:analysis_testutil",
"//third_party:guava",
diff --git a/src/test/java/com/google/devtools/build/lib/rules/apple/XcodeConfigTest.java b/src/test/java/com/google/devtools/build/lib/rules/apple/XcodeConfigTest.java
new file mode 100644
index 0000000000..93c1dabfc5
--- /dev/null
+++ b/src/test/java/com/google/devtools/build/lib/rules/apple/XcodeConfigTest.java
@@ -0,0 +1,716 @@
+// Copyright 2017 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.rules.apple;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.devtools.build.lib.analysis.ConfiguredTarget;
+import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget;
+import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
+import com.google.devtools.build.lib.packages.ConfiguredAttributeMapper;
+import com.google.devtools.build.lib.syntax.Type;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Unit tests for the {@code xcode_config} rule.
+ */
+@RunWith(JUnit4.class)
+public class XcodeConfigTest extends BuildViewTestCase {
+
+ @Test
+ public void testEmptyConfig_noVersionFlag() throws Exception {
+ scratch.file("xcode/BUILD",
+ "xcode_config(name = 'foo',)");
+ useConfiguration("--xcode_version_config=//xcode:foo");
+
+ assertIosSdkVersion(AppleCommandLineOptions.DEFAULT_IOS_SDK_VERSION);
+ }
+
+ @Test
+ public void testDefaultVersion() throws Exception {
+ scratch.file("xcode/BUILD",
+ "xcode_config(",
+ " name = 'foo',",
+ " default = ':version512',",
+ " versions = [':version512', ':version64'],",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version512',",
+ " version = '5.1.2',",
+ " aliases = ['5', '5.1'],",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version64',",
+ " version = '6.4',",
+ " aliases = ['6.0', 'foo', '6'],",
+ ")");
+ useConfiguration("--xcode_version_config=//xcode:foo");
+
+ assertXcodeVersion("5.1.2");
+ }
+
+ @Test
+ public void testConfigAlias_configSetting() throws Exception {
+ scratch.file("skylark/BUILD");
+ scratch.file("skylark/version_retriever.bzl",
+ "def _version_retriever_impl(ctx):",
+ " xcode_properties = ctx.attr.dep[apple_common.XcodeProperties]",
+ " version = xcode_properties.xcode_version",
+ " return struct(providers = [config_common.FeatureFlagInfo(value=version)])",
+ "",
+ "version_retriever = rule(",
+ " implementation = _version_retriever_impl,",
+ " attrs = {'dep': attr.label()},",
+ ")");
+
+ scratch.file("xcode/BUILD",
+ "load('//skylark:version_retriever.bzl', 'version_retriever')",
+ "version_retriever(",
+ " name = 'flag_propagator',",
+ " dep = ':alias',",
+ ")",
+ "",
+ "xcode_config(",
+ " name = 'config',",
+ " default = ':version512',",
+ " versions = [':version512', ':version64', ':version12'],",
+ ")",
+ "",
+ "xcode_config_alias(",
+ " name = 'alias'",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version512',",
+ " version = '5.1.2',",
+ " aliases = ['5', '5.1'],",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version64',",
+ " version = '6.4',",
+ " aliases = ['6.0', 'six', '6'],",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version12',",
+ " version = '12',",
+ ")",
+ "config_setting(name = 'xcode_5_1_2',",
+ " flag_values = {':flag_propagator': '5.1.2'})",
+ "config_setting(name = 'xcode_6_4',",
+ " flag_values = {':flag_propagator': '6.4'})",
+ "genrule(",
+ " name = 'gen',",
+ " srcs = [],",
+ " outs = ['out'],",
+ " cmd = select({",
+ " ':xcode_5_1_2': '5.1.2',",
+ " ':xcode_6_4': '6.4',",
+ " '//conditions:default': 'none'",
+ " }))");
+
+ useConfiguration("--xcode_version_config=//xcode:config");
+ assertThat(getMapper("//xcode:gen").get("cmd", Type.STRING)).isEqualTo("5.1.2");
+
+ useConfiguration("--xcode_version_config=//xcode:config", "--xcode_version=6.4");
+ assertThat(getMapper("//xcode:gen").get("cmd", Type.STRING)).isEqualTo("6.4");
+
+ useConfiguration("--xcode_version_config=//xcode:config", "--xcode_version=6");
+ assertThat(getMapper("//xcode:gen").get("cmd", Type.STRING)).isEqualTo("6.4");
+
+ useConfiguration("--xcode_version_config=//xcode:config", "--xcode_version=12");
+ assertThat(getMapper("//xcode:gen").get("cmd", Type.STRING)).isEqualTo("none");
+ }
+
+ @Test
+ public void testDefaultVersion_configSetting() throws Exception {
+ scratch.file("skylark/BUILD");
+ scratch.file("skylark/version_retriever.bzl",
+ "def _version_retriever_impl(ctx):",
+ " xcode_properties = ctx.attr.dep[apple_common.XcodeProperties]",
+ " version = xcode_properties.xcode_version",
+ " return struct(providers = [config_common.FeatureFlagInfo(value=version)])",
+ "",
+ "version_retriever = rule(",
+ " implementation = _version_retriever_impl,",
+ " attrs = {'dep': attr.label()},",
+ ")");
+
+ scratch.file("xcode/BUILD",
+ "load('//skylark:version_retriever.bzl', 'version_retriever')",
+ "version_retriever(",
+ " name = 'flag_propagator',",
+ " dep = ':alias',",
+ ")",
+ "xcode_config_alias(",
+ " name = 'alias'",
+ ")",
+ "xcode_config(",
+ " name = 'foo',",
+ " default = ':version512',",
+ " versions = [':version512', ':version64'],",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version512',",
+ " version = '5.1.2',",
+ " aliases = ['5', '5.1'],",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version64',",
+ " version = '6.4',",
+ " aliases = ['6.0', 'foo', '6'],",
+ ")",
+ "config_setting(name = 'xcode_5_1_2',",
+ " flag_values = {':flag_propagator': '5.1.2'})",
+ "config_setting(name = 'xcode_6_4',",
+ " flag_values = {':flag_propagator': '6.4'})",
+ "genrule(",
+ " name = 'gen',",
+ " srcs = [],",
+ " outs = ['out'],",
+ " cmd = select({",
+ " ':xcode_5_1_2': '5.1.2',",
+ " ':xcode_6_4': '6.4',",
+ " '//conditions:default': 'none'",
+ " }))");
+
+ useConfiguration("--xcode_version_config=//xcode:foo");
+ assertThat(getMapper("//xcode:gen").get("cmd", Type.STRING)).isEqualTo("5.1.2");
+
+ useConfiguration("--xcode_version_config=//xcode:foo", "--xcode_version=6.4");
+ assertThat(getMapper("//xcode:gen").get("cmd", Type.STRING)).isEqualTo("6.4");
+ }
+
+ @Test
+ public void testRequiresDefined_validVersion() throws Exception {
+ scratch.file("xcode/BUILD",
+ "xcode_config(",
+ " name = 'foo',",
+ " require_defined_version = 1,",
+ " versions = [':version512'],",
+ " default = ':version512',",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version512',",
+ " version = '5.1.2',",
+ " aliases = ['5', '5.1'],",
+ ")");
+ useConfiguration("--xcode_version=5.1.2", "--xcode_version_config=//xcode:foo");
+
+ assertXcodeVersion("5.1.2");
+ }
+
+ @Test
+ public void testRequiresDefined_validAlias_dottedVersion() throws Exception {
+ scratch.file("xcode/BUILD",
+ "xcode_config(",
+ " name = 'foo',",
+ " require_defined_version = 1,",
+ " versions = [':version512'],",
+ " default = ':version512',",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version512',",
+ " version = '5.1.2',",
+ " aliases = ['5', '5.1'],",
+ ")");
+ useConfiguration("--xcode_version=5", "--xcode_version_config=//xcode:foo");
+
+ assertXcodeVersion("5.1.2");
+ }
+
+ @Test
+ public void testRequiresDefined_validAlias_nonNumerical() throws Exception {
+ scratch.file("xcode/BUILD",
+ "xcode_config(",
+ " name = 'foo',",
+ " require_defined_version = 1,",
+ " versions = [':version512'],",
+ " default = ':version512',",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version512',",
+ " version = '5.1.2',",
+ " aliases = ['valid_version'],",
+ ")");
+ useConfiguration("--xcode_version=valid_version", "--xcode_version_config=//xcode:foo");
+
+ assertXcodeVersion("5.1.2");
+ }
+
+ @Test
+ public void testRequiresDefined_validDefault() throws Exception {
+ scratch.file("xcode/BUILD",
+ "xcode_config(",
+ " name = 'foo',",
+ " default = ':version512',",
+ " versions = [':version512'],",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version512',",
+ " version = '5.1.2',",
+ " aliases = ['5', '5.1'],",
+ ")");
+ useConfiguration("--xcode_version_config=//xcode:foo");
+
+ assertXcodeVersion("5.1.2");
+ }
+
+ @Test
+ public void testInvalidXcodeSpecified() throws Exception {
+ scratch.file("xcode/BUILD",
+ "xcode_config(",
+ " name = 'foo',",
+ " require_defined_version = 1,",
+ " versions = [':version512'],",
+ " default = ':version512',",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version512',",
+ " version = '5.1.2',",
+ " aliases = ['5', '5.1'],",
+ ")");
+ useConfiguration("--xcode_version=6");
+ reporter.removeHandler(failFastHandler);
+ getConfiguredTarget("//xcode:foo");
+ assertContainsEvent("6 matches no alias in the config");
+ }
+
+ @Test
+ public void testRequiresDefault() throws Exception {
+ scratch.file("xcode/BUILD",
+ "xcode_config(",
+ " name = 'foo',",
+ " require_defined_version = 1,",
+ " versions = [':version512'],",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version512',",
+ " version = '5.1.2',",
+ " aliases = ['5', '5.1'],",
+ ")");
+ reporter.removeHandler(failFastHandler);
+ getConfiguredTarget("//xcode:foo");
+ assertContainsEvent("default version must be specified");
+ }
+
+ @Test
+ public void testDuplicateAliases_definedVersion() throws Exception {
+ scratch.file("xcode/BUILD",
+ "xcode_config(",
+ " name = 'foo',",
+ " versions = [':version512', ':version5'],",
+ " default = ':version512'",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version512',",
+ " version = '5.1.2',",
+ " aliases = ['5', '5.1'],",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version5',",
+ " version = '5',",
+ " aliases = ['5', '5.0', 'foo'],",
+ ")");
+ reporter.removeHandler(failFastHandler);
+ getConfiguredTarget("//xcode:foo");
+ assertContainsEvent(
+ "'5' is registered to multiple labels (//xcode:version512, //xcode:version5)");
+ }
+
+ @Test
+ public void testVersionAliasedToItself() throws Exception {
+ scratch.file("xcode/BUILD",
+ "xcode_config(",
+ " name = 'foo',",
+ " versions = [':version512'],",
+ " default = ':version512',",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version512',",
+ " version = '5.1.2',",
+ " aliases = ['5', '5.1', '5.1.2'],",
+ ")");
+ useConfiguration("--xcode_version_config=//xcode:foo");
+
+ assertXcodeVersion("5.1.2");
+ }
+
+ @Test
+ public void testDuplicateVersionNumbers() throws Exception {
+ scratch.file("xcode/BUILD",
+ "xcode_config(",
+ " name = 'foo',",
+ " versions = [':version512', ':version5'],",
+ " default = ':version512',",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version512',",
+ " version = '5.1.2',",
+ " aliases = ['5', '5.1'],",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version5',",
+ " version = '5.1.2',",
+ " aliases = ['foo'],",
+ ")");
+ useConfiguration("--xcode_version=5");
+ reporter.removeHandler(failFastHandler);
+ getConfiguredTarget("//xcode:foo");
+ assertContainsEvent(
+ "'5.1.2' is registered to multiple labels (//xcode:version512, //xcode:version5)");
+ }
+
+ @Test
+ public void testVersionConflictsWithAlias() throws Exception {
+ scratch.file("xcode/BUILD",
+ "xcode_config(",
+ " name = 'foo',",
+ " versions = [':version512', ':version5'],",
+ " default = ':version512',",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version512',",
+ " version = '5',",
+ " aliases = ['5.1'],",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version5',",
+ " version = '5.1.3',",
+ " aliases = ['5'],",
+ ")");
+
+ reporter.removeHandler(failFastHandler);
+ getConfiguredTarget("//xcode:foo");
+ assertContainsEvent(
+ "'5' is registered to multiple labels (//xcode:version512, //xcode:version5)");
+ }
+
+ @Test
+ public void testDefaultIosSdkVersion() throws Exception {
+ scratch.file("xcode/BUILD",
+ "xcode_config(",
+ " name = 'foo',",
+ " default = ':version512',",
+ " versions = [':version512', ':version64'],",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version512',",
+ " version = '5.1.2',",
+ " aliases = ['5', '5.1'],",
+ " default_ios_sdk_version = '7.1'",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version64',",
+ " version = '6.4',",
+ " aliases = ['6.0', 'foo', '6'],",
+ " default_ios_sdk_version = '43.0'",
+ ")");
+ useConfiguration("--xcode_version_config=//xcode:foo");
+
+ assertXcodeVersion("5.1.2");
+ assertIosSdkVersion("7.1");
+ }
+
+ @Test
+ public void testDefaultSdkVersions() throws Exception {
+ scratch.file("xcode/BUILD",
+ "xcode_config(",
+ " name = 'foo',",
+ " default = ':version512',",
+ " versions = [':version512', ':version64'],",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version512',",
+ " version = '5.1.2',",
+ " aliases = ['5', '5.1'],",
+ " default_ios_sdk_version = '101',",
+ " default_watchos_sdk_version = '102',",
+ " default_tvos_sdk_version = '103',",
+ " default_macos_sdk_version = '104',",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version64',",
+ " version = '6.4',",
+ " aliases = ['6.0', 'foo', '6'],",
+ " default_ios_sdk_version = '43.0'",
+ ")");
+ useConfiguration("--xcode_version_config=//xcode:foo");
+
+ assertXcodeVersion("5.1.2");
+ ImmutableMap<ApplePlatform, String> platformToVersion =
+ ImmutableMap.<ApplePlatform, String>builder()
+ .put(ApplePlatform.IOS_SIMULATOR, "101")
+ .put(ApplePlatform.WATCHOS_SIMULATOR, "102")
+ .put(ApplePlatform.TVOS_SIMULATOR, "103")
+ .put(ApplePlatform.MACOS, "104")
+ .build();
+ for (ApplePlatform platform : platformToVersion.keySet()) {
+ DottedVersion version = DottedVersion.fromString(platformToVersion.get(platform));
+ assertThat(getSdkVersionForPlatform(platform)).isEqualTo(version);
+ assertThat(getMinimumOsVersionForPlatform(platform)).isEqualTo(version);
+ }
+ }
+
+ @Test
+ public void testDefaultSdkVersions_selectedXcode() throws Exception {
+ scratch.file("xcode/BUILD",
+ "xcode_config(",
+ " name = 'foo',",
+ " default = ':version512',",
+ " versions = [':version512', ':version64'],",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version512',",
+ " version = '5.1.2',",
+ " aliases = ['5', '5.1'],",
+ " default_ios_sdk_version = '7.1'",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version64',",
+ " version = '6.4',",
+ " aliases = ['6.0', 'foo', '6'],",
+ " default_ios_sdk_version = '43',",
+ " default_watchos_sdk_version = '44',",
+ " default_tvos_sdk_version = '45',",
+ " default_macos_sdk_version = '46',",
+ ")");
+ useConfiguration("--xcode_version=6", "--xcode_version_config=//xcode:foo");
+
+ assertXcodeVersion("6.4");
+ ImmutableMap<ApplePlatform, String> platformToVersion =
+ ImmutableMap.<ApplePlatform, String>builder()
+ .put(ApplePlatform.IOS_SIMULATOR, "43")
+ .put(ApplePlatform.WATCHOS_SIMULATOR, "44")
+ .put(ApplePlatform.TVOS_SIMULATOR, "45")
+ .put(ApplePlatform.MACOS, "46")
+ .build();
+ for (ApplePlatform platform : platformToVersion.keySet()) {
+ DottedVersion version = DottedVersion.fromString(platformToVersion.get(platform));
+ assertThat(getSdkVersionForPlatform(platform)).isEqualTo(version);
+ assertThat(getMinimumOsVersionForPlatform(platform)).isEqualTo(version);
+ }
+ }
+
+ @Test
+ public void testOverrideDefaultSdkVersions() throws Exception {
+ scratch.file("xcode/BUILD",
+ "xcode_config(",
+ " name = 'foo',",
+ " default = ':version512',",
+ " versions = [':version512', ':version64'],",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version512',",
+ " version = '5.1.2',",
+ " aliases = ['5', '5.1'],",
+ " default_ios_sdk_version = '7.1'",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version64',",
+ " version = '6.4',",
+ " aliases = ['6.0', 'foo', '6'],",
+ " default_ios_sdk_version = '101',",
+ " default_watchos_sdk_version = '102',",
+ " default_tvos_sdk_version = '103',",
+ " default_macos_sdk_version = '104',",
+ ")");
+ useConfiguration("--xcode_version=6", "--xcode_version_config=//xcode:foo",
+ "--ios_sdk_version=15.3", "--watchos_sdk_version=15.4",
+ "--tvos_sdk_version=15.5", "--macos_sdk_version=15.6");
+
+ assertXcodeVersion("6.4");
+ ImmutableMap<ApplePlatform, String> platformToVersion =
+ ImmutableMap.<ApplePlatform, String>builder()
+ .put(ApplePlatform.IOS_SIMULATOR, "15.3")
+ .put(ApplePlatform.WATCHOS_SIMULATOR, "15.4")
+ .put(ApplePlatform.TVOS_SIMULATOR, "15.5")
+ .put(ApplePlatform.MACOS, "15.6")
+ .build();
+ for (ApplePlatform platform : platformToVersion.keySet()) {
+ DottedVersion version = DottedVersion.fromString(platformToVersion.get(platform));
+ assertThat(getSdkVersionForPlatform(platform)).isEqualTo(version);
+ assertThat(getMinimumOsVersionForPlatform(platform)).isEqualTo(version);
+ }
+ }
+
+ @Test
+ public void testXcodeVersionFromSkylarkByAlias() throws Exception {
+ scratch.file("x/BUILD",
+ "load('//x:r.bzl', 'r')",
+ "xcode_config_alias(name='a')",
+ "xcode_config(name='c', default=':v', versions=[':v'])",
+ "xcode_version(",
+ " name = 'v',",
+ " version = '0.0',",
+ " default_ios_sdk_version = '1.0',",
+ " default_tvos_sdk_version = '2.0',",
+ " default_macos_sdk_version = '3.0',",
+ " default_watchos_sdk_version = '4.0',",
+ ")",
+ "r(name='r')");
+ scratch.file("x/r.bzl",
+ "def _impl(ctx):",
+ " conf = ctx.attr._xcode[apple_common.XcodeVersionConfig]",
+ " ios = ctx.fragments.apple.multi_arch_platform(apple_common.platform_type.ios)",
+ " tvos = ctx.fragments.apple.multi_arch_platform(apple_common.platform_type.tvos)",
+ " return struct(",
+ " xcode = conf.xcode_version(),",
+ " ios_sdk = conf.sdk_version_for_platform(ios),",
+ " tvos_sdk = conf.sdk_version_for_platform(tvos),",
+ " macos_min = conf.minimum_os_for_platform_type(apple_common.platform_type.macos),",
+ " watchos_min = conf.minimum_os_for_platform_type(apple_common.platform_type.watchos),",
+ " )",
+ "r = rule(implementation = _impl,",
+ " attrs = { '_xcode': attr.label(default = Label('//x:a'))},",
+ " fragments = ['apple'],",
+ ")");
+
+ useConfiguration(
+ "--xcode_version_config=//x:c",
+ "--tvos_sdk_version=2.5",
+ "--watchos_minimum_os=4.5");
+ ConfiguredTarget r = getConfiguredTarget("//x:r");
+ assertThat(r.get("xcode").toString()).isEqualTo("0.0");
+ assertThat(r.get("ios_sdk").toString()).isEqualTo("1.0");
+ assertThat(r.get("tvos_sdk").toString()).isEqualTo("2.5");
+ assertThat(r.get("macos_min").toString()).isEqualTo("3.0");
+ assertThat(r.get("watchos_min").toString()).isEqualTo("4.5");
+ }
+
+ @Test
+ public void testDefaultWithoutVersion() throws Exception {
+ scratch.file("xcode/BUILD",
+ "xcode_config(",
+ " name = 'foo',",
+ " default = ':version512',",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version512',",
+ " version = '5.1.2',",
+ " aliases = ['5', '5.1', '5.1.2'],",
+ ")");
+
+ reporter.removeHandler(failFastHandler);
+ getConfiguredTarget("//xcode:foo");
+ assertContainsEvent(
+ "default label '//xcode:version512' must be contained in versions attribute");
+ }
+
+ @Test
+ public void testVersionDoesNotContainDefault() throws Exception {
+ scratch.file("xcode/BUILD",
+ "xcode_config(",
+ " name = 'foo',",
+ " default = ':version512',",
+ " versions = [':version6'],",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version512',",
+ " version = '5.1.2',",
+ " aliases = ['5', '5.1', '5.1.2'],",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version6',",
+ " version = '6.0',",
+ ")");
+ reporter.removeHandler(failFastHandler);
+ getConfiguredTarget("//xcode:foo");
+ assertContainsEvent("must be contained in versions attribute");
+ }
+
+ @Test
+ public void testInvalidBitcodeVersion() throws Exception {
+ scratch.file("xcode/BUILD",
+ "xcode_config(",
+ " name = 'foo',",
+ " default = ':version512',",
+ " versions = [':version512'],",
+ ")",
+ "",
+ "xcode_version(",
+ " name = 'version512',",
+ " version = '5.1.2',",
+ ")");
+
+ useConfiguration("--apple_bitcode=embedded", "--apple_split_cpu=arm64");
+
+ reporter.removeHandler(failFastHandler);
+ getConfiguredTarget("//xcode:foo");
+ assertContainsEvent("apple_bitcode mode 'embedded' is unsupported");
+ }
+
+ private DottedVersion getSdkVersionForPlatform(ApplePlatform platform) throws Exception {
+ ConfiguredTarget xcodeConfig = getConfiguredTarget("//xcode:foo");
+ XcodeConfigProvider provider = xcodeConfig.get(XcodeConfigProvider.PROVIDER);
+ return provider.getSdkVersionForPlatform(platform);
+ }
+
+ private DottedVersion getMinimumOsVersionForPlatform(ApplePlatform platform) throws Exception {
+ ConfiguredTarget xcodeConfig = getConfiguredTarget("//xcode:foo");
+ XcodeConfigProvider provider = xcodeConfig.get(XcodeConfigProvider.PROVIDER);
+ return provider.getMinimumOsForPlatformType(platform.getType());
+ }
+
+ private void assertXcodeVersion(String version) throws Exception {
+ ConfiguredTarget xcodeConfig = getConfiguredTarget("//xcode:foo");
+ XcodeConfigProvider provider = xcodeConfig.get(XcodeConfigProvider.PROVIDER);
+ assertThat(provider.getXcodeVersion()).isEqualTo(DottedVersion.fromString(version));
+ }
+
+ private void assertIosSdkVersion(String version) throws Exception {
+ assertThat(getSdkVersionForPlatform(ApplePlatform.IOS_SIMULATOR))
+ .isEqualTo(DottedVersion.fromString(version));
+ }
+
+ /**
+ * Returns a ConfiguredAttributeMapper bound to the given rule with the target configuration.
+ */
+ private ConfiguredAttributeMapper getMapper(String label) throws Exception {
+ return ((RuleConfiguredTarget) getConfiguredTarget(label)).getAttributeMapper();
+ }
+}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/apple/XcodeVersionTest.java b/src/test/java/com/google/devtools/build/lib/rules/apple/XcodeVersionTest.java
new file mode 100644
index 0000000000..ce8a890a23
--- /dev/null
+++ b/src/test/java/com/google/devtools/build/lib/rules/apple/XcodeVersionTest.java
@@ -0,0 +1,105 @@
+// Copyright 2017 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.rules.apple;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import com.google.devtools.build.lib.analysis.ConfiguredTarget;
+import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget;
+import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Unit tests for the {@code xcode_version} rule.
+ */
+@RunWith(JUnit4.class)
+public final class XcodeVersionTest extends BuildViewTestCase {
+
+ @Test
+ public void testXcodeVersionCanBeReadFromSkylark() throws Exception {
+ scratch.file("examples/rule/BUILD");
+ scratch.file(
+ "examples/rule/apple_rules.bzl",
+ "def my_rule_impl(ctx):",
+ " xcode_properties = ctx.attr.xcode[apple_common.XcodeProperties]",
+ " xcode_version = xcode_properties.xcode_version",
+ " ios_version = xcode_properties.default_ios_sdk_version",
+ " watchos_version = xcode_properties.default_watchos_sdk_version",
+ " tvos_version = xcode_properties.default_tvos_sdk_version",
+ " macos_version = xcode_properties.default_macos_sdk_version",
+ " return struct(",
+ " xcode_version=xcode_version,",
+ " ios_version=ios_version,",
+ " watchos_version=watchos_version,",
+ " tvos_version=tvos_version,",
+ " macos_version=macos_version,",
+ " )",
+ "my_rule = rule(implementation = my_rule_impl,",
+ " attrs = {",
+ " 'xcode': attr.label(),",
+ " },",
+ ")");
+ scratch.file(
+ "examples/apple_skylark/BUILD",
+ "package(default_visibility = ['//visibility:public'])",
+ "load('/examples/rule/apple_rules', 'my_rule')",
+ "my_rule(",
+ " name = 'my_target',",
+ " xcode = ':my_xcode',",
+ ")",
+ "xcode_version(",
+ " name = 'my_xcode',",
+ " version = '8',",
+ " default_ios_sdk_version = '9.0',",
+ " default_watchos_sdk_version = '9.1',",
+ " default_tvos_sdk_version = '9.2',",
+ " default_macos_sdk_version = '9.3',",
+ ")");
+
+ RuleConfiguredTarget skylarkTarget =
+ (RuleConfiguredTarget) getConfiguredTarget("//examples/apple_skylark:my_target");
+ assertThat((String) skylarkTarget.get("xcode_version")).isEqualTo("8");
+ assertThat((String) skylarkTarget.get("ios_version")).isEqualTo("9.0");
+ assertThat((String) skylarkTarget.get("watchos_version")).isEqualTo("9.1");
+ assertThat((String) skylarkTarget.get("tvos_version")).isEqualTo("9.2");
+ assertThat((String) skylarkTarget.get("macos_version")).isEqualTo("9.3");
+ }
+
+ @Test
+ public void testXcodeVersionCanBeReadFromNative() throws Exception {
+ scratch.file(
+ "examples/apple/BUILD",
+ "package(default_visibility = ['//visibility:public'])",
+ "xcode_version(",
+ " name = 'my_xcode',",
+ " version = '8',",
+ " default_ios_sdk_version = '9.0',",
+ " default_watchos_sdk_version = '9.1',",
+ " default_tvos_sdk_version = '9.2',",
+ " default_macos_sdk_version = '9.3',",
+ ")");
+
+ ConfiguredTarget nativeTarget = getConfiguredTarget("//examples/apple:my_xcode");
+ XcodeVersionProperties xcodeProperties =
+ nativeTarget.get(XcodeVersionProperties.SKYLARK_CONSTRUCTOR);
+ assertThat(xcodeProperties.getXcodeVersion().get().toString()).isEqualTo("8");
+ assertThat(xcodeProperties.getDefaultIosSdkVersion().toString()).isEqualTo("9.0");
+ assertThat(xcodeProperties.getDefaultWatchosSdkVersion().toString()).isEqualTo("9.1");
+ assertThat(xcodeProperties.getDefaultTvosSdkVersion().toString()).isEqualTo("9.2");
+ assertThat(xcodeProperties.getDefaultMacosSdkVersion().toString()).isEqualTo("9.3");
+ }
+}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/BUILD b/src/test/java/com/google/devtools/build/lib/rules/cpp/BUILD
new file mode 100644
index 0000000000..891afc7ee7
--- /dev/null
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/BUILD
@@ -0,0 +1,72 @@
+package(
+ default_testonly = 1,
+ default_visibility = ["//src:__subpackages__"],
+)
+
+filegroup(
+ name = "srcs",
+ testonly = 0,
+ srcs = glob(["**"]),
+ visibility = ["//src/test/java/com/google/devtools/build/lib:__pkg__"],
+)
+
+java_test(
+ name = "cpp-rules-tests",
+ srcs = glob(["*.java"]) + ["proto/CcProtoLibraryTest.java"],
+ tags = ["rules"],
+ test_class = "com.google.devtools.build.lib.AllTests",
+ deps = [
+ "//src/main/java/com/google/devtools/build/lib:bazel-main",
+ "//src/main/java/com/google/devtools/build/lib:bazel-rules",
+ "//src/main/java/com/google/devtools/build/lib:build-base",
+ "//src/main/java/com/google/devtools/build/lib:core-rules",
+ "//src/main/java/com/google/devtools/build/lib:io",
+ "//src/main/java/com/google/devtools/build/lib:packages-internal",
+ "//src/main/java/com/google/devtools/build/lib:util",
+ "//src/main/java/com/google/devtools/build/lib/actions",
+ "//src/main/java/com/google/devtools/build/lib/analysis/platform",
+ "//src/main/java/com/google/devtools/build/lib/cmdline",
+ "//src/main/java/com/google/devtools/build/lib/collect/nestedset",
+ "//src/main/java/com/google/devtools/build/lib/concurrent",
+ "//src/main/java/com/google/devtools/build/lib/rules/cpp",
+ "//src/main/java/com/google/devtools/build/lib/vfs",
+ "//src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs",
+ "//src/main/java/com/google/devtools/common/options",
+ "//src/main/java/com/google/devtools/common/options:invocation_policy",
+ "//src/main/protobuf:crosstool_config_java_proto",
+ "//src/main/protobuf:extra_actions_base_java_proto",
+ "//src/test/java/com/google/devtools/build/lib:actions_testutil",
+ "//src/test/java/com/google/devtools/build/lib:analysis_testutil",
+ "//src/test/java/com/google/devtools/build/lib:packages_testutil",
+ "//src/test/java/com/google/devtools/build/lib:testutil",
+ "//third_party:guava",
+ "//third_party:guava-testlib",
+ "//third_party:jsr305",
+ "//third_party:junit4",
+ "//third_party:truth",
+ "//third_party/protobuf:protobuf_java",
+ ],
+)
+
+java_library(
+ name = "util",
+ srcs = [
+ "LinkBuildVariablesTestCase.java",
+ ],
+ deps = [
+ "//src/main/java/com/google/devtools/build/lib:build-base",
+ "//src/main/java/com/google/devtools/build/lib:util",
+ "//src/main/java/com/google/devtools/build/lib/actions",
+ "//src/main/java/com/google/devtools/build/lib/rules/cpp",
+ "//src/main/java/com/google/devtools/build/lib/vfs",
+ "//src/main/protobuf:crosstool_config_java_proto",
+ "//src/test/java/com/google/devtools/build/lib:analysis_testutil",
+ "//third_party:guava",
+ "//third_party:guava-testlib",
+ "//third_party:jsr305",
+ "//third_party:junit4",
+ "//third_party:truth",
+ "//third_party/java/dd_plist",
+ "//third_party/protobuf/3.4.0:protobuf_java",
+ ],
+)
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/LinkBuildVariablesTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/LinkBuildVariablesTest.java
index b772ea74ac..fea5b3d85b 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/LinkBuildVariablesTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/LinkBuildVariablesTest.java
@@ -16,13 +16,9 @@ package com.google.devtools.build.lib.rules.cpp;
import static com.google.common.truth.Truth.assertThat;
-import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
-import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.util.AnalysisMock;
-import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
-import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.FeatureConfiguration;
import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.Variables;
import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.Variables.LibraryToLinkValue;
import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.Variables.VariableValue;
@@ -35,74 +31,7 @@ import org.junit.runners.JUnit4;
/** Tests that {@code CppLinkAction} is populated with the correct build variables. */
@RunWith(JUnit4.class)
-public class LinkBuildVariablesTest extends BuildViewTestCase {
-
- private CppLinkAction getCppLinkAction(ConfiguredTarget target, Link.LinkTargetType type) {
- Artifact linkerOutput = null;
- switch (type) {
- case STATIC_LIBRARY:
- case ALWAYS_LINK_STATIC_LIBRARY:
- linkerOutput = getBinArtifact("lib" + target.getLabel().getName() + ".a", target);
- break;
- case PIC_STATIC_LIBRARY:
- case ALWAYS_LINK_PIC_STATIC_LIBRARY:
- linkerOutput = getBinArtifact("lib" + target.getLabel().getName() + "pic.a", target);
- break;
- case DYNAMIC_LIBRARY:
- linkerOutput = getBinArtifact("lib" + target.getLabel().getName() + ".so", target);
- break;
- case EXECUTABLE:
- linkerOutput = getExecutable(target);
- break;
- default:
- throw new IllegalArgumentException(
- String.format("Cannot get CppLinkAction for link type %s", type));
- }
- return (CppLinkAction) getGeneratingAction(linkerOutput);
- }
-
- /** Returns active build variables for a link action of given type for given target. */
- protected Variables getLinkBuildVariables(ConfiguredTarget target, Link.LinkTargetType type) {
- return getCppLinkAction(target, type).getLinkCommandLine().getBuildVariables();
- }
-
- /** Returns the value of a given sequence variable in context of the given Variables instance. */
- protected List<String> getSequenceVariableValue(Variables variables, String variable)
- throws Exception {
- FeatureConfiguration mockFeatureConfiguration =
- CcToolchainFeaturesTest.buildFeatures(
- "feature {",
- " name: 'a'",
- " flag_set {",
- " action: 'foo'",
- " flag_group {",
- " iterate_over: '" + variable + "'",
- " flag: '%{" + variable + "}'",
- " }",
- " }",
- "}")
- .getFeatureConfiguration(
- FeatureSpecification.create(ImmutableSet.of("a"), ImmutableSet.<String>of()));
- return mockFeatureConfiguration.getCommandLine("foo", variables);
- }
-
- /** Returns the value of a given string variable in context of the given Variables instance. */
- protected String getVariableValue(Variables variables, String variable) throws Exception {
- FeatureConfiguration mockFeatureConfiguration =
- CcToolchainFeaturesTest.buildFeatures(
- "feature {",
- " name: 'a'",
- " flag_set {",
- " action: 'foo'",
- " flag_group {",
- " flag: '%{" + variable + "}'",
- " }",
- " }",
- "}")
- .getFeatureConfiguration(
- FeatureSpecification.create(ImmutableSet.of("a"), ImmutableSet.<String>of()));
- return Iterables.getOnlyElement(mockFeatureConfiguration.getCommandLine("foo", variables));
- }
+public class LinkBuildVariablesTest extends LinkBuildVariablesTestCase {
@Test
public void testLinkstampBuildVariable() throws Exception {
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/LinkBuildVariablesTestCase.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/LinkBuildVariablesTestCase.java
new file mode 100644
index 0000000000..1cbb47921c
--- /dev/null
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/LinkBuildVariablesTestCase.java
@@ -0,0 +1,110 @@
+// Copyright 2017 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.rules.cpp;
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.devtools.build.lib.actions.Artifact;
+import com.google.devtools.build.lib.analysis.ConfiguredTarget;
+import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
+import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.FeatureConfiguration;
+import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.Variables;
+import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CToolchain;
+import com.google.protobuf.TextFormat;
+import java.util.List;
+
+/**
+ * Common test code to test that {@code CppLinkAction} is populated with the correct build
+ * variables.
+ **/
+public class LinkBuildVariablesTestCase extends BuildViewTestCase {
+
+ private CppLinkAction getCppLinkAction(ConfiguredTarget target, Link.LinkTargetType type) {
+ Artifact linkerOutput = null;
+ switch (type) {
+ case STATIC_LIBRARY:
+ case ALWAYS_LINK_STATIC_LIBRARY:
+ linkerOutput = getBinArtifact("lib" + target.getLabel().getName() + ".a", target);
+ break;
+ case PIC_STATIC_LIBRARY:
+ case ALWAYS_LINK_PIC_STATIC_LIBRARY:
+ linkerOutput = getBinArtifact("lib" + target.getLabel().getName() + "pic.a", target);
+ break;
+ case DYNAMIC_LIBRARY:
+ linkerOutput = getBinArtifact("lib" + target.getLabel().getName() + ".so", target);
+ break;
+ case EXECUTABLE:
+ linkerOutput = getExecutable(target);
+ break;
+ default:
+ throw new IllegalArgumentException(
+ String.format("Cannot get CppLinkAction for link type %s", type));
+ }
+ return (CppLinkAction) getGeneratingAction(linkerOutput);
+ }
+
+ /** Returns active build variables for a link action of given type for given target. */
+ protected Variables getLinkBuildVariables(ConfiguredTarget target, Link.LinkTargetType type) {
+ return getCppLinkAction(target, type).getLinkCommandLine().getBuildVariables();
+ }
+
+ /**
+ * Creates a CcToolchainFeatures from features described in the given toolchain fragment.
+ */
+ public static CcToolchainFeatures buildFeatures(String... toolchain) throws Exception {
+ CToolchain.Builder toolchainBuilder = CToolchain.newBuilder();
+ TextFormat.merge(Joiner.on("").join(toolchain), toolchainBuilder);
+ return new CcToolchainFeatures(toolchainBuilder.buildPartial());
+ }
+
+ /** Returns the value of a given sequence variable in context of the given Variables instance. */
+ protected List<String> getSequenceVariableValue(Variables variables, String variable)
+ throws Exception {
+ FeatureConfiguration mockFeatureConfiguration =
+ buildFeatures(
+ "feature {",
+ " name: 'a'",
+ " flag_set {",
+ " action: 'foo'",
+ " flag_group {",
+ " iterate_over: '" + variable + "'",
+ " flag: '%{" + variable + "}'",
+ " }",
+ " }",
+ "}")
+ .getFeatureConfiguration(
+ FeatureSpecification.create(ImmutableSet.of("a"), ImmutableSet.<String>of()));
+ return mockFeatureConfiguration.getCommandLine("foo", variables);
+ }
+
+ /** Returns the value of a given string variable in context of the given Variables instance. */
+ protected String getVariableValue(Variables variables, String variable) throws Exception {
+ FeatureConfiguration mockFeatureConfiguration =
+ buildFeatures(
+ "feature {",
+ " name: 'a'",
+ " flag_set {",
+ " action: 'foo'",
+ " flag_group {",
+ " flag: '%{" + variable + "}'",
+ " }",
+ " }",
+ "}")
+ .getFeatureConfiguration(
+ FeatureSpecification.create(ImmutableSet.of("a"), ImmutableSet.<String>of()));
+ return Iterables.getOnlyElement(mockFeatureConfiguration.getCommandLine("foo", variables));
+ }
+}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/BUILD b/src/test/java/com/google/devtools/build/lib/rules/objc/BUILD
index 84534ff782..5c8bbec4a1 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/BUILD
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/BUILD
@@ -13,7 +13,8 @@ filegroup(
java_library(
name = "ObjcRulesTests_lib",
srcs = [
- # TODO(b/64531582): Finish fixing all test files in this directory.
+ # TODO(b/64531582): Use glob for all files in this directory once
+ # legacy tests are removed.
"AppleBinaryTest.java",
"AppleDynamicLibraryTest.java",
"AppleStaticLibraryTest.java",
@@ -36,9 +37,12 @@ java_library(
"LegacyObjcImportTest.java",
"LegacyObjcLibraryTest.java",
"LegacyTest.java",
+ "ObjcBuildVariablesTest.java",
"ObjcBundleLibraryTest.java",
"ObjcBundleTest.java",
"ObjcFrameworkTest.java",
+ "ObjcProtoAspectTest.java",
+ "ObjcProtoLibraryTest.java",
"ObjcImportTest.java",
"ObjcLibraryTest.java",
"ObjcProviderTest.java",
@@ -57,6 +61,7 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/cmdline",
"//src/main/java/com/google/devtools/build/lib/collect/nestedset",
"//src/main/java/com/google/devtools/build/lib/rules/apple",
+ "//src/main/java/com/google/devtools/build/lib/rules/apple/cpp",
"//src/main/java/com/google/devtools/build/lib/rules/cpp",
"//src/main/java/com/google/devtools/build/lib/rules/objc",
"//src/main/java/com/google/devtools/build/lib/vfs",
@@ -67,6 +72,7 @@ java_library(
"//src/test/java/com/google/devtools/build/lib:analysis_testutil",
"//src/test/java/com/google/devtools/build/lib:packages_testutil",
"//src/test/java/com/google/devtools/build/lib:testutil",
+ "//src/test/java/com/google/devtools/build/lib/rules/cpp:util",
"//third_party:guava",
"//third_party:guava-testlib",
"//third_party:jsr305",
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcBuildVariablesTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcBuildVariablesTest.java
new file mode 100644
index 0000000000..58dc0e7e85
--- /dev/null
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcBuildVariablesTest.java
@@ -0,0 +1,247 @@
+// Copyright 2017 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.rules.objc;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import com.google.common.collect.ImmutableList;
+import com.google.devtools.build.lib.actions.Action;
+import com.google.devtools.build.lib.actions.Artifact;
+import com.google.devtools.build.lib.actions.CommandAction;
+import com.google.devtools.build.lib.actions.util.ActionsTestUtil;
+import com.google.devtools.build.lib.analysis.ConfiguredTarget;
+import com.google.devtools.build.lib.cmdline.Label;
+import com.google.devtools.build.lib.packages.util.MockObjcSupport;
+import com.google.devtools.build.lib.rules.apple.AppleCommandLineOptions;
+import com.google.devtools.build.lib.rules.apple.cpp.AppleCcToolchain;
+import com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.Variables;
+import com.google.devtools.build.lib.rules.cpp.CppLinkAction;
+import com.google.devtools.build.lib.rules.cpp.Link;
+import com.google.devtools.build.lib.rules.cpp.LinkBuildVariablesTestCase;
+import com.google.devtools.build.lib.testutil.TestConstants;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Tests that {@code CppLinkAction} is populated with the correct build variables for objective C
+ * builds.
+ **/
+@RunWith(JUnit4.class)
+public class ObjcBuildVariablesTest extends LinkBuildVariablesTestCase {
+
+ @Before
+ public void initializeToolsConfigMock() throws Exception {
+ MockObjcSupport.setup(mockToolsConfig);
+ }
+
+ @Override
+ protected void useConfiguration(String... args) throws Exception {
+ ImmutableList<String> extraArgs = ImmutableList.<String>builder()
+ .addAll(TestConstants.OSX_CROSSTOOL_FLAGS)
+ .add("--xcode_version_config=" + MockObjcSupport.XCODE_VERSION_CONFIG)
+ .add("--apple_crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL)
+ .add("--crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL)
+ .addAll(ImmutableList.copyOf(args))
+ .build();
+
+ super.useConfiguration(extraArgs.toArray(new String[extraArgs.size()]));
+ }
+
+ @Test
+ public void testAppleBuildVariablesIos() throws Exception {
+ MockObjcSupport.setup(mockToolsConfig);
+ useConfiguration(
+ "--crosstool_top=//tools/osx/crosstool", "--xcode_version=5.8",
+ "--ios_minimum_os=12.345", "--watchos_minimum_os=11.111",
+ "--cpu=ios_x86_64");
+ scratch.file(
+ "x/BUILD",
+ "cc_binary(",
+ " name = 'bin',",
+ " srcs = ['a.cc'],",
+ ")");
+ scratch.file("x/a.cc");
+
+ ConfiguredTarget target = getConfiguredTarget("//x:bin");
+ Variables variables = getLinkBuildVariables(target, Link.LinkTargetType.EXECUTABLE);
+ assertThat(
+ getVariableValue(variables, AppleCcToolchain.XCODE_VERISON_OVERRIDE_VALUE_KEY))
+ .contains("5.8");
+ assertThat(
+ getVariableValue(
+ variables, AppleCcToolchain.APPLE_SDK_VERSION_OVERRIDE_VALUE_KEY))
+ .contains("8.4");
+ assertThat(getVariableValue(variables, AppleCcToolchain.APPLE_SDK_PLATFORM_VALUE_KEY))
+ .contains("iPhoneSimulator");
+ assertThat(getVariableValue(variables, AppleCcToolchain.VERSION_MIN_KEY))
+ .contains("12.345");
+ }
+
+ @Test
+ public void testAppleBuildVariablesWatchos() throws Exception {
+ String dummyMinimumOsValue = "11.111";
+ useConfiguration(
+ "--crosstool_top=//tools/osx/crosstool", "--xcode_version=5.8",
+ "--ios_minimum_os=12.345", "--watchos_minimum_os=" + dummyMinimumOsValue,
+ "--watchos_cpus=armv7k");
+
+ scratch.file(
+ "x/BUILD",
+ "apple_binary(",
+ " name = 'bin',",
+ " deps = [':a'],",
+ " platform_type = 'watchos',",
+ ")",
+ "cc_library(",
+ " name = 'a',",
+ " srcs = ['a.cc'],",
+ ")");
+ scratch.file("x/a.cc");
+
+ ConfiguredTarget target = getConfiguredTarget("//x:bin");
+ // In order to get the set of variables that apply to the c++
+ // actions, follow the chain of actions starting at the lipobin
+ // creation.
+ Artifact lipoBin =
+ getBinArtifact(Label.parseAbsolute("//x:bin").getName() + "_lipobin", target);
+ Action lipoAction = getGeneratingAction(lipoBin);
+ Artifact bin = ActionsTestUtil.getFirstArtifactEndingWith(lipoAction.getInputs(), "_bin");
+ CommandAction appleBinLinkAction = (CommandAction) getGeneratingAction(bin);
+ Artifact archive =
+ ActionsTestUtil.getFirstArtifactEndingWith(appleBinLinkAction.getInputs(), "liba.a");
+ CppLinkAction ccArchiveAction = (CppLinkAction) getGeneratingAction(archive);
+
+ Variables variables = ccArchiveAction.getLinkCommandLine().getBuildVariables();
+ assertThat(
+ getVariableValue(variables, AppleCcToolchain.XCODE_VERISON_OVERRIDE_VALUE_KEY))
+ .contains("5.8");
+ assertThat(
+ getVariableValue(
+ variables, AppleCcToolchain.APPLE_SDK_VERSION_OVERRIDE_VALUE_KEY))
+ .contains("2.0");
+ assertThat(getVariableValue(variables, AppleCcToolchain.APPLE_SDK_PLATFORM_VALUE_KEY))
+ .contains("WatchOS");
+ assertThat(getVariableValue(variables, AppleCcToolchain.VERSION_MIN_KEY))
+ .contains(dummyMinimumOsValue);
+ }
+
+ @Test
+ public void testAppleBuildVariablesMacos() throws Exception {
+ MockObjcSupport.setup(mockToolsConfig);
+ String dummyMinimumOsValue = "13.579";
+ useConfiguration(
+ "--crosstool_top=//tools/osx/crosstool",
+ "--experimental_objc_crosstool=all",
+ "--apple_crosstool_transition",
+ "--cpu=darwin_x86_64",
+ "--macos_minimum_os=" + dummyMinimumOsValue);
+ scratch.file(
+ "x/BUILD",
+ "apple_binary(",
+ " name = 'bin',",
+ " deps = [':a'],",
+ " platform_type = 'macos',",
+ ")",
+ "cc_library(",
+ " name = 'a',",
+ " srcs = ['a.cc'],",
+ ")");
+ scratch.file("x/a.cc");
+
+ ConfiguredTarget target = getConfiguredTarget("//x:bin");
+ // In order to get the set of variables that apply to the c++ actions, follow the chain of
+ // actions starting at the lipobin creation.
+ Artifact lipoBin =
+ getBinArtifact(Label.parseAbsolute("//x:bin").getName() + "_lipobin", target);
+ Action lipoAction = getGeneratingAction(lipoBin);
+ Artifact bin = ActionsTestUtil.getFirstArtifactEndingWith(lipoAction.getInputs(), "_bin");
+ CommandAction appleBinLinkAction = (CommandAction) getGeneratingAction(bin);
+ Artifact archive =
+ ActionsTestUtil.getFirstArtifactEndingWith(appleBinLinkAction.getInputs(), "liba.a");
+ CppLinkAction ccArchiveAction = (CppLinkAction) getGeneratingAction(archive);
+
+ Variables variables = ccArchiveAction.getLinkCommandLine().getBuildVariables();
+ assertThat(getVariableValue(variables, AppleCcToolchain.VERSION_MIN_KEY))
+ .contains(dummyMinimumOsValue);
+ }
+
+ @Test
+ public void testDefaultBuildVariablesIos() throws Exception {
+ MockObjcSupport.setup(mockToolsConfig);
+ useConfiguration(
+ "--crosstool_top=//tools/osx/crosstool", "--cpu=ios_x86_64");
+ scratch.file(
+ "x/BUILD",
+ "cc_binary(",
+ " name = 'bin',",
+ " srcs = ['a.cc'],",
+ ")");
+ scratch.file("x/a.cc");
+
+ ConfiguredTarget target = getConfiguredTarget("//x:bin");
+ Variables variables = getLinkBuildVariables(target, Link.LinkTargetType.EXECUTABLE);
+ assertThat(
+ getVariableValue(variables, AppleCcToolchain.XCODE_VERISON_OVERRIDE_VALUE_KEY))
+ .contains(MockObjcSupport.DEFAULT_XCODE_VERSION);
+ assertThat(
+ getVariableValue(
+ variables, AppleCcToolchain.APPLE_SDK_VERSION_OVERRIDE_VALUE_KEY))
+ .contains(MockObjcSupport.DEFAULT_IOS_SDK_VERSION);
+ assertThat(getVariableValue(variables, AppleCcToolchain.VERSION_MIN_KEY))
+ .contains(AppleCommandLineOptions.DEFAULT_IOS_SDK_VERSION);
+ }
+
+ @Test
+ public void testMinimumOsAttributeBuildVariable() throws Exception {
+ MockObjcSupport.setup(mockToolsConfig);
+ String dummyMinimumOsValue = "13.579";
+ useConfiguration(
+ "--crosstool_top=//tools/osx/crosstool",
+ "--experimental_objc_crosstool=all",
+ "--apple_crosstool_transition",
+ "--cpu=darwin_x86_64");
+ scratch.file(
+ "x/BUILD",
+ "apple_binary(",
+ " name = 'bin',",
+ " deps = [':a'],",
+ " platform_type = 'ios',",
+ " minimum_os_version = '" + dummyMinimumOsValue + "',",
+ ")",
+ "cc_library(",
+ " name = 'a',",
+ " srcs = ['a.cc'],",
+ ")");
+ scratch.file("x/a.cc");
+
+ ConfiguredTarget target = getConfiguredTarget("//x:bin");
+ // In order to get the set of variables that apply to the c++ actions, follow the chain of
+ // actions starting at the lipobin creation.
+ Artifact lipoBin =
+ getBinArtifact(Label.parseAbsolute("//x:bin").getName() + "_lipobin", target);
+ Action lipoAction = getGeneratingAction(lipoBin);
+ Artifact bin = ActionsTestUtil.getFirstArtifactEndingWith(lipoAction.getInputs(), "_bin");
+ CommandAction appleBinLinkAction = (CommandAction) getGeneratingAction(bin);
+ Artifact archive =
+ ActionsTestUtil.getFirstArtifactEndingWith(appleBinLinkAction.getInputs(), "liba.a");
+ CppLinkAction ccArchiveAction = (CppLinkAction) getGeneratingAction(archive);
+
+ Variables variables = ccArchiveAction.getLinkCommandLine().getBuildVariables();
+ assertThat(getVariableValue(variables, AppleCcToolchain.VERSION_MIN_KEY))
+ .contains(dummyMinimumOsValue);
+ }
+}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoAspectTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoAspectTest.java
index b66630017e..27e6fb81d1 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoAspectTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoAspectTest.java
@@ -23,6 +23,7 @@ import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.packages.util.MockObjcSupport;
import com.google.devtools.build.lib.packages.util.MockProtoSupport;
import com.google.devtools.build.lib.rules.apple.AppleConfiguration.ConfigurationDistinguisher;
+import com.google.devtools.build.lib.testutil.TestConstants;
import com.google.devtools.build.lib.vfs.PathFragment;
import org.junit.Before;
import org.junit.Test;
@@ -74,7 +75,7 @@ public final class ObjcProtoAspectTest extends ObjcRuleTestCase {
ObjcProtoProvider objcProtoProvider = topTarget.getProvider(ObjcProtoProvider.class);
assertThat(objcProtoProvider).isNotNull();
assertThat(Artifact.toExecPaths(objcProtoProvider.getProtobufHeaders()))
- .containsExactly("objcproto/include/header.h");
+ .containsExactly(TestConstants.TOOLS_REPOSITORY_PATH_PREFIX + "objcproto/include/header.h");
Artifact header = Iterables.getOnlyElement(objcProtoProvider.getProtobufHeaders());
PathFragment includePath = header.getExecPath().getParentDirectory();
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoLibraryTest.java
index 26ac6007ad..3894f64224 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoLibraryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoLibraryTest.java
@@ -18,7 +18,6 @@ import static com.google.common.truth.Truth.assertThat;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Ordering;
import com.google.devtools.build.lib.actions.Artifact;
@@ -35,6 +34,7 @@ import com.google.devtools.build.lib.packages.util.MockProtoSupport;
import com.google.devtools.build.lib.rules.apple.ApplePlatform;
import com.google.devtools.build.lib.rules.apple.AppleToolchain;
import com.google.devtools.build.lib.rules.cpp.CppModuleMapAction;
+import com.google.devtools.build.lib.testutil.TestConstants;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
@@ -137,7 +137,7 @@ public class ObjcProtoLibraryTest extends ObjcRuleTestCase {
"proto_library(",
" name = 'protolib_well_known_types',",
" srcs = ['file_a.proto'],",
- " deps = ['//objcproto:well_known_type_proto'],",
+ " deps = ['" + TestConstants.TOOLS_REPOSITORY + "//objcproto:well_known_type_proto'],",
")",
"",
"genrule(",
@@ -274,7 +274,7 @@ public class ObjcProtoLibraryTest extends ObjcRuleTestCase {
BuildConfiguration topLevelConfig = getAppleCrosstoolConfiguration();
assertThat(action.getArguments())
.containsExactly(
- "tools/objc/protobuf_compiler_wrapper.sh",
+ TestConstants.TOOLS_REPOSITORY_PATH_PREFIX + "tools/objc/protobuf_compiler_wrapper.sh",
"--input-file-list",
inputFileList.getExecPathString(),
"--output-dir",
@@ -294,9 +294,9 @@ public class ObjcProtoLibraryTest extends ObjcRuleTestCase {
.inOrder();
assertThat(Artifact.toRootRelativePaths(action.getInputs()))
.containsAllOf(
- "tools/objc/protobuf_compiler_wrapper.sh",
- "tools/objc/protobuf_compiler_helper.py",
- "tools/objc/proto_support");
+ TestConstants.TOOLS_REPOSITORY_PATH_PREFIX + "tools/objc/protobuf_compiler_wrapper.sh",
+ TestConstants.TOOLS_REPOSITORY_PATH_PREFIX + "tools/objc/protobuf_compiler_helper.py",
+ TestConstants.TOOLS_REPOSITORY_PATH_PREFIX + "tools/objc/proto_support");
assertThat(Artifact.toRootRelativePaths(action.getInputs())).containsAllIn(protoInputs);
assertThat(action.getInputs()).contains(inputFileList);
@@ -316,16 +316,15 @@ public class ObjcProtoLibraryTest extends ObjcRuleTestCase {
ActionsTestUtil.getFirstArtifactEndingWith(
action.getInputs(), "/_proto_input_files_BundledProtos_0");
- ImmutableList<String> protoInputs = ImmutableList.of("package/file_a.proto");
+ ImmutableList<String> protoInputs = ImmutableList.of(
+ "package/file_a.proto",
+ TestConstants.TOOLS_REPOSITORY_PATH_PREFIX + "objcproto/well_known_type.proto");
assertThat(Artifact.toRootRelativePaths(action.getInputs())).containsAllIn(protoInputs);
assertThat(action.getInputs()).contains(inputFileList);
- assertThat(Artifact.toRootRelativePaths(action.getInputs()))
- .contains("objcproto/well_known_type.proto");
-
FileWriteAction inputListAction = (FileWriteAction) getGeneratingAction(inputFileList);
- assertThat(inputListAction.getFileContents()).isEqualTo(sortedJoin(protoInputs));
+ assertThat(inputListAction.getFileContents()).contains("package/file_a.proto");
}
@Test
@@ -413,19 +412,12 @@ public class ObjcProtoLibraryTest extends ObjcRuleTestCase {
}
private void checkOnlyLibModuleMapsArePresentForTarget(String target) throws Exception {
- Artifact libModuleMap =
- getGenfilesArtifact(
- "opl_protobuf.modulemaps/module.modulemap",
- getConfiguredTarget("//package:opl_protobuf"));
- Artifact protolibModuleMap =
- getGenfilesArtifact(
- "protobuf_lib.modulemaps/module.modulemap",
- getConfiguredTarget("//objcproto:protobuf_lib"));
-
ObjcProvider provider = providerForTarget(target);
assertThat(Artifact.toRootRelativePaths(provider.get(ObjcProvider.MODULE_MAP).toSet()))
- .containsExactlyElementsIn(
- Artifact.toRootRelativePaths(ImmutableSet.of(libModuleMap, protolibModuleMap)));
+ .containsExactly(
+ "package/opl_protobuf.modulemaps/module.modulemap",
+ TestConstants.TOOLS_REPOSITORY_PATH_PREFIX
+ + "objcproto/protobuf_lib.modulemaps/module.modulemap");
}
@Test
@@ -437,9 +429,9 @@ public class ObjcProtoLibraryTest extends ObjcRuleTestCase {
assertThat(provider.get(ObjcProvider.INCLUDE).toSet())
.contains(headerFile.getExecPath().getParentDirectory().getParentDirectory());
- ConfiguredTarget libProtoBufTarget = getConfiguredTarget("//objcproto:protobuf_lib");
- assertThat(provider.get(ObjcProvider.LIBRARY).toSet())
- .containsExactly(getBinArtifact("libprotobuf_lib.a", libProtoBufTarget));
+ assertThat(Artifact.toRootRelativePaths(provider.get(ObjcProvider.LIBRARY).toSet()))
+ .containsExactly(TestConstants.TOOLS_REPOSITORY_PATH_PREFIX
+ + "objcproto/libprotobuf_lib.a");
assertThat(provider.get(ObjcProvider.HEADER).toSet()).contains(headerFile);
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoProviderTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoProviderTest.java
index 031a9516bd..6f91eb238e 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoProviderTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcProtoProviderTest.java
@@ -20,7 +20,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
-import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.collect.nestedset.Order;
import com.google.devtools.build.lib.vfs.PathFragment;
@@ -31,7 +30,7 @@ import org.junit.runners.JUnit4;
/** Unit tests for {@link ObjcProvider}. */
@RunWith(JUnit4.class)
-public class ObjcProtoProviderTest extends BuildViewTestCase {
+public class ObjcProtoProviderTest extends ObjcRuleTestCase {
@Before
public final void setup() throws Exception {