diff options
Diffstat (limited to 'src/test/java/com')
21 files changed, 145 insertions, 4201 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/MockObjcSupport.java b/src/test/java/com/google/devtools/build/lib/packages/util/MockObjcSupport.java index d42f6f720a..bc99b16aa2 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/util/MockObjcSupport.java +++ b/src/test/java/com/google/devtools/build/lib/packages/util/MockObjcSupport.java @@ -64,6 +64,7 @@ public final class MockObjcSupport { "bundlemerge", "objc_dummy.mm", "environment_plist.sh", + "device_debug_entitlements.plist", "gcov", "ibtoolwrapper", "momcwrapper", @@ -76,8 +77,34 @@ public final class MockObjcSupport { "libtool")) { config.create(TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/objc/" + tool); } + // Since we deleted ios_application, we have to create a custom rule that mocks out a + // close-enough test host app for ios_test to use until those rules are also deleted. + config.create( + TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/objc/fake_test_app.bzl", + "def _fake_test_app_impl(ctx):", + " return struct(", + " instrumented_files=struct(dependency_attributes=['bundle_loader', 'ipa']),", + " providers=[", + " DefaultInfo(files=depset([ctx.file.ipa])),", + " apple_common.new_xctest_app_provider(", + " bundle_loader=ctx.file.bundle_loader,", + " ipa=ctx.file.ipa,", + " objc_provider=apple_common.new_objc_provider(),", + " ),", + " ],", + " )", + "fake_test_app = rule(", + " implementation=_fake_test_app_impl,", + " attrs={", + " 'bundle_loader': attr.label(", + " single_file=True, default='//tools/objc:xctest_appbin'),", + " 'ipa': attr.label(", + " allow_files=True, single_file=True, default='//tools/objc:xctest_app.ipa'),", + " },", + ")"); config.create( TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/objc/BUILD", + "load(':fake_test_app.bzl', 'fake_test_app')", "package(default_visibility=['//visibility:public'])", "exports_files(glob(['**']))", "filegroup(name = 'default_provisioning_profile', srcs = ['foo.mobileprovision'])", @@ -88,10 +115,11 @@ public final class MockObjcSupport { " name = 'protobuf_compiler_support',", " srcs = ['proto_support', 'protobuf_compiler_helper.py'],", ")", + "sh_binary(name = 'environment_plist', srcs = ['environment_plist.sh'])", + "fake_test_app(name = 'xctest_app')", + "apple_binary(name = 'xctest_appbin', platform_type = 'ios', deps = [':dummy_lib'])", "filegroup(name = 'xctest_infoplist', srcs = ['xctest.plist'])", "filegroup(name = 'j2objc_dead_code_pruner', srcs = ['j2objc_dead_code_pruner.py'])", - "ios_application(name = 'xctest_app', binary = ':xctest_appbin')", - "objc_binary(name = 'xctest_appbin', srcs = ['objc_dummy.mm'])", "filegroup(", " name = 'protobuf_well_known_types',", String.format( @@ -124,13 +152,17 @@ public final class MockObjcSupport { if (TestConstants.TOOLS_REPOSITORY_SCRATCH.length() > 0) { config.create( "tools/objc/BUILD", + "load('@" + + TestConstants.TOOLS_REPOSITORY_SCRATCH + + "//tools/objc:fake_test_app.bzl', 'fake_test_app')", "package(default_visibility=['//visibility:public'])", "exports_files(glob(['**']))", - "ios_application(name = 'xctest_app', binary = ':xctest_appbin')", - "objc_binary(name = 'xctest_appbin', srcs = ['objc_dummy.mm'])", + "fake_test_app(name = 'xctest_app')", + "apple_binary(name = 'xctest_appbin', platform_type = 'ios', deps = [':dummy_lib'])", "filegroup(name = 'default_provisioning_profile', srcs = ['foo.mobileprovision'])", "filegroup(name = 'xctest_infoplist', srcs = ['xctest.plist'])"); } + config.create(TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/objc/xctest_app.ipa"); config.create( TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/objc/foo.mobileprovision", "No such luck"); config.create(TestConstants.TOOLS_REPOSITORY_SCRATCH + "tools/objc/compile_protos.py"); diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/AppleToolchainSelectionTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/AppleToolchainSelectionTest.java index 8b7fba8160..2dad393ac0 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/AppleToolchainSelectionTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/AppleToolchainSelectionTest.java @@ -21,10 +21,7 @@ import com.google.common.base.Joiner; 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.analysis.ConfiguredTarget; -import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.analysis.util.ScratchAttributeWriter; -import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.rules.apple.AppleConfiguration.ConfigurationDistinguisher; import com.google.devtools.build.lib.rules.cpp.CppConfiguration; import com.google.devtools.build.lib.rules.cpp.CppLinkAction; @@ -42,31 +39,6 @@ public class AppleToolchainSelectionTest extends ObjcRuleTestCase { useConfiguration(ObjcCrosstoolMode.LIBRARY, args); } - /** - * Returns the given target in the configuration that it would be given by this - * {@code BuildViewTestCase}'s {@code Transitions}, were the target a top-level target. - */ - private ConfiguredTarget getTopLevelConfiguredTarget(ConfiguredTarget target) - throws InterruptedException { - BuildConfiguration topLevelConfig = getAppleCrosstoolConfiguration(); - return getConfiguredTarget(target.getLabel(), topLevelConfig); - } - - /** - * Returns the action that produces the artifact with the given label and suffix, in a output - * directory consistent with that action being registered by a top-level target. - */ - private CommandAction actionProducingArtifactForTopLevelTarget(String targetLabel, - String artifactSuffix) throws Exception { - ConfiguredTarget libraryTarget = getConfiguredTarget(targetLabel); - ConfiguredTarget topLevelLibraryTarget = getTopLevelConfiguredTarget(libraryTarget); - Label parsedLabel = Label.parseAbsolute(targetLabel); - Artifact linkedLibrary = getBinArtifact( - parsedLabel.getName() + artifactSuffix, - topLevelLibraryTarget); - return (CommandAction) getGeneratingAction(linkedLibrary); - } - @Test public void testToolchainSelectionDefault() throws Exception { createLibraryTargetWriter("//a:lib").write(); @@ -104,9 +76,15 @@ public class AppleToolchainSelectionTest extends ObjcRuleTestCase { .setList("deps", "//b:lib") .write(); - CommandAction linkAction = actionProducingArtifactForTopLevelTarget("//a:bin", "_bin"); - Artifact ccArchive = getFirstArtifactEndingWith(linkAction.getInputs(), "liblib.a"); - CommandAction ccArchiveAction = (CommandAction) getGeneratingAction(ccArchive); + Action lipoAction = actionProducingArtifact("//a:bin", "_lipobin"); + String x8664Bin = + configurationBin("x86_64", ConfigurationDistinguisher.APPLEBIN_IOS, DEFAULT_IOS_SDK_VERSION) + + "a/bin_bin"; + Artifact binArtifact = getFirstArtifactEndingWith(lipoAction.getInputs(), x8664Bin); + CommandAction linkAction = getGeneratingSpawnAction(binArtifact); + CppLinkAction ccArchiveAction = + (CppLinkAction) + getGeneratingAction(getFirstArtifactEndingWith(linkAction.getInputs(), "liblib.a")); Artifact ccObjectFile = getFirstArtifactEndingWith(ccArchiveAction.getInputs(), ".o"); CommandAction ccCompileAction = (CommandAction) getGeneratingAction(ccObjectFile); assertThat(ccCompileAction.getArguments()).contains("tools/osx/crosstool/iossim/wrapped_clang"); @@ -123,9 +101,15 @@ public class AppleToolchainSelectionTest extends ObjcRuleTestCase { .setList("srcs", "a.m") .setList("deps", "//b:lib") .write(); - CommandAction linkAction = actionProducingArtifactForTopLevelTarget("//a:bin", "_bin"); - Artifact ccArchive = getFirstArtifactEndingWith(linkAction.getInputs(), "liblib.a"); - CommandAction ccArchiveAction = (CommandAction) getGeneratingAction(ccArchive); + Action lipoAction = actionProducingArtifact("//a:bin", "_lipobin"); + String armv7Bin = + configurationBin("armv7", ConfigurationDistinguisher.APPLEBIN_IOS, DEFAULT_IOS_SDK_VERSION) + + "a/bin_bin"; + Artifact binArtifact = getFirstArtifactEndingWith(lipoAction.getInputs(), armv7Bin); + CommandAction linkAction = getGeneratingSpawnAction(binArtifact); + CppLinkAction ccArchiveAction = + (CppLinkAction) + getGeneratingAction(getFirstArtifactEndingWith(linkAction.getInputs(), "liblib.a")); Artifact ccObjectFile = getFirstArtifactEndingWith(ccArchiveAction.getInputs(), ".o"); CommandAction ccCompileAction = (CommandAction) getGeneratingAction(ccObjectFile); assertThat(ccCompileAction.getArguments()).contains("tools/osx/crosstool/ios/wrapped_clang"); diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcLibraryTest.java index 684426ef22..2599ce4bdc 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcLibraryTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/BazelJ2ObjcLibraryTest.java @@ -18,6 +18,7 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.getFirstArtifactEndingWith; import com.google.common.base.Joiner; +import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; @@ -34,11 +35,14 @@ import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.actions.ActionTemplate.ActionTemplateExpansionException; import com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction; import com.google.devtools.build.lib.analysis.actions.SpawnAction; +import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.cmdline.RepositoryName; import com.google.devtools.build.lib.packages.util.MockObjcSupport; import com.google.devtools.build.lib.rules.apple.AppleConfiguration; +import com.google.devtools.build.lib.rules.apple.ApplePlatform.PlatformType; import com.google.devtools.build.lib.rules.apple.AppleToolchain; +import com.google.devtools.build.lib.rules.apple.DottedVersion; import com.google.devtools.build.lib.rules.cpp.CppCompileActionTemplate; import com.google.devtools.build.lib.rules.cpp.CppModuleMapAction; import com.google.devtools.build.lib.rules.cpp.UmbrellaHeaderAction; @@ -57,6 +61,21 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public class BazelJ2ObjcLibraryTest extends J2ObjcLibraryTest { + /** + * Gets the target with the given label, using the apple_binary multi-arch split transition with + * the default version of iOS as the platform. + */ + private ConfiguredTarget getConfiguredTargetInAppleBinaryTransition(String label) + throws Exception { + BuildConfiguration childConfig = + Iterables.getOnlyElement( + getSplitConfigurations( + targetConfig, + new MultiArchSplitTransitionProvider.AppleBinaryTransition( + PlatformType.IOS, Optional.<DottedVersion>absent()))); + return getConfiguredTarget(label, childConfig); + } + @Test public void testJ2ObjCInformationExportedFromJ2ObjcLibrary() throws Exception { ConfiguredTarget j2objcLibraryTarget = getConfiguredTarget( @@ -265,7 +284,8 @@ public class BazelJ2ObjcLibraryTest extends J2ObjcLibraryTest { (CommandAction) getGeneratingAction( getBinArtifact( - String.format("%s_bin", labelName), getConfiguredTarget(targetLabel))); + String.format("%s_bin", labelName), + getConfiguredTargetInAppleBinaryTransition(targetLabel))); checkObjcCompileActions( getFirstArtifactEndingWith(linkAction.getInputs(), archiveFileName), @@ -458,18 +478,19 @@ public class BazelJ2ObjcLibraryTest extends J2ObjcLibraryTest { protected void addSimpleBinaryTarget(String j2objcLibraryTargetDep) throws Exception { scratch.file("app/app.m"); scratch.file("app/Info.plist"); - scratch.file("app/BUILD", + scratch.file( + "app/BUILD", "package(default_visibility=['//visibility:public'])", "objc_library(", " name = 'lib',", " deps = ['" + j2objcLibraryTargetDep + "'])", "", - "objc_binary(", + "apple_binary(", " name = 'app',", " srcs = ['app.m'],", + " platform_type = 'ios',", " deps = [':lib'],", ")"); - } protected void addSimpleJ2ObjcLibraryWithEntryClasses() throws Exception { @@ -598,27 +619,16 @@ public class BazelJ2ObjcLibraryTest extends J2ObjcLibraryTest { " name = 'j2',", " deps = [ '//java/c/y:ylib' ],", " jre_deps = [ '//third_party/java/j2objc:jre_io_lib' ])", - "ios_application(", - " name = 'app',", - " binary = ':bin',", - " infoplist = 'info.plist',", - ")", - "objc_binary(", - " name = 'bin',", - " srcs = ['bin.m'],", - " deps = [':j2'],", - ")", - "ios_test(", + "apple_binary(", " name = 'test',", " srcs = ['test.m'],", + " platform_type = 'ios',", " deps = [':j2'],", - " xctest = 1,", - " xctest_app = ':app',", ")"); CommandAction linkAction = linkAction("//x:test"); List<String> linkArgs = normalizeBashArgs(linkAction.getArguments()); - ConfiguredTarget target = getConfiguredTarget("//x:test"); + ConfiguredTarget target = getConfiguredTargetInAppleBinaryTransition("//x:test"); String binDir = target.getConfiguration().getBinDirectory(RepositoryName.MAIN).getExecPathString(); Artifact fileList = getFirstArtifactEndingWith(linkAction.getInputs(), "test-linker.objlist"); @@ -844,7 +854,7 @@ public class BazelJ2ObjcLibraryTest extends J2ObjcLibraryTest { addSimpleJ2ObjcLibraryWithEntryClasses(); addSimpleBinaryTarget("//java/com/google/app/test:transpile"); - ConfiguredTarget appTarget = getConfiguredTarget("//app:app", getAppleCrosstoolConfiguration()); + ConfiguredTarget appTarget = getConfiguredTargetInAppleBinaryTransition("//app:app"); Artifact prunedArchive = getBinArtifact( "_j2objc_pruned/app/java/com/google/app/test/libtest_j2objc_pruned.a", appTarget); @@ -852,7 +862,7 @@ public class BazelJ2ObjcLibraryTest extends J2ObjcLibraryTest { getBinArtifact("_j2objc_pruned/app/java/com/google/app/test/test.param.j2objc", appTarget); ConfiguredTarget javaTarget = - getConfiguredTarget("//java/com/google/app/test:test", getAppleCrosstoolConfiguration()); + getConfiguredTargetInAppleBinaryTransition("//java/com/google/app/test:test"); Artifact inputArchive = getBinArtifact("libtest_j2objc.a", javaTarget); Artifact headerMappingFile = getBinArtifact("test.mapping.j2objc", javaTarget); Artifact dependencyMappingFile = getBinArtifact("test.dependency_mapping.j2objc", javaTarget); diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ExperimentalObjcBinaryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ExperimentalObjcBinaryTest.java deleted file mode 100644 index 0f8f03ccff..0000000000 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/ExperimentalObjcBinaryTest.java +++ /dev/null @@ -1,302 +0,0 @@ -// 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 static com.google.devtools.build.lib.rules.objc.LegacyCompilationSupport.AUTOMATIC_SDK_FRAMEWORKS; - -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; -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.analysis.ConfiguredTarget; -import com.google.devtools.build.lib.analysis.util.ScratchAttributeWriter; -import com.google.devtools.build.lib.packages.util.MockObjcSupport; -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.CppCompileAction; -import com.google.devtools.build.lib.rules.cpp.CppLinkAction; -import com.google.devtools.build.lib.rules.objc.ObjcCommandLineOptions.ObjcCrosstoolMode; -import java.util.List; -import java.util.Map; -import java.util.regex.Pattern; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Test case for linking targets with the OSX crosstool. */ -@RunWith(JUnit4.class) -@LegacyTest -public class ExperimentalObjcBinaryTest extends ObjcRuleTestCase { - static final RuleType RULE_TYPE = new BinaryRuleType("objc_binary"); - - private static final String WRAPPED_CLANG = "wrapped_clang"; - private static final String WRAPPED_CLANGPLUSPLUS = "wrapped_clang++"; - - private ConfiguredTarget addMockBinAndLibs(List<String> srcs) throws Exception { - createLibraryTargetWriter("//lib1:lib1") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "hdr.h") - .write(); - createLibraryTargetWriter("//lib2:lib2") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "hdr.h") - .write(); - - return createBinaryTargetWriter("//bin:bin") - .setAndCreateFiles("srcs", srcs) - .setList("deps", "//lib1:lib1", "//lib2:lib2") - .write(); - } - - private ImmutableList<String> automaticSdkFrameworks() { - ImmutableList.Builder<String> result = ImmutableList.<String>builder(); - for (SdkFramework framework : AUTOMATIC_SDK_FRAMEWORKS) { - result.add("-framework " + framework.getName()); - } - return result.build(); - } - - @Test - public void testDeviceBuild() throws Exception { - useConfiguration( - "--crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL, - "--experimental_objc_crosstool=all", - "--experimental_disable_go", - "--cpu=ios_armv7", - "--ios_cpu=armv7"); - ApplePlatform platform = ApplePlatform.IOS_DEVICE; - - addMockBinAndLibs(ImmutableList.of("a.m")); - CommandAction action = linkAction("//bin:bin"); - assertRequiresDarwin(action); - assertThat(Artifact.toRootRelativePaths(action.getInputs())) - .containsExactly( - "bin/libbin.a", - "lib1/liblib1.a", - "lib2/liblib2.a", - "bin/bin-linker.objlist"); - assertThat(Artifact.toRootRelativePaths(action.getOutputs())).containsExactly("bin/bin_bin"); - verifyObjlist( - action, - "bin-linker.objlist", - execPathEndingWith(action.getInputs(), "libbin.a"), - execPathEndingWith(action.getInputs(), "liblib1.a"), - execPathEndingWith(action.getInputs(), "liblib2.a")); - assertThat(action.getArguments()) - .containsExactlyElementsIn( - new ImmutableList.Builder<String>() - .add("tools/osx/crosstool/ios/" + WRAPPED_CLANG) - .add("-arch armv7") - .add("-Xlinker", "-objc_abi_version", "-Xlinker", "2") - .add("-Xlinker", "-rpath", "-Xlinker", "@executable_path/Frameworks") - .add("-fobjc-link-runtime") - .add("-ObjC") - .add("-filelist " + execPathEndingWith(action.getInputs(), "bin-linker.objlist")) - .add("-o " + Iterables.getOnlyElement(Artifact.toExecPaths(action.getOutputs()))) - .add("-F" + AppleToolchain.sdkDir() + AppleToolchain.DEVELOPER_FRAMEWORK_PATH) - .add("-F" + frameworkDir(platform)) - .add("-isysroot") - .add(AppleToolchain.sdkDir()) - // TODO(b/35853671): Factor out "-lc++" - .add("-lc++") - .add("-target", "armv7-apple-ios") - .add("-miphoneos-version-min=" + DEFAULT_IOS_SDK_VERSION) - .addAll(automaticSdkFrameworks()) - .build()) - .inOrder(); - } - - @Test - public void testSimulatorBuild() throws Exception { - useConfiguration( - "--crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL, - "--experimental_objc_crosstool=all", - "--experimental_disable_go", - "--cpu=ios_x86_64", - "--ios_cpu=x86_64"); - ApplePlatform platform = ApplePlatform.IOS_SIMULATOR; - - addMockBinAndLibs(ImmutableList.of("a.m")); - CommandAction action = linkAction("//bin:bin"); - assertThat(action.getArguments()) - .containsAllOf( - "tools/osx/crosstool/iossim/" + WRAPPED_CLANG, - "-arch x86_64", - "-mios-simulator-version-min=" + DEFAULT_IOS_SDK_VERSION, - "-F" + frameworkDir(platform)); - } - - @Test - public void testAlwaysLinkCcDependenciesAreForceLoaded() throws Exception { - useConfiguration( - "--crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL, - "--experimental_objc_crosstool=all", - "--experimental_disable_go", - "--cpu=ios_armv7", - "--ios_cpu=armv7"); - - scratch.file( - "bin/BUILD", - "cc_library(", - " name = 'cclib1',", - " srcs = ['dep1.c'],", - " alwayslink = 1,", - ")", - "cc_library(", - " name = 'cclib2',", - " srcs = ['dep2.c'],", - " deps = [':cclib1'],", - ")", - "objc_binary(", - " name = 'bin',", - " srcs = ['bin.m'],", - " deps = [':cclib2'],", - ")"); - - // cclib1 is force loaded. - assertThat(Joiner.on(" ").join(linkAction("//bin").getArguments())) - .containsMatch(Pattern.compile(" -force_load [^\\s]+/libcclib1.lo\\b")); - } - - @Test - public void testObjcPlusPlusLinkAction() throws Exception { - useConfiguration( - "--crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL, - "--experimental_objc_crosstool=all", - "--experimental_disable_go", - "--cpu=ios_armv7", - "--ios_cpu=armv7"); - - addMockBinAndLibs(ImmutableList.of("a.mm")); - - CommandAction action = linkAction("//bin:bin"); - assertThat(action.getArguments()) - .containsAllOf( - "tools/osx/crosstool/ios/" + WRAPPED_CLANGPLUSPLUS, - "-stdlib=libc++", - "-std=gnu++11"); - } - - @Test - public void testUnstrippedArtifactGeneratedForBinaryStripping() throws Exception { - useConfiguration( - "--crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL, - "--experimental_objc_crosstool=all", - "--experimental_disable_go", - "--objc_enable_binary_stripping", - "--compilation_mode=opt"); - addMockBinAndLibs(ImmutableList.of("a.m")); - Action linkAction = actionProducingArtifact("//bin:bin", "_bin_unstripped"); - Action stripAction = actionProducingArtifact("//bin:bin", "_bin"); - assertThat(linkAction).isNotNull(); - assertThat(stripAction).isNotNull(); - } - - - @Test - public void testDeadStripLinkArguments() throws Exception { - useConfiguration( - "--crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL, - "--experimental_objc_crosstool=all", - "--experimental_disable_go", - "--cpu=ios_armv7", - "--ios_cpu=armv7", - "--objc_enable_binary_stripping", - "--compilation_mode=opt"); - addMockBinAndLibs(ImmutableList.of("a.mm")); - CommandAction linkAction = - (CommandAction) actionProducingArtifact("//bin:bin", "_bin_unstripped"); - assertThat(linkAction.getArguments()) - .containsAllOf("-dead_strip", "-no_dead_strip_inits_and_terms"); - } - - @Test - public void testDeadStripLinkArgumentsNotPresentIfStrippingNotEnabled() throws Exception { - useConfiguration( - "--crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL, - "--experimental_objc_crosstool=all", - "--experimental_disable_go", - "--cpu=ios_armv7", - "--ios_cpu=armv7", - "--compilation_mode=opt"); - addMockBinAndLibs(ImmutableList.of("a.mm")); - CommandAction linkAction = - (CommandAction) actionProducingArtifact("//bin:bin", "_bin"); - assertThat(linkAction.getArguments()) - .containsNoneOf("--dead_strip", "--no_dead_strip_inits_and_terms"); - } - - @Test - public void testDeadStripLinkArgumentsNotPresentIfCompilationModeFastbuild() throws Exception { - useConfiguration( - "--crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL, - "--experimental_objc_crosstool=all", - "--experimental_disable_go", - "--cpu=ios_armv7", - "--ios_cpu=armv7", - "--objc_enable_binary_stripping", - "--compilation_mode=fastbuild"); - addMockBinAndLibs(ImmutableList.of("a.mm")); - CommandAction linkAction = - (CommandAction) actionProducingArtifact("//bin:bin", "_bin"); - assertThat(linkAction.getArguments()) - .containsNoneOf("--dead_strip", "--no_dead_strip_inits_and_terms"); - } - - @Test - public void testCompileEnv() throws Exception { - MockObjcSupport.createCrosstoolPackage(mockToolsConfig); - useConfiguration( - ObjcCrosstoolMode.LIBRARY, - "--experimental_disable_go", - "--experimental_disable_jvm", - "--ios_sdk_version=2.9", - "--xcode_version=5.0", - "--cpu=ios_x86_64"); - ScratchAttributeWriter.fromLabelString(this, "objc_library", "//main:lib") - .setList("srcs", "a.m") - .write(); - - CppCompileAction compileAction = (CppCompileAction) compileAction("//main:lib", "a.o"); - - Map<String, String> environment = compileAction.getEnvironment(); - assertThat(environment).containsEntry("XCODE_VERSION_OVERRIDE", "5.0"); - assertThat(environment).containsEntry("APPLE_SDK_VERSION_OVERRIDE", "2.9"); - } - - @Test - public void testArchiveEnv() throws Exception { - MockObjcSupport.createCrosstoolPackage(mockToolsConfig); - useConfiguration( - ObjcCrosstoolMode.LIBRARY, - "--experimental_disable_go", - "--experimental_disable_jvm", - "--ios_sdk_version=2.9", - "--xcode_version=5.0", - "--cpu=ios_x86_64"); - ScratchAttributeWriter.fromLabelString(this, "objc_library", "//main:lib") - .setList("srcs", "a.m") - .write(); - - CppLinkAction archiveAction = (CppLinkAction) archiveAction("//main:lib"); - - Map<String, String> environment = archiveAction.getEnvironment(); - assertThat(environment).containsEntry("XCODE_VERSION_OVERRIDE", "5.0"); - assertThat(environment).containsEntry("APPLE_SDK_VERSION_OVERRIDE", "2.9"); - } -} diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/IosApplicationTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/IosApplicationTest.java deleted file mode 100644 index 5183cfa09d..0000000000 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/IosApplicationTest.java +++ /dev/null @@ -1,1115 +0,0 @@ -// 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 static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.ReleaseBundlingRule.APP_ICON_ATTR; -import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.ReleaseBundlingRule.LAUNCH_IMAGE_ATTR; - -import com.google.common.base.Function; -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableListMultimap; -import com.google.common.collect.ImmutableMultiset; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSetMultimap; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Multiset; -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.analysis.ConfiguredTarget; -import com.google.devtools.build.lib.analysis.RuleContext; -import com.google.devtools.build.lib.analysis.RunfilesProvider; -import com.google.devtools.build.lib.analysis.actions.SpawnAction; -import com.google.devtools.build.lib.analysis.config.BuildConfiguration; -import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget.Mode; -import com.google.devtools.build.lib.rules.apple.AppleConfiguration; -import com.google.devtools.build.lib.rules.apple.AppleConfiguration.ConfigurationDistinguisher; -import com.google.devtools.build.lib.rules.apple.DottedVersion; -import com.google.devtools.build.lib.testutil.Scratch; -import com.google.devtools.build.xcode.bundlemerge.proto.BundleMergeProtos; -import com.google.devtools.build.xcode.bundlemerge.proto.BundleMergeProtos.BundleFile; -import com.google.devtools.build.xcode.plmerge.proto.PlMergeProtos; -import java.io.IOException; -import java.util.List; -import java.util.Set; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Test case for ios_application. */ -@RunWith(JUnit4.class) -@LegacyTest -public class IosApplicationTest extends ObjcRuleTestCase { - protected static final RuleType RULE_TYPE = - new RuleType("ios_application") { - @Override - Iterable<String> requiredAttributes( - Scratch scratch, String packageDir, Set<String> alreadyAdded) throws IOException { - ImmutableList.Builder<String> attributes = new ImmutableList.Builder<>(); - if (!alreadyAdded.contains("binary")) { - scratch.file(packageDir + "/bin/a.m"); - scratch.file(packageDir + "/bin/BUILD", "objc_binary(name = 'bin', srcs = ['a.m'])"); - attributes.add("binary = '//" + packageDir + "/bin:bin'"); - } - return attributes.build(); - } - }; - - protected static final BinaryRuleTypePair RULE_TYPE_PAIR = - new BinaryRuleTypePair( - ObjcBinaryTest.RULE_TYPE, RULE_TYPE, ReleaseBundlingSupport.APP_BUNDLE_DIR_FORMAT); - - private ConfiguredTarget addMockAppAndLibs(String... extraAppAttributes) - throws Exception { - createLibraryTargetWriter("//lib1:lib1") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "hdr.h") - .write(); - createLibraryTargetWriter("//lib2:lib2") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "hdr.h") - .write(); - scratch.file("x/a.m"); - scratch.file("x/x-Info.plist"); - scratch.file("x/BUILD", - "objc_binary(", - " name = 'bin',", - " srcs = ['a.m'],", - " deps = ['//lib1:lib1', '//lib2:lib2'],", - ")", - "", - "ios_application(", - " name = 'x',", - " binary = ':bin',", - Joiner.on(',').join(extraAppAttributes), - ")"); - return getConfiguredTarget("//x:x"); - } - - @Test - public void testSplitConfigurationProviders() throws Exception { - useConfiguration("--ios_multi_cpus=i386,x86_64"); - scratch.file("x/BUILD", - "objc_binary(", - " name = 'bin',", - " srcs = ['a.m'],", - ")", - "", - "ios_application(", - " name = 'x',", - " infoplist = 'Info.plist',", - " binary = ':bin',", - ")"); - RuleContext ruleContext = getRuleContext(getConfiguredTarget("//x:x")); - ImmutableListMultimap<BuildConfiguration, ObjcProvider> prereqByConfig = - ruleContext.getPrerequisitesByConfiguration( - "binary", Mode.SPLIT, ObjcProvider.SKYLARK_CONSTRUCTOR); - List<String> childCpus = Lists.transform(prereqByConfig.keySet().asList(), - new Function<BuildConfiguration, String>() { - @Override - public String apply(BuildConfiguration config) { - return config.getFragment(AppleConfiguration.class).getIosCpu(); - } - }); - assertThat(childCpus).containsExactly("i386", "x86_64"); - } - - @Test - public void testRunfiles() throws Exception { - ConfiguredTarget application = addMockAppAndLibs(); - RunfilesProvider runfiles = application.getProvider(RunfilesProvider.class); - assertThat(runfiles.getDefaultRunfiles().getArtifacts()).isEmpty(); - assertThat(Artifact.toRootRelativePaths(runfiles.getDataRunfiles().getArtifacts())) - .containsExactly("x/x.ipa"); - } - - @Test - public void testFilesToRun() throws Exception { - checkFilesToRun(RULE_TYPE); - } - - @Test - public void testNoRunfilesSupportForDevice() throws Exception { - checkNoRunfilesSupportForDevice(RULE_TYPE); - } - - @Test - public void testGenerateRunnerScriptAction() throws Exception { - checkGenerateRunnerScriptAction(RULE_TYPE); - } - - @Test - public void testGenerateRunnerScriptAction_escaped() throws Exception { - checkGenerateRunnerScriptAction_escaped(RULE_TYPE); - } - - @Test - public void testSigningAction() throws Exception { - checkDeviceSigningAction(RULE_TYPE); - } - - @Test - public void testSigningWithCertName() throws Exception { - checkSigningWithCertName(RULE_TYPE); - } - - @Test - public void testPostProcessingAction() throws Exception { - checkPostProcessingAction(RULE_TYPE); - } - - @Test - public void testSigningAndPostProcessing() throws Exception { - checkSigningAndPostProcessing(RULE_TYPE); - } - - @Test - public void testSigning_simulatorBuild() throws Exception { - checkSigningSimulatorBuild(RULE_TYPE_PAIR, false); - } - - @Test - public void testSigning_simulatorBuild_multiCpu() throws Exception { - checkSigningSimulatorBuild(RULE_TYPE_PAIR, true); - } - - @Test - public void testProvisioningProfile_deviceBuild() throws Exception { - checkProvisioningProfileDeviceBuild(RULE_TYPE_PAIR, false); - } - - @Test - public void testProvisioningProfile_deviceBuild_multiCpu() throws Exception { - checkProvisioningProfileDeviceBuild(RULE_TYPE_PAIR, true); - } - - @Test - public void testUserSpecifiedProvisioningProfile_deviceBuild() throws Exception { - checkProvisioningProfileUserSpecified(RULE_TYPE_PAIR, false); - } - - @Test - public void testUserSpecifiedProvisioningProfile_deviceBuild_multiCpu() throws Exception { - checkProvisioningProfileUserSpecified(RULE_TYPE_PAIR, true); - } - - @Test - public void testMergeControlAction() throws Exception { - addMockAppAndLibs("infoplist = 'Info.plist'"); - Action mergeAction = bundleMergeAction("//x:x"); - Action action = bundleMergeControlAction("//x:x"); - assertThat(action.getInputs()).isEmpty(); - assertThat(Artifact.toRootRelativePaths(action.getOutputs())) - .containsExactly("x/x.ipa-control"); - assertThat(bundleMergeControl("//x:x")) - .isEqualTo( - BundleMergeProtos.Control.newBuilder() - .addBundleFile( - BundleFile.newBuilder() - .setSourceFile(execPathEndingWith(mergeAction.getInputs(), "x_lipobin")) - .setBundlePath("x") - .setExternalFileAttribute(BundleableFile.EXECUTABLE_EXTERNAL_FILE_ATTRIBUTE) - .build()) - .setBundleRoot(String.format(ReleaseBundlingSupport.APP_BUNDLE_DIR_FORMAT, "x")) - .setBundleInfoPlistFile(execPathEndingWith(mergeAction.getInputs(), "Info.plist")) - .setOutFile(execPathEndingWith(mergeAction.getOutputs(), "x.unprocessed.ipa")) - .setMinimumOsVersion(DEFAULT_IOS_SDK_VERSION.toString()) - .setSdkVersion(DEFAULT_IOS_SDK_VERSION.toString()) - .setPlatform("IOS_SIMULATOR") - .setFallbackBundleIdentifier("example.x") - .build()); - } - - @Test - public void testMergeBundleAction() throws Exception { - checkMergeBundleAction(RULE_TYPE_PAIR); - } - - @Test - public void testCheckPrimaryBundleIdInMergedPlist() throws Exception { - checkPrimaryBundleIdInMergedPlist(RULE_TYPE_PAIR); - } - - @Test - public void testCheckFallbackBundleIdInMergedPlist() throws Exception { - checkFallbackBundleIdInMergedPlist(RULE_TYPE_PAIR); - } - - @Test - public void testErrorForLaunchImageGivenWithNoAssetCatalog() throws Exception { - checkAssetCatalogAttributeError(RULE_TYPE, LAUNCH_IMAGE_ATTR); - } - - @Test - public void testErrorForAppIconGivenWithNoAssetCatalog() throws Exception { - checkAssetCatalogAttributeError(RULE_TYPE, APP_ICON_ATTR); - } - - @Test - public void testCollectsAssetCatalogsTransitively() throws Exception { - checkCollectsAssetCatalogsTransitively(RULE_TYPE_PAIR); - } - - @Test - public void testSpecifyAppIconAndLaunchImageUsingXcassetsOfDependency() throws Exception { - checkSpecifyAppIconAndLaunchImageUsingXcassetsOfDependency( - RULE_TYPE_PAIR, DEFAULT_IOS_SDK_VERSION); - } - - private void addTargetWithAssetCatalogs() throws IOException { - scratch.file("x/foo.xcassets/foo"); - scratch.file("x/foo.xcassets/bar"); - scratch.file("x/a.m"); - scratch.file("x/BUILD", - "objc_binary(", - " name = 'bin',", - " asset_catalogs = ['foo.xcassets/foo', 'bar.xcassets/bar'],", - " srcs = ['a.m'],", - ")", - "", - "ios_application(", - " name = 'x',", - " binary = ':bin',", - ")"); - } - - @Test - public void testActoolAction() throws Exception { - addTargetWithAssetCatalogs(); - checkActoolActionCorrectness(DEFAULT_IOS_SDK_VERSION); - } - - @Test - public void testPassesFamiliesToActool() throws Exception { - checkPassesFamiliesToActool(RULE_TYPE_PAIR); - } - - @Test - public void testPassesFamiliesToIbtool() throws Exception { - checkPassesFamiliesToIbtool(RULE_TYPE_PAIR); - } - - @Test - public void testReportsErrorsForInvalidFamiliesAttribute() throws Exception { - checkReportsErrorsForInvalidFamiliesAttribute(RULE_TYPE); - } - - @Test - public void testMergeActionsWithAssetCatalog() throws Exception { - // TODO(matvore): add this test to IosTestTest.java. - addTargetWithAssetCatalogs(); - checkMergeActionsWithAssetCatalog(RULE_TYPE_PAIR); - } - - private void addBinAndLibWithRawResources() throws Exception { - addBinAndLibWithResources( - "resources", "resource1.txt", "ja.lproj/resource2.txt", "objc_binary"); - scratch.file("x/BUILD", - "ios_application(", - " name = 'x',", - " binary = '//bin:bin',", - ")"); - } - - private void addBinAndLibWithStrings() throws Exception { - addBinAndLibWithResources( - "strings", "foo.strings", "ja.lproj/bar.strings", "objc_binary"); - scratch.file("x/BUILD", - "ios_application(", - " name = 'x',", - " binary = '//bin:bin',", - ")"); - } - - @Test - public void testCollectsRawResourceFilesTransitively() throws Exception { - addBinAndLibWithRawResources(); - checkCollectsResourceFilesTransitively( - "//x:x", - ImmutableList.of("lib/resource1.txt", "bin/ja.lproj/resource2.txt"), - ImmutableList.of("lib/resource1.txt"), - ImmutableSetMultimap.<String, Multiset<String>>of( - "bin_bin", - ImmutableMultiset.of("bin/ja.lproj/resource2.txt", "lib/resource1.txt"), - "bin_static_lib_bin", - ImmutableMultiset.of("bin/ja.lproj/resource2.txt", "lib/resource1.txt"), - "x_x", - ImmutableMultiset.of("bin/ja.lproj/resource2.txt", "lib/resource1.txt"), - "lib_lib", - ImmutableMultiset.of("lib/resource1.txt"))); - } - - @Test - public void testCollectsStringsFilesTransitively() throws Exception { - addBinAndLibWithStrings(); - checkCollectsResourceFilesTransitively( - "//x:x", - ImmutableList.of("x/lib/foo.strings.binary", "x/bin/ja.lproj/bar.strings.binary"), - ImmutableList.of("x/lib/foo.strings.binary"), - ImmutableSetMultimap.<String, Multiset<String>>of( - "bin_bin", - ImmutableMultiset.of("bin/ja.lproj/bar.strings", "lib/foo.strings"), - "bin_static_lib_bin", - ImmutableMultiset.of("bin/ja.lproj/bar.strings", "lib/foo.strings"), - "x_x", - ImmutableMultiset.of("bin/ja.lproj/bar.strings", "lib/foo.strings"), - "lib_lib", - ImmutableMultiset.of("lib/foo.strings"))); - } - - @Test - public void testResourceFilesMergedInBundle() throws Exception { - addBinAndLibWithRawResources(); - checkBundleablesAreMerged("//x:x", - ImmutableListMultimap.of( - "resource1.txt", "resource1.txt", - "ja.lproj/resource2.txt", "ja.lproj/resource2.txt")); - } - - @Test - public void testResourceFlattenedInBundle() throws Exception { - addBinAndLibWithResources( - "resources", "libres/resource1.txt", "binres/resource2.txt", "objc_binary"); - scratch.file("x/BUILD", - "ios_application(", - " name = 'x',", - " binary = '//bin:bin',", - ")"); - checkBundleablesAreMerged("//x:x", - ImmutableListMultimap.of( - "libres/resource1.txt", "resource1.txt", - "binres/resource2.txt", "resource2.txt")); - } - - @Test - public void testStructuredResourceFilesMergedInBundle() throws Exception { - addBinAndLibWithResources( - "structured_resources", "libres/resource1.txt", "binres/resource2.txt", "objc_binary"); - scratch.file("x/BUILD", - "ios_application(", - " name = 'x',", - " binary = '//bin:bin',", - ")"); - checkBundleablesAreMerged("//x:x", - ImmutableListMultimap.of( - "libres/resource1.txt", "libres/resource1.txt", - "binres/resource2.txt", "binres/resource2.txt")); - } - - @Test - public void testStringsFilesMergedInBundle() throws Exception { - addBinAndLibWithStrings(); - checkBundleablesAreMerged("//x:x", - ImmutableListMultimap.of( - "foo.strings.binary", "foo.strings", - "ja.lproj/bar.strings.binary", "ja.lproj/bar.strings")); - } - - @Test - public void testMergesXcdatamodelZips() throws Exception { - checkMergesXcdatamodelZips(RULE_TYPE_PAIR); - } - - @Test - public void testPlistRequiresDotInName() throws Exception { - checkError("x", "x", - "'//x:Infoplist' does not produce any ios_application infoplist files (expected .plist)", - "objc_binary(", - " name = 'bin',", - " srcs = ['a.m'],", - ")", - "", - "ios_application(", - " name = 'x',", - " infoplist = 'Infoplist',", - " binary = ':bin',", - ")"); - } - - @Test - public void testPopulatesBundling() throws Exception { - scratch.file("x/x-Info.plist"); - scratch.file("x/a.m"); - scratch.file("x/assets.xcassets/1"); - scratch.file("x/BUILD", - "objc_binary(", - " name = 'bin',", - " srcs = ['a.m'],", - " asset_catalogs = ['assets.xcassets/1']", - ")", - "ios_application(", - " name = 'x',", - " binary = ':bin',", - " infoplist = 'x-Info.plist',", - ")"); - - PlMergeProtos.Control control = plMergeControl("//x:x"); - assertThat(control.getSourceFileList()) - .contains(getSourceArtifact("x/x-Info.plist").getExecPathString()); - - Artifact actoolzipOutput = getBinArtifact("x.actool.zip", "//x:x"); - assertThat(getGeneratingAction(actoolzipOutput).getInputs()) - .contains(getSourceArtifact("x/assets.xcassets/1")); - } - - @Test - public void testMergesPartialInfoplists() throws Exception { - checkMergesPartialInfoplists(RULE_TYPE_PAIR); - } - - @Test - public void testNibZipsMergedIntoBundle() throws Exception { - checkNibZipsMergedIntoBundle(RULE_TYPE_PAIR); - } - - @Test - public void testNoEntitlementsDefined() throws Exception { - checkNoEntitlementsDefined(RULE_TYPE); - } - - @Test - public void testEntitlementsDefined() throws Exception { - checkEntitlementsDefined(RULE_TYPE); - } - - @Test - public void testExtraEntitlements() throws Exception { - checkExtraEntitlements(RULE_TYPE); - } - - @Test - public void testDebugEntitlements() throws Exception { - checkDebugEntitlements(RULE_TYPE); - } - - @Test - public void testFastbuildDebugEntitlements() throws Exception { - checkFastbuildDebugEntitlements(RULE_TYPE); - } - - @Test - public void testOptNoDebugEntitlements() throws Exception { - checkOptNoDebugEntitlements(RULE_TYPE); - } - - @Test - public void testExplicitNoDebugEntitlements() throws Exception { - checkExplicitNoDebugEntitlements(RULE_TYPE); - } - - @Test - public void testMultiPlatformBuild_fails() throws Exception { - checkBinaryActionMultiPlatform_fails(RULE_TYPE_PAIR); - } - - @Test - public void testMultiArchitectureResources() throws Exception { - checkMultiCpuResourceInheritance(RULE_TYPE_PAIR); - } - - /** - * Regression test for b/27946171. Verifies that nodistinct_host_configuration functions in - * builds with more than one split transition. (In this case, both ios_application and - * ios_extension split into two child configurations.) - */ - @Test - public void testNoDistinctHostConfiguration() throws Exception { - useConfiguration("--ios_multi_cpus=i386,x86_64", "--nodistinct_host_configuration"); - scratch.file("x/BUILD", - "ios_extension_binary(", - " name = 'ext_bin',", - " srcs = ['ebin.m'],", - ")", - "", - "ios_extension(", - " name = 'ext',", - " binary = ':ext_bin',", - ")", - "", - "objc_binary(", - " name = 'bin',", - " srcs = ['bin.m'],", - ")", - "", - "ios_application(", - " name = 'app',", - " binary = ':bin',", - " extensions = [':ext'],", - ")"); - - getConfiguredTarget("//x:app"); - - // Assert that only the deprecation warnings are emitted, but no other events. - assertContainsEventWithFrequency( - "This rule is deprecated. Please use the new Apple build rules " - + "(https://github.com/bazelbuild/rules_apple) to build Apple targets.", - 4); - } - - @Test - public void testApplicationExtensionSharedDependencyResourceActions() throws Exception { - useConfiguration("--ios_multi_cpus=i386,x86_64"); - scratch.file("x/BUILD", - "objc_library(", - " name = 'res',", - " xibs = ['interface.xib'],", - " storyboards = ['story.storyboard'],", - " datamodels = ['data.xcdatamodel/1'],", - " asset_catalogs = ['assets.xcassets/foo'],", - ")", - "", - "ios_extension_binary(", - " name = 'ext_bin',", - " srcs = ['ebin.m'],", - " deps = [':res'],", - ")", - "", - "ios_extension(", - " name = 'ext',", - " binary = ':ext_bin',", - ")", - "", - "objc_binary(", - " name = 'bin',", - " srcs = ['bin.m'],", - " deps = [':res'],", - ")", - "", - "ios_application(", - " name = 'app',", - " binary = ':bin',", - " extensions = [':ext'],", - ")"); - - Action appIpaAction = bundleMergeAction("//x:app"); - - Action extIpaAction = bundleMergeAction("//x:ext"); - - Artifact appNibZip = Iterables.getOnlyElement(inputsEndingWith(appIpaAction, "nib.zip")); - Artifact extNibZip = Iterables.getOnlyElement(inputsEndingWith(extIpaAction, "nib.zip")); - assertThat(appNibZip.getExecPath()).isNotEqualTo(extNibZip.getExecPath()); - - Artifact appStoryboardZip = - Iterables.getOnlyElement(inputsEndingWith(appIpaAction, "story.storyboard.zip")); - Artifact extStoryboardZip = - Iterables.getOnlyElement(inputsEndingWith(extIpaAction, "story.storyboard.zip")); - assertThat(appStoryboardZip.getExecPath()).isNotEqualTo(extStoryboardZip.getExecPath()); - - Artifact appDatamodelZip = Iterables.getOnlyElement(inputsEndingWith(appIpaAction, "data.zip")); - Artifact extDatamodelZip = Iterables.getOnlyElement(inputsEndingWith(extIpaAction, "data.zip")); - assertThat(appDatamodelZip.getExecPath()).isNotEqualTo(extDatamodelZip.getExecPath()); - - Artifact appAssetZip = Iterables.getOnlyElement(inputsEndingWith(appIpaAction, "actool.zip")); - Artifact extAssetZip = Iterables.getOnlyElement(inputsEndingWith(extIpaAction, "actool.zip")); - assertThat(appAssetZip.getExecPath()).isNotEqualTo(extAssetZip.getExecPath()); - } - - @Test - public void testMultiCpuCompiledResources() throws Exception { - checkMultiCpuCompiledResources(RULE_TYPE_PAIR); - } - - @Test - public void testMomczipActions() throws Exception { - checkMomczipActions(RULE_TYPE_PAIR, DEFAULT_IOS_SDK_VERSION); - } - - @Test - public void testConvertStringsActions() throws Exception { - checkConvertStringsAction(RULE_TYPE_PAIR); - } - - @Test - public void testCompileXibActions() throws Exception { - checkCompileXibActions(RULE_TYPE_PAIR, DEFAULT_IOS_SDK_VERSION, "iphone"); - } - - @Test - public void testRegistersStoryboardCompileActions() throws Exception { - checkRegistersStoryboardCompileActions(RULE_TYPE_PAIR, DEFAULT_IOS_SDK_VERSION, "iphone"); - } - - @Test - public void testMultiCpuCompiledResourcesFromGenrule() throws Exception { - checkMultiCpuCompiledResourcesFromGenrule(RULE_TYPE_PAIR); - } - - @Test - public void testMultiCpuGeneratedResourcesFromGenrule() throws Exception { - checkMultiCpuGeneratedResourcesFromGenrule(RULE_TYPE_PAIR); - } - - @Test - public void testTwoStringsOneBundlePath() throws Exception { - //TODO(bazel-team): This error should be on //x:x but shows up on :bin right now until that - // doesn't support bundling anymore. - checkTwoStringsOneBundlePath(RULE_TYPE_PAIR, "bin"); - } - - @Test - public void testTwoResourcesOneBundlePath() throws Exception { - //TODO(bazel-team): This error should be on //x:x but shows up on :bin right now until that - // doesn't support bundling anymore. - checkTwoResourcesOneBundlePath(RULE_TYPE_PAIR, "bin"); - } - - @Test - public void testSameStringsTwice() throws Exception { - //TODO(bazel-team): This error should be on //x:x but shows up on :bin right now until that - // doesn't support bundling anymore. - checkSameStringsTwice(RULE_TYPE_PAIR, "bin"); - } - - @Test - public void testGenruleWithoutJavaCcDeps() throws Exception { - checkGenruleWithoutJavaCcDependency(RULE_TYPE_PAIR); - } - - @Test - public void testCcDependencyWithProtoDependencyMultiArch() throws Exception { - checkCcDependencyWithProtoDependencyMultiArch( - RULE_TYPE_PAIR, ConfigurationDistinguisher.IOS_APPLICATION); - } - - @Test - public void testAppleSdkVersionEnv() throws Exception { - RULE_TYPE_PAIR.scratchTargets(scratch); - - useConfiguration("--ios_multi_cpus=x86_64,i386"); - SpawnAction action = (SpawnAction) getGeneratingAction( - getBinArtifact("x_lipobin", getConfiguredTarget("//x:x"))); - - assertAppleSdkVersionEnv(action); - } - - @Test - public void testNonDefaultAppleSdkVersionEnv() throws Exception { - RULE_TYPE_PAIR.scratchTargets(scratch); - - useConfiguration("--ios_sdk_version=8.1", "--ios_multi_cpus=x86_64,i386"); - SpawnAction action = (SpawnAction) getGeneratingAction( - getBinArtifact("x_lipobin", getConfiguredTarget("//x:x"))); - - assertAppleSdkVersionEnv(action, "8.1"); - } - - @Test - public void testAppleSdkDefaultPlatformEnv() throws Exception { - RULE_TYPE_PAIR.scratchTargets(scratch); - - useConfiguration("--ios_multi_cpus=x86_64,i386"); - SpawnAction action = (SpawnAction) getGeneratingAction( - getBinArtifact("x_lipobin", getConfiguredTarget("//x:x"))); - - assertAppleSdkPlatformEnv(action, "iPhoneSimulator"); - } - - @Test - public void testAppleSdkDevicePlatformEnv() throws Exception { - RULE_TYPE_PAIR.scratchTargets(scratch); - - useConfiguration("--ios_multi_cpus=arm64,armv7"); - SpawnAction action = (SpawnAction) getGeneratingAction( - getBinArtifact("x_lipobin", getConfiguredTarget("//x:x"))); - - assertAppleSdkPlatformEnv(action, "iPhoneOS"); - } - - @Test - public void testXcodeVersionEnv() throws Exception { - RULE_TYPE_PAIR.scratchTargets(scratch); - - useConfiguration("--xcode_version=5.8", "--ios_multi_cpus=x86_64,i386"); - SpawnAction action = (SpawnAction) getGeneratingAction( - getBinArtifact("x_lipobin", getConfiguredTarget("//x:x"))); - - assertXcodeVersionEnv(action, "5.8"); - } - - @Test - public void testLaunchStoryboardIncluded() throws Exception { - checkLaunchStoryboardIncluded(RULE_TYPE_PAIR); - } - - @Test - public void testLaunchStoryboardXibIncluded() throws Exception { - checkLaunchStoryboardXib(RULE_TYPE_PAIR); - } - - @Test - public void testLaunchStoryboardLproj() throws Exception { - checkLaunchStoryboardLproj(RULE_TYPE_PAIR); - } - - @Test - public void testAutomaticPlistEntries() throws Exception { - checkAutomaticPlistEntries(RULE_TYPE); - } - - @Test - public void testBundleMergeInputContainsPlMergeOutput() throws Exception { - checkBundleMergeInputContainsPlMergeOutput(RULE_TYPE); - } - - @Test - public void testMultipleInfoPlists() throws Exception { - checkMultipleInfoPlists(RULE_TYPE); - } - - @Test - public void testInfoplistAndInfoplistsTogether() throws Exception { - checkInfoplistAndInfoplistsTogether(RULE_TYPE); - } - - @Test - public void testLateLoadedObjcFrameworkInFinalBundle() throws Exception { - scratch.file("x/Foo.framework/Foo"); - scratch.file("x/Foo.framework/Info.plist"); - scratch.file("x/Foo.framework/Headers/Foo.h"); - scratch.file("x/Foo.framework/Resources/bar.png"); - scratch.file( - "x/BUILD", - "objc_framework(", - " name = 'foo_framework',", - " framework_imports = glob(['Foo.framework/**']),", - " is_dynamic = 1,", - ")", - "", - "objc_binary(", - " name = 'bin',", - " srcs = [ 'a.m' ],", - " runtime_deps = [ ':foo_framework' ],", - ")", - "", - "ios_application(", - " name = 'x',", - " binary = ':bin',", - ")"); - - BundleMergeProtos.Control mergeControl = bundleMergeControl("//x:x"); - - assertThat(mergeControl.getBundleFileList()) - .containsAllOf( - BundleFile.newBuilder() - .setBundlePath("Frameworks/Foo.framework/Foo") - .setSourceFile(getSourceArtifact("x/Foo.framework/Foo").getExecPathString()) - .setExternalFileAttribute(BundleableFile.EXECUTABLE_EXTERNAL_FILE_ATTRIBUTE) - .build(), - BundleFile.newBuilder() - .setBundlePath("Frameworks/Foo.framework/Info.plist") - .setSourceFile(getSourceArtifact("x/Foo.framework/Info.plist").getExecPathString()) - .setExternalFileAttribute(BundleableFile.EXECUTABLE_EXTERNAL_FILE_ATTRIBUTE) - .build(), - BundleFile.newBuilder() - .setBundlePath("Frameworks/Foo.framework/Resources/bar.png") - .setSourceFile( - getSourceArtifact("x/Foo.framework/Resources/bar.png").getExecPathString()) - .setExternalFileAttribute(BundleableFile.DEFAULT_EXTERNAL_FILE_ATTRIBUTE) - .build()); - - assertThat(mergeControl.getBundleFileList()) - .doesNotContain( - BundleFile.newBuilder() - .setBundlePath("Frameworks/Foo.framework/Headers/Foo.h") - .setSourceFile( - getSourceArtifact("x/Foo.framework/Headers/Foo.h").getExecPathString()) - .setExternalFileAttribute(BundleableFile.DEFAULT_EXTERNAL_FILE_ATTRIBUTE) - .build()); - } - - @Test - public void testLateloadedObjcFrameworkSigned() throws Exception { - useConfiguration("--cpu=ios_arm64"); - - scratch.file("x/Foo.framework/Foo"); - scratch.file("x/Foo.framework/Info.plist"); - scratch.file("x/Foo.framework/Headers/Foo.h"); - scratch.file("x/Foo.framework/Resources/bar.png"); - scratch.file( - "x/BUILD", - "objc_framework(", - " name = 'foo_framework',", - " framework_imports = glob(['Foo.framework/**']),", - " is_dynamic = 1,", - ")", - "", - "objc_binary(", - " name = 'bin',", - " srcs = [ 'a.m' ],", - " runtime_deps = [ ':foo_framework' ],", - ")", - "", - "ios_application(", - " name = 'x',", - " binary = ':bin',", - ")"); - - SpawnAction signingAction = (SpawnAction) ipaGeneratingAction(); - - assertThat(normalizeBashArgs(signingAction.getArguments())) - .containsAllOf("--sign", "${t}/Payload/x.app/Frameworks/*", "--sign", "${t}/Payload/x.app") - .inOrder(); - } - - @Test - public void aspectOnSplitAttributeRegressionTest() throws Exception { - useConfiguration("--ios_multi_cpus=armv7,arm64"); - scratch.file("x/a.m"); - scratch.file("x/x-Info.plist"); - scratch.file( - "x/extension.bzl", - "def _my_aspect_impl(target, ctx):", - " if type(ctx.rule.attr.binary) != 'list':", - " fail('Expected a list for split')", - " if len(ctx.rule.attr.binary) != 2:", - " fail('Expected 2 items in split')", - " return struct()", - "my_aspect = aspect(_my_aspect_impl)", - "def _my_rule_impl(ctx):", - " pass", - "my_rule = rule(_my_rule_impl, attrs = { 'deps' : attr.label_list(aspects = [my_aspect]) })" - ); - scratch.file("x/BUILD", - "load(':extension.bzl', 'my_rule')", - "objc_binary(name = 'bin', srcs = ['a.m'], )", - "ios_application(name = 'x', binary = ':bin',)", - "my_rule(name = 'y', deps = [ ':x' ])" - ); - getConfiguredTarget("//x:y"); - } - - @Test - public void aspectOnSplitAttributeNoSplitRegressionTest() throws Exception { - useConfiguration("--ios_multi_cpus=arm64"); - scratch.file("x/a.m"); - scratch.file("x/x-Info.plist"); - scratch.file( - "x/extension.bzl", - "def _my_aspect_impl(target, ctx):", - " if type(ctx.rule.attr.binary) != 'list':", - " fail('Expected a list for split')", - " if len(ctx.rule.attr.binary) != 1:", - " fail('Expected 1 items in split')", - " return struct()", - "my_aspect = aspect(_my_aspect_impl)", - "def _my_rule_impl(ctx):", - " pass", - "my_rule = rule(_my_rule_impl, attrs = { 'deps' : attr.label_list(aspects = [my_aspect]) })" - ); - scratch.file("x/BUILD", - "load(':extension.bzl', 'my_rule')", - "objc_binary(name = 'bin', srcs = ['a.m'], )", - "ios_application(name = 'x', binary = ':bin',)", - "my_rule(name = 'y', deps = [ ':x' ])" - ); - getConfiguredTarget("//x:y"); - } - - @Test - public void testMergeBundleActionsWithNestedBundle() throws Exception { - checkMergeBundleActionsWithNestedBundle(RULE_TYPE_PAIR, targetConfig); - } - - @Test - public void testIncludesStoryboardOutputZipsAsMergeZips() throws Exception { - checkIncludesStoryboardOutputZipsAsMergeZips(RULE_TYPE_PAIR, targetConfig); - } - - @Test - public void testCcDependency() throws Exception { - checkCcDependency(RULE_TYPE_PAIR, ConfigurationDistinguisher.IOS_APPLICATION); - } - - @Test - public void testCcDependencyMultiArch() throws Exception { - checkCcDependencyMultiArch(RULE_TYPE_PAIR, ConfigurationDistinguisher.IOS_APPLICATION); - } - - @Test - public void testCCDependencyWithProtoDependency() throws Exception { - checkCcDependencyWithProtoDependency( - RULE_TYPE_PAIR, ConfigurationDistinguisher.IOS_APPLICATION); - } - - @Test - public void testCcDependencyAndJ2objcDependency() throws Exception { - checkCcDependencyAndJ2objcDependency( - RULE_TYPE_PAIR, ConfigurationDistinguisher.IOS_APPLICATION); - } - - @Test - public void testApplicationExtension() throws Exception { - // Including minimum OS version to trigger a special code path in extension split transitions - // which have a higher chance of conflicting with application transitions. See flag - // --DO_NOT_USE_configuration_distinguisher for details. - useConfiguration("--ios_multi_cpus=i386,x86_64", "--ios_minimum_os=8.1"); - DottedVersion minOsString = DottedVersion.fromString("8.1"); - scratch.file( - "x/BUILD", - "ios_extension_binary(", - " name = 'ext_bin',", - " srcs = ['ebin.m'],", - ")", - "", - "ios_extension(", - " name = 'ext',", - " binary = ':ext_bin',", - ")", - "", - "objc_binary(", - " name = 'bin',", - " srcs = ['bin.m'],", - ")", - "", - "ios_application(", - " name = 'app',", - " binary = ':bin',", - " extensions = [':ext'],", - ")"); - - SpawnAction appLipoAction = - (SpawnAction) - getGeneratingAction( - getBinArtifact( - "app_lipobin", getConfiguredTarget("//x:app", getTargetConfiguration()))); - - assertThat(Artifact.toExecPaths(appLipoAction.getInputs())) - .containsExactly( - configurationBin("i386", ConfigurationDistinguisher.IOS_APPLICATION, minOsString) - + "x/bin_bin", - configurationBin("x86_64", ConfigurationDistinguisher.IOS_APPLICATION, minOsString) - + "x/bin_bin", - MOCK_XCRUNWRAPPER_PATH); - - SpawnAction extLipoAction = - (SpawnAction) - getGeneratingAction( - getBinArtifact( - "ext_lipobin", getConfiguredTarget("//x:ext", getTargetConfiguration()))); - - assertThat(Artifact.toExecPaths(extLipoAction.getInputs())) - .containsExactly( - configurationBin("i386", ConfigurationDistinguisher.IOS_EXTENSION, minOsString) - + "x/ext_bin_bin", - configurationBin("x86_64", ConfigurationDistinguisher.IOS_EXTENSION, minOsString) - + "x/ext_bin_bin", MOCK_XCRUNWRAPPER_PATH); - } - - @Test - public void testGenruleDependency() throws Exception { - checkGenruleDependency(RULE_TYPE_PAIR); - } - - @Test - public void testGenruleDependencyMultiArch() throws Exception { - checkGenruleDependencyMultiArch(RULE_TYPE_PAIR, ConfigurationDistinguisher.IOS_APPLICATION); - } - - @Test - public void testTargetHasCpuSpecificDsymFiles() throws Exception { - checkTargetHasCpuSpecificDsymFiles(RULE_TYPE); - } - - @Test - public void testTargetHasDsymPlist() throws Exception { - checkTargetHasDsymPlist(RULE_TYPE); - } - - @Test - public void testMultiArchitectureFanOut() throws Exception { - checkBinaryLipoActionMultiCpu(RULE_TYPE_PAIR, ConfigurationDistinguisher.IOS_APPLICATION); - } - - @Test - public void testMultiArchitectureWithConfigurableAttribute() throws Exception { - useConfiguration("--ios_multi_cpus=armv7,arm64", "--cpu=ios_i386"); - scratch.file( - "x/BUILD", - "config_setting(", - " name = 'i386',", - " values = {'cpu': 'ios_i386'},", - ")", - "", - "config_setting(", - " name = 'armv7',", - " values = {'cpu': 'ios_armv7'},", - ")", - "", - "objc_library(", - " name = 'libi386',", - " srcs = ['i386.m'],", - ")", - "", - "objc_library(", - " name = 'libarmv7',", - " srcs = ['armv7.m'],", - ")", - "", - "objc_library(", - " name = 'libdefault',", - " srcs = ['default.m'],", - ")", - "", - "objc_binary(", - " name = 'bin',", - " srcs = ['bin.m'],", - " deps = select({", - " ':i386': [':libi386'],", - " ':armv7': [':libarmv7'],", - " '//conditions:default': [':libdefault'],", - " }),", - ")", - "", - "ios_application(", - " name = 'app',", - " binary = ':bin',", - ")"); - - CommandAction appLipoAction = - (CommandAction) - getGeneratingAction( - getBinArtifact( - "app_lipobin", getConfiguredTarget("//x:app", getTargetConfiguration()))); - - assertThat(Artifact.toExecPaths(appLipoAction.getInputs())) - .containsExactly( - configurationBin("armv7", ConfigurationDistinguisher.IOS_APPLICATION) + "x/bin_bin", - configurationBin("arm64", ConfigurationDistinguisher.IOS_APPLICATION) + "x/bin_bin", - MOCK_XCRUNWRAPPER_PATH); - - ImmutableSet.Builder<Artifact> binInputs = ImmutableSet.builder(); - for (Artifact bin : appLipoAction.getInputs()) { - CommandAction binAction = (CommandAction) getGeneratingAction(bin); - if (binAction != null) { - binInputs.addAll(binAction.getInputs()); - } - } - - assertThat(Artifact.toExecPaths(binInputs.build())) - .containsAllOf( - configurationBin("armv7", ConfigurationDistinguisher.IOS_APPLICATION) - + "x/liblibarmv7.a", - configurationBin("arm64", ConfigurationDistinguisher.IOS_APPLICATION) - + "x/liblibdefault.a"); - - assertThat(Artifact.toExecPaths(binInputs.build())) - .doesNotContain( - configurationBin("i386", ConfigurationDistinguisher.IOS_APPLICATION) - + "x/liblibi386.a"); - } -} diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/IosExtensionBinaryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/IosExtensionBinaryTest.java deleted file mode 100644 index 44744a7092..0000000000 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/IosExtensionBinaryTest.java +++ /dev/null @@ -1,252 +0,0 @@ -// 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 static com.google.devtools.build.lib.rules.objc.BinaryLinkingTargetFactory.REQUIRES_AT_LEAST_ONE_LIBRARY_OR_SOURCE_FILE; -import static com.google.devtools.build.lib.rules.objc.ObjcProvider.ASSET_CATALOG; - -import com.google.devtools.build.lib.actions.Artifact; -import com.google.devtools.build.lib.analysis.ConfiguredTarget; -import com.google.devtools.build.lib.analysis.RunfilesProvider; -import com.google.devtools.build.lib.analysis.config.CompilationMode; -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.objc.CompilationSupport.ExtraLinkArgs; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Test case for ios_extension_binary. */ -@RunWith(JUnit4.class) -@LegacyTest -public class IosExtensionBinaryTest extends ObjcRuleTestCase { - static final RuleType RULE_TYPE = new OnlyNeedsSourcesRuleType("ios_extension_binary"); - protected static final ExtraLinkArgs EXTRA_LINK_ARGS = - new ExtraLinkArgs("-e", "_NSExtensionMain", "-fapplication-extension"); - - @Before - public final void initializeToolsConfigMock() throws Exception { - MockProtoSupport.setup(mockToolsConfig); - MockObjcSupport.setup(mockToolsConfig); - } - - @Test - public void testCreate_runfiles() throws Exception { - scratch.file("x/a.m"); - RULE_TYPE.scratchTarget(scratch, "srcs", "['a.m']"); - ConfiguredTarget binary = getConfiguredTarget("//x:x"); - RunfilesProvider runfiles = binary.getProvider(RunfilesProvider.class); - assertThat(runfiles.getDefaultRunfiles().getArtifacts()).isEmpty(); - assertThat(Artifact.toRootRelativePaths(runfiles.getDataRunfiles().getArtifacts())) - .containsExactly("x/x_bin"); - } - - @Test - public void testCreate_errorForNoSourceOrDep() throws Exception { - checkError("x", "x", REQUIRES_AT_LEAST_ONE_LIBRARY_OR_SOURCE_FILE, - "ios_extension_binary(name='x')"); - } - - @Test - public void testCompileWithDotMFileInHeaders() throws Exception { - checkCompileWithDotMFileInHeaders(RULE_TYPE); - } - - @Test - public void testObjcProviderExportsAssetCatalogs() throws Exception { - scratch.file("x/BUILD", - "ios_extension_binary(", - " name = 'x',", - " srcs = ['a.m'],", - " asset_catalogs = ['foo.xcassets/bar', 'foo.xcassets/baz'],", - ")"); - ObjcProvider provider = providerForTarget("//x:x"); - assertThat(provider.get(ASSET_CATALOG)) - .containsExactly( - getSourceArtifact("x/foo.xcassets/bar"), - getSourceArtifact("x/foo.xcassets/baz")); - } - - @Test - public void testLinksFrameworksOfSelfAndTransitiveDependencies() throws Exception { - checkLinksFrameworksOfSelfAndTransitiveDependencies(RULE_TYPE); - } - - @Test - public void testLinksWeakFrameworksOfSelfAndTransitiveDependencies() throws Exception { - checkLinksWeakFrameworksOfSelfAndTransitiveDependencies(RULE_TYPE); - } - - @Test - public void testLinksDylibsTransitively() throws Exception { - checkLinksDylibsTransitively(RULE_TYPE); - } - - @Test - public void testPopulatesCompilationArtifacts() throws Exception { - checkPopulatesCompilationArtifacts(RULE_TYPE); - } - - @Test - public void testArchivesPrecompiledObjectFiles() throws Exception { - checkArchivesPrecompiledObjectFiles(RULE_TYPE); - } - - @Test - public void testErrorsWrongFileTypeForSrcsWhenCompiling() throws Exception { - checkErrorsWrongFileTypeForSrcsWhenCompiling(RULE_TYPE); - } - - @Test - public void testObjcCopts() throws Exception { - checkObjcCopts(RULE_TYPE); - } - - @Test - public void testObjcCopts_argumentOrdering() throws Exception { - checkObjcCopts_argumentOrdering(RULE_TYPE); - } - - @Test - public void testAllowVariousNonBlacklistedTypesInHeaders() throws Exception { - checkAllowVariousNonBlacklistedTypesInHeaders(RULE_TYPE); - } - - @Test - public void testWarningForBlacklistedTypesInHeaders() throws Exception { - checkWarningForBlacklistedTypesInHeaders(RULE_TYPE); - } - - @Test - public void testCppSourceCompilesWithCppFlags() throws Exception { - checkCppSourceCompilesWithCppFlags(RULE_TYPE); - } - - @Test - public void testLinkOpts() throws Exception { - checkLinkopts(RULE_TYPE); - } - - @Test - public void testProtoBundlingAndLinking() throws Exception { - checkProtoBundlingAndLinking(RULE_TYPE); - } - - @Test - public void testProtoBundlingWithTargetsWithNoDeps() throws Exception { - checkProtoBundlingWithTargetsWithNoDeps(RULE_TYPE); - } - - @Test - public void testLinkingRuleCanUseCrosstool() throws Exception { - checkLinkingRuleCanUseCrosstool(RULE_TYPE); - } - - @Test - public void testBinaryStrippings() throws Exception { - checkBinaryStripAction(RULE_TYPE); - } - - @Test - public void testCompilationActionsForDebug() throws Exception { - checkClangCoptsForCompilationMode(RULE_TYPE, CompilationMode.DBG, CodeCoverageMode.NONE); - } - - @Test - public void testCompilationActionsForOptimized() throws Exception { - checkClangCoptsForCompilationMode(RULE_TYPE, CompilationMode.OPT, CodeCoverageMode.NONE); - } - - @Test - public void testClangCoptsForDebugModeWithoutGlib() throws Exception { - checkClangCoptsForDebugModeWithoutGlib(RULE_TYPE); - } - - @Test - public void testLinkActionCorrect() throws Exception { - checkLinkActionCorrect(RULE_TYPE, EXTRA_LINK_ARGS); - } - - @Test - public void testFrameworkDepLinkFlags() throws Exception { - checkFrameworkDepLinkFlags(RULE_TYPE, EXTRA_LINK_ARGS); - } - - @Test - public void testCompilationActionsForDebugInGcovCoverage() throws Exception { - checkClangCoptsForCompilationMode(RULE_TYPE, CompilationMode.DBG, - CodeCoverageMode.GCOV); - } - - @Test - public void testCompilationActionsForDebugInLlvmCovCoverage() throws Exception { - checkClangCoptsForCompilationMode(RULE_TYPE, CompilationMode.DBG, - CodeCoverageMode.LLVMCOV); - } - - @Test - public void testCompilationActionsForOptimizedInGcovCoverage() throws Exception { - checkClangCoptsForCompilationMode(RULE_TYPE, CompilationMode.OPT, - CodeCoverageMode.GCOV); - } - - @Test - public void testCompilationActionsForOptimizedInLlvmCovCoverage() throws Exception { - checkClangCoptsForCompilationMode(RULE_TYPE, CompilationMode.OPT, - CodeCoverageMode.LLVMCOV); - } - - @Test - public void testCompileWithTextualHeaders() throws Exception { - checkCompileWithTextualHeaders(RULE_TYPE); - } - - @Test - public void testCompilesWithHdrs() throws Exception { - checkCompilesWithHdrs(RULE_TYPE); - } - - @Test - public void testCompilesSources() throws Exception { - checkCompilesSources(RULE_TYPE); - } - - @Test - public void testLinkActionWithTransitiveCppDependency() throws Exception { - checkLinkActionWithTransitiveCppDependency(RULE_TYPE, EXTRA_LINK_ARGS); - } - - @Test - public void testLinkWithFrameworkImportsIncludesFlagsAndInputArtifacts() throws Exception { - checkLinkWithFrameworkImportsIncludesFlagsAndInputArtifacts(RULE_TYPE); - } - - @Test - public void testForceLoadsAlwayslinkTargets() throws Exception { - checkForceLoadsAlwayslinkTargets(RULE_TYPE, EXTRA_LINK_ARGS); - } - - @Test - public void testReceivesTransitivelyPropagatedDefines() throws Exception { - checkReceivesTransitivelyPropagatedDefines(RULE_TYPE); - } - - @Test - public void testSdkIncludesUsedInCompileAction() throws Exception { - checkSdkIncludesUsedInCompileAction(RULE_TYPE); - } -} diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/IosExtensionTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/IosExtensionTest.java deleted file mode 100644 index 5045ccd1a8..0000000000 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/IosExtensionTest.java +++ /dev/null @@ -1,641 +0,0 @@ -// 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 static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.ReleaseBundlingRule.APP_ICON_ATTR; -import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.ReleaseBundlingRule.LAUNCH_IMAGE_ATTR; - -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableListMultimap; -import com.google.common.collect.ImmutableMultiset; -import com.google.common.collect.ImmutableSetMultimap; -import com.google.common.collect.Iterables; -import com.google.common.collect.Multiset; -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.CommandLineExpansionException; -import com.google.devtools.build.lib.analysis.ConfiguredTarget; -import com.google.devtools.build.lib.analysis.config.BuildConfiguration; -import com.google.devtools.build.lib.rules.apple.AppleConfiguration.ConfigurationDistinguisher; -import com.google.devtools.build.lib.rules.apple.DottedVersion; -import com.google.devtools.build.lib.testutil.Scratch; -import com.google.devtools.build.xcode.bundlemerge.proto.BundleMergeProtos; -import com.google.devtools.build.xcode.bundlemerge.proto.BundleMergeProtos.BundleFile; -import java.io.IOException; -import java.util.List; -import java.util.Set; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Test case for ios_extension. */ -@RunWith(JUnit4.class) -@LegacyTest -public class IosExtensionTest extends ObjcRuleTestCase { - protected static final RuleType RULE_TYPE = - new RuleType("ios_extension") { - @Override - Iterable<String> requiredAttributes( - Scratch scratch, String packageDir, Set<String> alreadyAdded) throws IOException { - ImmutableList.Builder<String> attributes = new ImmutableList.Builder<>(); - if (!alreadyAdded.contains("binary")) { - scratch.file(packageDir + "/extension_binary/a.m"); - scratch.file( - packageDir + "/extension_binary/BUILD", - "ios_extension_binary(", - " name = 'extension_binary',", - " srcs = ['a.m'],", - ")"); - attributes.add(String.format("binary = '//%s/extension_binary'", packageDir)); - } - return attributes.build(); - } - }; - - protected static final BinaryRuleTypePair RULE_TYPE_PAIR = - new BinaryRuleTypePair( - IosExtensionBinaryTest.RULE_TYPE, - RULE_TYPE, - ReleaseBundlingSupport.EXTENSION_BUNDLE_DIR_FORMAT); - - private ConfiguredTarget addMockExtensionAndLibs(String... extraExtAttributes) - throws Exception { - createLibraryTargetWriter("//lib1:lib1") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "hdr.h") - .write(); - createLibraryTargetWriter("//lib2:lib2") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "hdr.h") - .write(); - scratch.file("x/a.m"); - scratch.file("x/BUILD", - "ios_extension_binary(", - " name = 'bin',", - " srcs = ['a.m'],", - " deps = ['//lib1:lib1', '//lib2:lib2'],", - ")", - "", - "ios_extension(", - " name = 'x',", - " binary = ':bin',", - Joiner.on(',').join(extraExtAttributes), - ")"); - return getConfiguredTarget("//x:x"); - } - - @Test - public void testSigningAction() throws Exception { - checkDeviceSigningAction(RULE_TYPE); - } - - @Test - public void testSigningWithCertName() throws Exception { - checkSigningWithCertName(RULE_TYPE); - } - - @Test - public void testPostProcessingAction() throws Exception { - checkPostProcessingAction(RULE_TYPE); - } - - @Test - public void testSigningAndPostProcessing() throws Exception { - checkSigningAndPostProcessing(RULE_TYPE); - } - - @Test - public void testSigning_simulatorBuild() throws Exception { - checkSigningSimulatorBuild(RULE_TYPE_PAIR, false); - } - - @Test - public void testSigning_simulatorBuild_multiCpu() throws Exception { - checkSigningSimulatorBuild(RULE_TYPE_PAIR, true); - } - - @Test - public void testProvisioningProfile_deviceBuild() throws Exception { - checkProvisioningProfileDeviceBuild(RULE_TYPE_PAIR, false); - } - - @Test - public void testProvisioningProfile_deviceBuild_multiCpu() throws Exception { - checkProvisioningProfileDeviceBuild(RULE_TYPE_PAIR, true); - } - - @Test - public void testUserSpecifiedProvisioningProfile_deviceBuild() throws Exception { - checkProvisioningProfileUserSpecified(RULE_TYPE_PAIR, false); - } - - @Test - public void testUserSpecifiedProvisioningProfile_deviceBuild_multiCpu() throws Exception { - checkProvisioningProfileUserSpecified(RULE_TYPE_PAIR, true); - } - - @Test - public void testMergeControlAction() throws Exception { - addMockExtensionAndLibs("infoplist = 'Info.plist'"); - Action mergeAction = bundleMergeAction("//x:x"); - Action action = bundleMergeControlAction("//x:x"); - assertThat(action.getInputs()).isEmpty(); - assertThat(Artifact.toRootRelativePaths(action.getOutputs())).containsExactly( - "x/x.ipa-control"); - assertThat(bundleMergeControl("//x:x")) - .isEqualTo( - BundleMergeProtos.Control.newBuilder() - .addBundleFile( - BundleFile.newBuilder() - .setSourceFile(execPathEndingWith(mergeAction.getInputs(), "x_lipobin")) - .setBundlePath("x") - .setExternalFileAttribute(BundleableFile.EXECUTABLE_EXTERNAL_FILE_ATTRIBUTE) - .build()) - .setBundleRoot("PlugIns/x.appex") - .setBundleInfoPlistFile( - getMergedInfoPlist(getConfiguredTarget("//x:x")).getExecPathString()) - .setOutFile(execPathEndingWith(mergeAction.getOutputs(), "x.unprocessed.ipa")) - .setMinimumOsVersion(DEFAULT_IOS_SDK_VERSION.toString()) - .setSdkVersion(DEFAULT_IOS_SDK_VERSION.toString()) - .setPlatform("IOS_SIMULATOR") - .setFallbackBundleIdentifier("example.x") - .build()); - } - - @Test - public void testMergeBundleAction() throws Exception { - checkMergeBundleAction(RULE_TYPE_PAIR); - } - - protected List<BuildConfiguration> getExtensionConfigurations() throws InterruptedException { - return getSplitConfigurations(getTargetConfiguration(), - IosExtension.MINIMUM_OS_AND_SPLIT_ARCH_TRANSITION); - } - - @Test - public void testErrorForLaunchImageGivenWithNoAssetCatalog() throws Exception { - checkAssetCatalogAttributeError(RULE_TYPE, LAUNCH_IMAGE_ATTR); - } - - @Test - public void testErrorForAppIconGivenWithNoAssetCatalog() throws Exception { - checkAssetCatalogAttributeError(RULE_TYPE, APP_ICON_ATTR); - } - - @Test - public void testCollectsAssetCatalogsTransitively() throws Exception { - checkCollectsAssetCatalogsTransitively(RULE_TYPE_PAIR); - } - - @Test - public void testSpecifyAppIconAndLaunchImageUsingXcassetsOfDependency() throws Exception { - checkSpecifyAppIconAndLaunchImageUsingXcassetsOfDependency( - RULE_TYPE_PAIR, DEFAULT_IOS_SDK_VERSION); - } - - private void addTargetWithAssetCatalogs() throws IOException { - scratch.file("x/foo.xcassets/foo"); - scratch.file("x/foo.xcassets/bar"); - scratch.file("x/a.m"); - scratch.file("x/BUILD", - "ios_extension_binary(", - " name = 'bin',", - " asset_catalogs = ['foo.xcassets/foo', 'bar.xcassets/bar'],", - " srcs = ['a.m'],", - ")", - "", - "ios_extension(", - " name = 'x',", - " binary = ':bin',", - ")"); - } - - @Test - public void testActoolActionCorrectness() throws Exception { - addTargetWithAssetCatalogs(); - checkActoolActionCorrectness(DEFAULT_IOS_SDK_VERSION); - } - - @Test - public void testPassesFamiliesToActool() throws Exception { - checkPassesFamiliesToActool(RULE_TYPE_PAIR); - } - - @Test - public void testPassesFamiliesToIbtool() throws Exception { - checkPassesFamiliesToIbtool(RULE_TYPE_PAIR); - } - - @Test - public void testReportsErrorsForInvalidFamiliesAttribute() throws Exception { - checkReportsErrorsForInvalidFamiliesAttribute(RULE_TYPE); - } - - @Test - public void testMergeActionsWithAssetCatalog() throws Exception { - addTargetWithAssetCatalogs(); - checkMergeActionsWithAssetCatalog(RULE_TYPE_PAIR); - } - - private void addBinAndLibWithRawResources() throws Exception { - addBinAndLibWithResources( - "resources", "resource1.txt", "ja.lproj/resource2.txt", "ios_extension_binary"); - scratch.file("x/BUILD", - "ios_extension(", - " name = 'x',", - " binary = '//bin:bin',", - ")"); - } - - private void addBinAndLibWithStrings() throws Exception { - addBinAndLibWithResources( - "strings", "foo.strings", "ja.lproj/bar.strings", "ios_extension_binary"); - scratch.file("x/BUILD", - "ios_extension(", - " name = 'x',", - " binary = '//bin:bin',", - ")"); - } - - @Test - public void testCollectsRawResourceFilesTransitively() throws Exception { - addBinAndLibWithRawResources(); - checkCollectsResourceFilesTransitively( - "//x:x", - ImmutableList.of("lib/resource1.txt", "bin/ja.lproj/resource2.txt"), - ImmutableList.of("lib/resource1.txt"), - ImmutableSetMultimap.<String, Multiset<String>>of( - "bin_bin", ImmutableMultiset.of("bin/ja.lproj/resource2.txt", "lib/resource1.txt"), - "x_x", ImmutableMultiset.of("bin/ja.lproj/resource2.txt", "lib/resource1.txt"), - "lib_lib", ImmutableMultiset.of("lib/resource1.txt"))); - } - - @Test - public void testCollectsStringsFilesTransitively() throws Exception { - addBinAndLibWithStrings(); - checkCollectsResourceFilesTransitively( - "//x:x", - ImmutableList.of("x/lib/foo.strings.binary", "x/bin/ja.lproj/bar.strings.binary"), - ImmutableList.of("lib/foo.strings.binary"), - ImmutableSetMultimap.<String, Multiset<String>>of( - "bin_bin", ImmutableMultiset.of("bin/ja.lproj/bar.strings", "lib/foo.strings"), - "x_x", ImmutableMultiset.of("bin/ja.lproj/bar.strings", "lib/foo.strings"), - "lib_lib", ImmutableMultiset.of("lib/foo.strings"))); - } - - @Test - public void testResourceFilesMergedInBundle() throws Exception { - addBinAndLibWithRawResources(); - checkBundleablesAreMerged("//x:x", - ImmutableListMultimap.of( - "resource1.txt", "resource1.txt", - "ja.lproj/resource2.txt", "ja.lproj/resource2.txt")); - } - - @Test - public void testStringsFilesMergedInBundle() throws Exception { - addBinAndLibWithStrings(); - checkBundleablesAreMerged("//x:x", - ImmutableListMultimap.of( - "foo.strings.binary", "foo.strings", - "ja.lproj/bar.strings.binary", "ja.lproj/bar.strings")); - } - - @Test - public void testMergesXcdatamodelZips() throws Exception { - checkMergesXcdatamodelZips(RULE_TYPE_PAIR); - } - - @Test - public void testPlistRequiresDotInName() throws Exception { - checkError("x", "x", - "'//x:Infoplist' does not produce any ios_extension infoplist files (expected .plist)", - "ios_extension_binary(", - " name = 'bin',", - " srcs = ['a.m'],", - ")", - "", - "ios_extension(", - " name = 'x',", - " infoplist = 'Infoplist',", - " binary = ':bin',", - ")"); - } - - @Test - public void testMergesPartialInfoplists() throws Exception { - checkMergesPartialInfoplists(RULE_TYPE_PAIR); - } - - @Test - public void testNibZipsMergedIntoBundle() throws Exception { - checkNibZipsMergedIntoBundle(RULE_TYPE_PAIR); - } - - @Test - public void testNoEntitlementsDefined() throws Exception { - checkNoEntitlementsDefined(RULE_TYPE); - } - - @Test - public void testEntitlementsDefined() throws Exception { - checkEntitlementsDefined(RULE_TYPE); - } - - @Test - public void testExtraEntitlements() throws Exception { - checkExtraEntitlements(RULE_TYPE); - } - - @Test - public void testDebugEntitlements() throws Exception { - checkDebugEntitlements(RULE_TYPE); - } - - @Test - public void testFastbuildDebugEntitlements() throws Exception { - checkFastbuildDebugEntitlements(RULE_TYPE); - } - - @Test - public void testOptNoDebugEntitlements() throws Exception { - checkOptNoDebugEntitlements(RULE_TYPE); - } - - @Test - public void testExplicitNoDebugEntitlements() throws Exception { - checkExplicitNoDebugEntitlements(RULE_TYPE); - } - - @Test - public void testPassesFallbackBundleIdToBundleMerging() throws Exception { - checkBundleIdPassedAsFallbackId(RULE_TYPE); - } - - @Test - public void testPassesPrimaryBundleIdToBundleMerging() throws Exception { - checkBundleIdPassedAsPrimaryId(RULE_TYPE); - } - - @Test - public void testMultiPlatformBuild_fails() throws Exception { - checkBinaryActionMultiPlatform_fails(RULE_TYPE_PAIR); - } - - @Test - public void testMultiArchitectureResources() throws Exception { - checkMultiCpuResourceInheritance(RULE_TYPE_PAIR); - } - - @Test - public void testMultiCpuCompiledResources() throws Exception { - checkMultiCpuCompiledResources(RULE_TYPE_PAIR); - } - - @Test - public void testMomczipActions() throws Exception { - checkMomczipActions(RULE_TYPE_PAIR, DEFAULT_IOS_SDK_VERSION); - } - - @Test - public void testConvertStringsActions() throws Exception { - checkConvertStringsAction(RULE_TYPE_PAIR); - } - - @Test - public void testCompileXibActions() throws Exception { - checkCompileXibActions(RULE_TYPE_PAIR, DEFAULT_IOS_SDK_VERSION, "iphone"); - } - - @Test - public void testRegistersStoryboardCompileActions() throws Exception { - checkRegistersStoryboardCompileActions( - RULE_TYPE_PAIR, DEFAULT_IOS_SDK_VERSION, "iphone"); - } - - @Test - public void testMultiCpuCompiledResourcesFromGenrule() throws Exception { - checkMultiCpuCompiledResourcesFromGenrule(RULE_TYPE_PAIR); - } - - @Test - public void testMultiCpuGeneratedResourcesFromGenrule() throws Exception { - checkMultiCpuGeneratedResourcesFromGenrule(RULE_TYPE_PAIR); - } - - @Test - public void testTwoStringsOneBundlePath() throws Exception { - checkTwoStringsOneBundlePath(RULE_TYPE_PAIR, "x"); - } - - @Test - public void testTwoResourcesOneBundlePath() throws Exception { - checkTwoResourcesOneBundlePath(RULE_TYPE_PAIR, "x"); - } - - @Test - public void testSameStringsTwice() throws Exception { - checkSameStringsTwice(RULE_TYPE_PAIR, "x"); - } - - @Test - public void testExtensionReplacesMinimumOsInBundleMerge() throws Exception { - useConfiguration("--ios_minimum_os=7.1"); - addMockExtensionAndLibs("infoplist = 'Info.plist'"); - - assertThat(bundleMergeControl("//x:x").getMinimumOsVersion()) - .isEqualTo(IosExtension.EXTENSION_MINIMUM_OS_VERSION.toString()); - } - - @Test - public void testExtensionReplacesMinimumOsVersionInBundleMergeAtMost80() throws Exception { - useConfiguration("--ios_minimum_os=8.1"); - addMockExtensionAndLibs("infoplist = 'Info.plist'"); - - assertThat(bundleMergeControl("//x:x").getMinimumOsVersion()) - .isEqualTo("8.1"); - } - - @Test - public void testCheckPrimaryBundleIdInMergedPlist() throws Exception { - checkPrimaryBundleIdInMergedPlist(RULE_TYPE_PAIR); - } - - @Test - public void testCheckFallbackBundleIdInMergedPlist() throws Exception { - checkFallbackBundleIdInMergedPlist(RULE_TYPE_PAIR); - } - - protected void checkExtensionReplacesMinimumOsInCompilation() throws Exception { - addMockExtensionAndLibs("infoplist = 'Info.plist'"); - - Action lipoAction = lipoBinAction("//x:x"); - - for (Artifact bin : lipoAction.getInputs()) { - CommandAction action = (CommandAction) getGeneratingAction(bin); - if (action == null) { - continue; - } - assertThat(generatingArgumentsToString(action)) - .contains("-mios-simulator-version-min=" + IosExtension.EXTENSION_MINIMUM_OS_VERSION); - assertThat(generatingArgumentsToString(action)) - .doesNotContain("-mios-simulator-version-min=7.1"); - } - } - - private String generatingArgumentsToString(CommandAction generatingAction) - throws CommandLineExpansionException { - return Joiner.on(' ').join(generatingAction.getArguments()); - } - - protected void checkExtensionDoesNotReplaceMinimumOsInCompilation() throws Exception { - addMockExtensionAndLibs("infoplist = 'Info.plist'"); - - Action lipoAction = lipoBinAction("//x:x"); - - for (Artifact bin : lipoAction.getInputs()) { - CommandAction action = (CommandAction) getGeneratingAction(bin); - if (action == null) { - continue; - } - assertThat(generatingArgumentsToString(action)).contains("-mios-simulator-version-min=8.1"); - assertThat(generatingArgumentsToString(action)) - .doesNotContain("-mios-simulator-version-min=" + DEFAULT_IOS_SDK_VERSION); - } - } - - @Test - public void testExtensionReplacesMinimumOsVersionInMomcZipAtMost80() throws Exception { - useConfiguration("--ios_minimum_os=8.1"); - checkMomczipActions(RULE_TYPE_PAIR, DottedVersion.fromString("8.1")); - } - - @Test - public void testGenruleWithoutJavaCcDeps() throws Exception { - checkGenruleWithoutJavaCcDependency(RULE_TYPE_PAIR); - } - - @Test - public void testCcDependencyWithProtoDependencyMultiArch() throws Exception { - checkCcDependencyWithProtoDependencyMultiArch( - RULE_TYPE_PAIR, ConfigurationDistinguisher.IOS_EXTENSION); - } - - @Test - public void testLaunchStoryboardIncluded() throws Exception { - checkLaunchStoryboardIncluded(RULE_TYPE_PAIR); - } - - @Test - public void testLaunchStoryboardXibIncluded() throws Exception { - checkLaunchStoryboardXib(RULE_TYPE_PAIR); - } - - @Test - public void testLaunchStoryboardLproj() throws Exception { - checkLaunchStoryboardLproj(RULE_TYPE_PAIR); - } - - @Test - public void testAutomaticPlistEntries() throws Exception { - checkAutomaticPlistEntries(RULE_TYPE); - } - - @Test - public void testBundleMergeInputContainsPlMergeOutput() throws Exception { - checkBundleMergeInputContainsPlMergeOutput(RULE_TYPE); - } - - @Test - public void testMergeBundleActionsWithNestedBundle() throws Exception { - BuildConfiguration extensionConfiguration = - Iterables.getOnlyElement(getExtensionConfigurations()); - checkMergeBundleActionsWithNestedBundle(RULE_TYPE_PAIR, extensionConfiguration); - } - - @Test - public void testIncludesStoryboardOutputZipsAsMergeZips() throws Exception { - BuildConfiguration extensionConfiguration = - Iterables.getOnlyElement(getExtensionConfigurations()); - checkIncludesStoryboardOutputZipsAsMergeZips(RULE_TYPE_PAIR, extensionConfiguration); - } - - @Test - public void testCcDependency() throws Exception { - checkCcDependency(RULE_TYPE_PAIR, ConfigurationDistinguisher.IOS_EXTENSION); - } - - @Test - public void testCcDependencyMultiArch() throws Exception { - checkCcDependencyMultiArch(RULE_TYPE_PAIR, ConfigurationDistinguisher.IOS_EXTENSION); - } - - @Test - public void testCcDependencyWithProtoDependency() throws Exception { - checkCcDependencyWithProtoDependency(RULE_TYPE_PAIR, ConfigurationDistinguisher.IOS_EXTENSION); - } - - @Test - public void testCcDependencyAndJ2objcDependency() throws Exception { - checkCcDependencyAndJ2objcDependency(RULE_TYPE_PAIR, ConfigurationDistinguisher.IOS_EXTENSION); - } - - @Test - public void testMultiArchitectureFanOut() throws Exception { - checkBinaryLipoActionMultiCpu(RULE_TYPE_PAIR, ConfigurationDistinguisher.IOS_EXTENSION); - } - - @Test - public void testTargetHasCpuSpecificDsymFiles() throws Exception { - checkTargetHasCpuSpecificDsymFiles(RULE_TYPE); - } - - @Test - public void testTargetHasDsymPlist() throws Exception { - checkTargetHasDsymPlist(RULE_TYPE); - } - - @Test - public void testGenruleDependencyMultiArch() throws Exception { - checkGenruleDependencyMultiArch(RULE_TYPE_PAIR, ConfigurationDistinguisher.IOS_EXTENSION); - } - - @Test - public void testExtensionReplacesMinimumOsInCompilation() throws Exception { - useConfiguration("--ios_minimum_os=7.1"); - checkExtensionReplacesMinimumOsInCompilation(); - } - - @Test - public void testExtensionReplacesMinimumOsInCompilationAtMost80() throws Exception { - useConfiguration("--ios_minimum_os=8.1"); - checkExtensionDoesNotReplaceMinimumOsInCompilation(); - } - - @Test - public void testExtensionReplacesMinimumOsInCompilationMultiArch() throws Exception { - useConfiguration("--ios_minimum_os=7.1", "--ios_multi_cpus=i386,x86_64"); - checkExtensionReplacesMinimumOsInCompilation(); - } - - @Test - public void testExtensionReplacesMinimumOsInCompilationAtMost80MultiArch() throws Exception { - useConfiguration("--ios_minimum_os=8.1", "--ios_multi_cpus=i386,x86_64"); - checkExtensionDoesNotReplaceMinimumOsInCompilation(); - } -} diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/IosTestTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/IosTestTest.java index f789de4ef1..05130bd7f6 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/IosTestTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/IosTestTest.java @@ -20,7 +20,6 @@ import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; -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.analysis.ConfiguredTarget; @@ -34,11 +33,8 @@ import com.google.devtools.build.lib.analysis.test.TestProvider; import com.google.devtools.build.lib.analysis.test.TestRunnerAction; 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.rules.apple.AppleToolchain; import com.google.devtools.build.lib.rules.apple.XcodeVersionProperties; import com.google.devtools.build.lib.rules.objc.ObjcCommandLineOptions.ObjcCrosstoolMode; -import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.xcode.plmerge.proto.PlMergeProtos; import java.util.List; import java.util.Map; @@ -172,7 +168,7 @@ public class IosTestTest extends ObjcRuleTestCase { "lib1/_objs/lib1/lib1/b.gcno", "lib2/_objs/lib2/lib2/a.gcno", "lib2/_objs/lib2/lib2/b.gcno", - "tools/objc/_objs/xctest_appbin/tools/objc/objc_dummy.gcno"); + "tools/objc/_objs/dummy_lib/tools/objc/objc_dummy.gcno"); } @Test @@ -205,26 +201,14 @@ public class IosTestTest extends ObjcRuleTestCase { @Test public void testXcTestAppIpaIsInFilesToBuild() throws Exception { scratch.file("x/BUILD", - "ios_application(", - " name = 'xctest_app',", - " binary = ':xctest_app_bin',", - " infoplist = 'Info.plist',", - ")", - "", - "objc_binary(", - " name = 'xctest_app_bin',", - " srcs = ['a.m'],", - ")", - "", "ios_test(", " name = 'x',", " xctest = 1,", - " xctest_app = ':xctest_app',", " srcs = ['test.m'],", ")"); ConfiguredTarget target = getConfiguredTarget("//x:x"); Iterable<Artifact> filesToBuild = target.getProvider(FileProvider.class).getFilesToBuild(); - assertThat(filesToBuild).contains(getBinArtifact("xctest_app.ipa", target)); + assertThat(Artifact.toRootRelativePaths(filesToBuild)).contains("tools/objc/xctest_app.ipa"); } @Test @@ -241,10 +225,10 @@ public class IosTestTest extends ObjcRuleTestCase { ImmutableList<String> expectedRunfiles = ImmutableList.of( "test/XcTest.ipa", - "test/testApp.ipa", "test/XcTest_test_script", "tools/objc/StdRedirect.dylib", - "tools/objc/testrunner"); + "tools/objc/testrunner", + "tools/objc/xctest_app.ipa"); RunfilesProvider runfiles = target.getProvider(RunfilesProvider.class); assertThat(Artifact.toRootRelativePaths(runfiles.getDefaultRunfiles().getArtifacts())) .containsExactlyElementsIn(expectedRunfiles); @@ -261,12 +245,13 @@ public class IosTestTest extends ObjcRuleTestCase { InstrumentedFilesProvider instrumentedFilesProvider = target.getProvider(InstrumentedFilesProvider.class); assertThat(Artifact.toRootRelativePaths(instrumentedFilesProvider.getInstrumentedFiles())) - .containsExactly("test/src.m", "test/test-src.m"); + .containsExactly("tools/objc/objc_dummy.mm", "test/test-src.m"); assertThat( Artifact.toRootRelativePaths( instrumentedFilesProvider.getInstrumentationMetadataFiles())) .containsExactly( - "test/_objs/XcTest/test/test-src.gcno", "test/_objs/testAppBin/test/src.gcno"); + "test/_objs/XcTest/test/test-src.gcno", + "tools/objc/_objs/dummy_lib/tools/objc/objc_dummy.gcno"); } @Test @@ -281,7 +266,7 @@ public class IosTestTest extends ObjcRuleTestCase { // Missing "test/test-src.m" since the target including it has been excluded. assertThat(Artifact.toRootRelativePaths(instrumentedFilesProvider.getInstrumentedFiles())) - .containsExactly("test/src.m"); + .containsExactly("tools/objc/objc_dummy.mm"); } @Test @@ -325,41 +310,24 @@ public class IosTestTest extends ObjcRuleTestCase { } protected void setUpXCTestClient() throws Exception { - scratch.file("/test/XcTest-Info.plist"); - scratch.file("/test/App-Info.plist"); scratch.file("/test/src.m"); scratch.file("/test/test-src.m"); scratch.file("test/BUILD", - "objc_binary(", - " name = 'testAppBin',", - " srcs = ['src.m'],", - ")", - "ios_application(", - " name = 'testApp',", - " binary = ':testAppBin',", - ")", "ios_test(", " name = 'XcTest',", " srcs = ['test-src.m'],", " xctest = True,", - " xctest_app = ':testApp',", ")"); } @Test public void testCreate_recognizesDylibsAttribute() throws Exception { - createBinaryTargetWriter("//bin:bin").setAndCreateFiles("srcs", "a.m").write(); scratch.file("test/BUILD", - "ios_application(", - " name = 'testApp',", - " binary = '//bin:bin',", - ")", "ios_test(", " name = 'test',", " srcs = ['test-src.m'],", " xctest = 1,", - " xctest_app = ':testApp',", " sdk_dylibs = ['libdy'],", ")"); CommandAction action = linkAction("//test:test"); @@ -433,15 +401,10 @@ public class IosTestTest extends ObjcRuleTestCase { public void testHasDefaultInfoplistForXcTest() throws Exception { createBinaryTargetWriter("//bin:bin").setAndCreateFiles("srcs", "a.m").write(); scratch.file("x/BUILD", - "ios_application(", - " name = 'testApp',", - " binary = '//bin:bin',", - ")", "ios_test(", " name = 'x',", " srcs = ['x-src.m'],", " xctest = 1,", - " xctest_app = ':testApp',", ")"); PlMergeProtos.Control control = plMergeControl("//x:x"); assertThat(control.getSourceFileList()) @@ -472,14 +435,9 @@ public class IosTestTest extends ObjcRuleTestCase { .write(); checkError("x", "x", IosTest.REQUIRES_SOURCE_ERROR, - "ios_application(", - " name = 'testApp',", - " binary = '//bin:bin',", - ")", "ios_test(", " name = 'x',", " xctest = 1,", - " xctest_app = ':testApp',", " deps = ['//lib:lib'],", ")"); } @@ -488,15 +446,10 @@ public class IosTestTest extends ObjcRuleTestCase { throws Exception { createBinaryTargetWriter("//bin:bin").setAndCreateFiles("srcs", "a.m").write(); scratch.file("x/BUILD", - "ios_application(", - " name = 'testApp',", - " binary = '//bin:bin',", - ")", "ios_test(", " name = 'x',", " srcs = ['a.m'],", " xctest = 1,", - " xctest_app = ':testApp',", Joiner.on(",").join(extraAttrs), ")"); TemplateExpansionAction action = @@ -544,105 +497,6 @@ public class IosTestTest extends ObjcRuleTestCase { } @Test - public void testGetsDefinesFromTestRig() throws Exception { - scratch.file("x/BUILD", - "objc_library(", - " name = 'lib',", - " srcs = ['lib.m'],", - " defines = ['LIB_DEFINE=1'],", - ")", - "objc_binary(", - " name = 'bin',", - " srcs = ['bin.m'],", - " defines = ['BIN_DEFINE=1'],", - " deps = [':lib'],", - ")", - "ios_application(", - " name = 'testApp',", - " binary = ':bin',", - ")", - "ios_test(", - " name = 'test',", - " srcs = ['test.m'],", - " defines = ['TEST_DEFINE=1'],", - " xctest = 1,", - " xctest_app = ':testApp',", - ")"); - assertContainsSublist(compileAction("//x:test", "test.o").getArguments(), - ImmutableList.of("-DLIB_DEFINE=1", "-DBIN_DEFINE=1", "-DTEST_DEFINE=1")); - } - - @Test - public void testGetsSdkDylibsFromTestRig() throws Exception { - scratch.file("x/BUILD", - "objc_library(", - " name = 'lib',", - " srcs = ['lib.m'],", - " sdk_dylibs = ['lib_dylib'],", - ")", - "objc_binary(", - " name = 'bin',", - " srcs = ['bin.m'],", - " sdk_dylibs = ['bin_dylib'],", - " deps = [':lib'],", - ")", - "ios_application(", - " name = 'testApp',", - " binary = ':bin',", - ")", - "ios_test(", - " name = 'test',", - " srcs = ['test.m'],", - " sdk_dylibs = ['test_dylib'],", - " xctest = 1,", - " xctest_app = ':testApp',", - ")"); - - String linkArgs = Joiner.on(' ').join(linkAction("//x:test").getArguments()); - assertThat(linkArgs).contains("-l_dylib"); - assertThat(linkArgs).contains("-lbin_dylib"); - assertThat(linkArgs).contains("-ltest_dylib"); - } - - @Test - public void testGetsSdkFrameworksFromTestRig() throws Exception { - scratch.file("x/BUILD", - "objc_library(", - " name = 'lib',", - " srcs = ['lib.m'],", - " sdk_frameworks = ['lib_fx'],", - " weak_sdk_frameworks = ['lib_wfx'],", - ")", - "objc_binary(", - " name = 'bin',", - " srcs = ['bin.m'],", - " sdk_frameworks = ['bin_fx'],", - " weak_sdk_frameworks = ['bin_wfx'],", - " deps = [':lib'],", - ")", - "ios_application(", - " name = 'testApp',", - " binary = ':bin',", - ")", - "ios_test(", - " name = 'test',", - " srcs = ['test.m'],", - " sdk_frameworks = ['test_fx'],", - " weak_sdk_frameworks = ['test_wfx'],", - " xctest = 1,", - " xctest_app = ':testApp',", - ")"); - - String linkArgs = Joiner.on(' ').join(linkAction("//x:test").getArguments()); - assertThat(linkArgs).contains("-framework lib_fx"); - assertThat(linkArgs).contains("-weak_framework lib_wfx"); - assertThat(linkArgs).contains("-framework bin_fx"); - assertThat(linkArgs).contains("-weak_framework bin_wfx"); - assertThat(linkArgs).contains("-framework test_fx"); - assertThat(linkArgs).contains("-weak_framework test_wfx"); - } - - @Test public void testLinkIncludeOrder_staticLibsFirst() throws Exception { checkLinkIncludeOrderStaticLibsFirst(RULE_TYPE); } @@ -884,7 +738,6 @@ public class IosTestTest extends ObjcRuleTestCase { " name = 'some_test_with_device',", " srcs = ['SomeOtherTest.m'],", " xctest = 1,", - " xctest_app = ':testApp',", " target_device = ':device',", ")", "ios_device(", @@ -892,13 +745,6 @@ public class IosTestTest extends ObjcRuleTestCase { " ios_version = '1.2',", " type = 'iMarmoset',", " locale = 'en-gb'", - ")", - "ios_application(", - " name = 'testApp',", - " binary = ':bin',", - ")", - "objc_binary(name = 'bin',", - " srcs = ['app.m'],", ")"); scratch.file("test/SomeOtherTest.m"); @@ -906,26 +752,23 @@ public class IosTestTest extends ObjcRuleTestCase { TemplateExpansionAction action = getTestScriptGenerationAction(getConfiguredTarget("//test:some_test_with_device")); - assertThat(action.getSubstitutions()).containsExactly( - Substitution.of("%(memleaks)s", "false"), - - Substitution.of("%(test_app_ipa)s", "test/some_test_with_device.ipa"), - Substitution.of("%(test_app_name)s", "some_test_with_device"), - Substitution.of("%(test_bundle_path)s", "test/some_test_with_device.ipa"), - - Substitution.of("%(xctest_app_ipa)s", "test/testApp.ipa"), - Substitution.of("%(xctest_app_name)s", "testApp"), - Substitution.of("%(test_host_path)s", "test/testApp.ipa"), - - Substitution.of("%(plugin_jars)s", ""), - Substitution.of("%(device_type)s", "iMarmoset"), - Substitution.of("%(locale)s", "en-gb"), - Substitution.of("%(simulator_sdk)s", "1.2"), - Substitution.of("%(testrunner_binary)s", "tools/objc/testrunner"), - Substitution.of("%(std_redirect_dylib_path)s", "tools/objc/StdRedirect.dylib"), - Substitution.of("%(test_env)s", ""), - Substitution.of("%(test_type)s", "XCTEST") - ); + assertThat(action.getSubstitutions()) + .containsExactly( + Substitution.of("%(memleaks)s", "false"), + Substitution.of("%(test_app_ipa)s", "test/some_test_with_device.ipa"), + Substitution.of("%(test_app_name)s", "some_test_with_device"), + Substitution.of("%(test_bundle_path)s", "test/some_test_with_device.ipa"), + Substitution.of("%(xctest_app_ipa)s", "tools/objc/xctest_app.ipa"), + Substitution.of("%(xctest_app_name)s", "xctest_app"), + Substitution.of("%(test_host_path)s", "tools/objc/xctest_app.ipa"), + Substitution.of("%(plugin_jars)s", ""), + Substitution.of("%(device_type)s", "iMarmoset"), + Substitution.of("%(locale)s", "en-gb"), + Substitution.of("%(simulator_sdk)s", "1.2"), + Substitution.of("%(testrunner_binary)s", "tools/objc/testrunner"), + Substitution.of("%(std_redirect_dylib_path)s", "tools/objc/StdRedirect.dylib"), + Substitution.of("%(test_env)s", ""), + Substitution.of("%(test_type)s", "XCTEST")); } @Test @@ -935,14 +778,12 @@ public class IosTestTest extends ObjcRuleTestCase { " name = 'one_plugin',", " srcs = ['SomeTest.m'],", " xctest = 1,", - " xctest_app = ':testApp',", " plugins = [':a_plugin_deploy.jar'],", ")", "ios_test(", " name = 'two_plugins',", " srcs = ['SomeOtherTest.m'],", " xctest = 1,", - " xctest_app = ':testApp',", " plugins = [':a_plugin_deploy.jar', ':b_plugin_deploy.jar'],", ")", "java_binary(", @@ -954,13 +795,6 @@ public class IosTestTest extends ObjcRuleTestCase { " name = 'b_plugin',", " srcs = ['B.java'],", " main_class = 'B',", - ")", - "ios_application(", - " name = 'testApp',", - " binary = ':bin',", - ")", - "objc_binary(name = 'bin',", - " srcs = ['app.m'],", ")"); scratch.file("test/SomeTest.m"); @@ -1064,83 +898,11 @@ public class IosTestTest extends ObjcRuleTestCase { } @Test - public void testProtobufPropagatedHeaderSearchPaths() throws Exception { - scratch.file( - "test/BUILD", - "ios_test(", - " name = 'protos_test',", - " srcs = ['SomeTest.m'],", - " xctest = 1,", - " xctest_app = ':protos_app',", - ")", - "ios_application(", - " name = 'protos_app',", - " binary = ':protos_bin',", - ")", - "objc_binary(", - " name = 'protos_bin',", - " srcs = ['app.m'],", - " deps = [':protos_objc'],", - ")", - "objc_proto_library(", - " name = 'protos_objc',", - " deps = [':protos_lib'],", - " portable_proto_filters = ['filter.pbascii'],", - ")", - "proto_library(", - " name = 'protos_lib',", - " srcs = ['a.proto'],", - ")"); - - ObjcProvider appProvider = - getConfiguredTarget("//test:protos_app") - .get(XcTestAppProvider.SKYLARK_CONSTRUCTOR) - .getObjcProvider(); - ConfiguredTarget binTarget = getConfiguredTarget("//test:protos_bin"); - Artifact protoHeader = - getBinArtifact("_generated_protos/protos_bin/test/A.pbobjc.h", binTarget); - - assertThat(PathFragment.safePathStrings(appProvider.get(ObjcProvider.INCLUDE))) - .containsAllOf( - "objcproto/include", - protoHeader.getExecPath().getParentDirectory().getParentDirectory().toString()); - } - - @Test public void testCcDependency() throws Exception { checkCcDependency(RULE_TYPE, "xctest", "0"); } @Test - public void testPassesTestRigAppAsBundleLoaderFlagToLinker() throws Exception { - useConfiguration("--cpu=ios_x86_64", - "--crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL, - "--experimental_disable_go"); - scratch.file("x/BUILD", - "objc_binary(", - " name = 'bin',", - " srcs = ['bin.m'],", - ")", - "ios_application(", - " name = 'testApp',", - " binary = ':bin',", - ")", - "ios_test(", - " name = 'test',", - " srcs = ['test.m'],", - " xctest = 1,", - " xctest_app = ':testApp',", - ")"); - CommandAction testLinkAction = linkAction("//x:test"); - Action appLipoAction = lipoBinAction("//x:testApp"); - Artifact rigBinary = Iterables.getOnlyElement(appLipoAction.getOutputs()); - - String linkArgs = Joiner.on(' ').join(testLinkAction.getArguments()); - assertThat(linkArgs).contains("-bundle_loader " + rigBinary.getExecPath()); - assertThat(testLinkAction.getInputs()).contains(rigBinary); - } - - @Test public void testCompilationActionsForDebugInGcovCoverage() throws Exception { checkClangCoptsForCompilationMode(RULE_TYPE, CompilationMode.DBG, CodeCoverageMode.GCOV); @@ -1165,46 +927,6 @@ public class IosTestTest extends ObjcRuleTestCase { } @Test - public void testMultiArchUserHeaderSearchPathsUsed() throws Exception { - // Usually, an ios_test would depend on apple_binary through a skylark_ios_application in its - // 'binary' attribute. Since we don't have skylark_ios_application here, we use the 'deps' - // attribute instead. - scratch.file("x/BUILD", - "genrule(", - " name = 'gen_hdrs',", - " outs = ['generated.h'],", - " cmd = 'echo hello > \\$@',", - ")", - "apple_binary(", - " name = 'apple_bin',", - " srcs = ['apple_bin.m'],", - " platform_type = 'ios',", - " hdrs = ['generated.h'],", - ")", - "objc_binary(", - " name = 'bin',", - " srcs = ['bin.m'],", - ")", - "ios_application(", - " name = 'testApp',", - " binary = ':bin',", - ")", - "ios_test(", - " name = 'test',", - " srcs = ['test.m'],", - " xctest = 1,", - " xctest_app = ':testApp',", - " deps = [':apple_bin']", - ")"); - CommandAction compileAction = compileAction("//x:test", "test.o"); - // The genfiles root for child configurations must be present in the compile action so that - // generated headers can be resolved. - assertThat(Joiner.on(" ").join(compileAction.getArguments())).contains("-iquote " - + configurationGenfiles("x86_64", ConfigurationDistinguisher.APPLEBIN_IOS, - defaultMinimumOs(ConfigurationDistinguisher.APPLEBIN_IOS))); - } - - @Test public void testXcTest_linkAction_inCoverageMode() throws Exception { useConfiguration("--collect_code_coverage"); setUpXCTestClient(); @@ -1232,37 +954,6 @@ public class IosTestTest extends ObjcRuleTestCase { } @Test - public void testGetsHeadersFromTestRig() throws Exception { - scratch.file( - "x/BUILD", - "objc_library(", - " name = 'lib',", - " srcs = ['lib.m'],", - " hdrs = ['lib.h'],", - ")", - "objc_binary(", - " name = 'bin',", - " srcs = ['bin.m'],", - " hdrs = ['bin.h'],", - " deps = [':lib'],", - ")", - "ios_application(", - " name = 'testApp',", - " binary = ':bin',", - ")", - "ios_test(", - " name = 'test',", - " srcs = ['test.m'],", - " hdrs = ['test.h'],", - " xctest = 1,", - " xctest_app = ':testApp',", - ")"); - Iterable<Artifact> compileInputs = - compileAction("//x:test", "test.o").getPossibleInputsForTesting(); - assertThat(Artifact.toExecPaths(compileInputs)).containsAllOf("x/lib.h", "x/bin.h", "x/test.h"); - } - - @Test public void testReceivesTransitivelyPropagatedDefines() throws Exception { checkReceivesTransitivelyPropagatedDefines(RULE_TYPE); } @@ -1271,88 +962,4 @@ public class IosTestTest extends ObjcRuleTestCase { public void testSdkIncludesUsedInCompileAction() throws Exception { checkSdkIncludesUsedInCompileAction(RULE_TYPE); } - - @Test - public void testGetsIncludesFromTestRig() throws Exception { - scratch.file("x/BUILD", - "objc_library(", - " name = 'lib',", - " srcs = ['lib.m'],", - " includes = ['libinc'],", - " sdk_includes = ['libinc_sdk'],", - ")", - "objc_binary(", - " name = 'bin',", - " srcs = ['bin.m'],", - " includes = ['bininc'],", - " sdk_includes = ['bininc_sdk'],", - " deps = [':lib'],", - ")", - "ios_application(", - " name = 'testApp',", - " binary = ':bin',", - ")", - "ios_test(", - " name = 'test',", - " srcs = ['test.m'],", - " includes = ['testinc'],", - " sdk_includes = ['testinc_sdk'],", - " xctest = 1,", - " xctest_app = ':testApp',", - ")"); - // We remove spaces because the crosstool case does not use spaces for include paths. - String compileArgs = Joiner.on("") - .join(compileAction("//x:test", "test.o").getArguments()) - .replace(" ", ""); - assertThat(compileArgs).contains("-Ix/libinc"); - assertThat(compileArgs).contains("-Ix/bininc"); - assertThat(compileArgs).contains("-Ix/testinc"); - - String sdkIncludeDir = AppleToolchain.sdkDir() + "/usr/include/"; - assertThat(compileArgs).contains("-I" + sdkIncludeDir + "libinc_sdk"); - assertThat(compileArgs).contains("-I" + sdkIncludeDir + "bininc_sdk"); - assertThat(compileArgs).contains("-I" + sdkIncludeDir + "testinc_sdk"); - } - - @Test - public void testGetsFrameworksFromTestRig() throws Exception { - scratch.file("x/BUILD", - "objc_framework(", - " name = 'fx',", - " framework_imports = ['fx.framework/1'],", - ")", - "objc_library(", - " name = 'lib',", - " srcs = ['lib.m'],", - " deps = [':fx'],", - ")", - "objc_binary(", - " name = 'bin',", - " srcs = ['bin.m'],", - " deps = [':lib'],", - ")", - "ios_application(", - " name = 'testApp',", - " binary = ':bin',", - ")", - "ios_test(", - " name = 'test',", - " srcs = ['test.m'],", - " xctest = 1,", - " xctest_app = ':testApp',", - ")"); - CommandAction compileAction = compileAction("//x:test", "test.o"); - - assertThat(Artifact.toExecPaths(compileAction.getInputs())) - .contains("x/fx.framework/1"); - // We remove spaces since the crosstool case does not use spaces for '-F'. - String compileActionArgs = Joiner.on("") - .join(compileAction.getArguments()) - .replace(" ", ""); - - assertThat(compileActionArgs).contains("-Fx"); - - CommandAction linkAction = linkAction("//x:test"); - assertThat(Joiner.on(" ").join(linkAction.getArguments())).doesNotContain("-framework fx"); - } } diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyIosApplicationTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyIosApplicationTest.java deleted file mode 100644 index 122600b445..0000000000 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyIosApplicationTest.java +++ /dev/null @@ -1,32 +0,0 @@ -// 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 com.google.devtools.build.lib.rules.objc.ObjcCommandLineOptions.ObjcCrosstoolMode; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** - * Legacy test: These tests test --experimental_objc_crosstool=off. See README. - */ -@RunWith(JUnit4.class) -@LegacyTest -public class LegacyIosApplicationTest extends IosApplicationTest { - @Override - protected ObjcCrosstoolMode getObjcCrosstoolMode() { - return ObjcCrosstoolMode.OFF; - } - -} diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyIosExtensionBinaryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyIosExtensionBinaryTest.java deleted file mode 100644 index d28371a647..0000000000 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyIosExtensionBinaryTest.java +++ /dev/null @@ -1,39 +0,0 @@ -// 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 com.google.devtools.build.lib.rules.objc.ObjcCommandLineOptions.ObjcCrosstoolMode; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** - * Legacy test: These tests test --experimental_objc_crosstool=off. See README. - */ -@RunWith(JUnit4.class) -@LegacyTest -public class LegacyIosExtensionBinaryTest extends IosExtensionBinaryTest { - @Override - protected ObjcCrosstoolMode getObjcCrosstoolMode() { - return ObjcCrosstoolMode.OFF; - } - - // Module maps are not made action inputs in the crosstool rules. - @Test - public void testCompilesSourcesWithModuleMapsEnabled() throws Exception { - checkCompilesSourcesWithModuleMapsEnabled(RULE_TYPE); - } - -} diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyIosExtensionTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyIosExtensionTest.java deleted file mode 100644 index 73af61b459..0000000000 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyIosExtensionTest.java +++ /dev/null @@ -1,31 +0,0 @@ -// 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 com.google.devtools.build.lib.rules.objc.ObjcCommandLineOptions.ObjcCrosstoolMode; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** - * Legacy test: These tests test --experimental_objc_crosstool=off. See README. - */ -@RunWith(JUnit4.class) -@LegacyTest -public class LegacyIosExtensionTest extends IosExtensionTest { - @Override - public ObjcCrosstoolMode getObjcCrosstoolMode() { - return ObjcCrosstoolMode.OFF; - } -} diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyIosTestTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyIosTestTest.java index 25c7d2d7ed..f955d3e635 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyIosTestTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyIosTestTest.java @@ -28,5 +28,4 @@ public class LegacyIosTestTest extends IosTestTest { protected ObjcCrosstoolMode getObjcCrosstoolMode() { return ObjcCrosstoolMode.OFF; } - } diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyObjcBinaryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyObjcBinaryTest.java deleted file mode 100644 index c8cb67d358..0000000000 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyObjcBinaryTest.java +++ /dev/null @@ -1,94 +0,0 @@ -// 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.base.Joiner; -import com.google.devtools.build.lib.actions.Artifact; -import com.google.devtools.build.lib.actions.CommandAction; -import com.google.devtools.build.lib.analysis.ConfiguredTarget; -import com.google.devtools.build.lib.analysis.actions.SpawnAction; -import com.google.devtools.build.lib.rules.objc.ObjcCommandLineOptions.ObjcCrosstoolMode; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** - * Legacy test: These tests test --experimental_objc_crosstool=off. See README. - */ -@RunWith(JUnit4.class) -@LegacyTest -public class LegacyObjcBinaryTest extends ObjcBinaryTest { - @Override - protected ObjcCrosstoolMode getObjcCrosstoolMode() { - return ObjcCrosstoolMode.OFF; - } - - // Module maps are not made action inputs in the crosstool rules. - @Test - public void testCompilesSourcesWithModuleMapsEnabled() throws Exception { - checkCompilesSourcesWithModuleMapsEnabled(RULE_TYPE); - } - - @Override - @Test - public void testCreate_debugSymbolActionWithAppleFlag() throws Exception { - useConfiguration("--apple_generate_dsym"); - RULE_TYPE.scratchTarget(scratch, "srcs", "['a.m']"); - ConfiguredTarget target = getConfiguredTarget("//x:x"); - - Artifact artifact = getBinArtifact("x.app.dSYM.temp.zip", target); - String execPath = artifact.getExecPath().getParentDirectory().toString(); - CommandAction linkAction = (CommandAction) getGeneratingAction(artifact); - assertThat(Joiner.on(" ").join(linkAction.getArguments())) - .contains( - Joiner.on(" ") - .join( - "&&", - MOCK_XCRUNWRAPPER_PATH, - ObjcRuleClasses.DSYMUTIL, - execPath + "/x_bin", - "-o", - execPath + "/x.app.dSYM.temp", - "&&", - "zipped_bundle=${PWD}/" + artifact.getExecPathString(), - "&&", - "cd " + artifact.getExecPathString().replace(".zip", ""), - "&&", - "/usr/bin/zip -q -r \"${zipped_bundle}\" .")); - - Artifact plistArtifact = getBinArtifact("x.app.dSYM/Contents/Info.plist", target); - Artifact debugSymbolArtifact = - getBinArtifact("x.app.dSYM/Contents/Resources/DWARF/x_bin", target); - SpawnAction plistAction = (SpawnAction) getGeneratingAction(plistArtifact); - SpawnAction debugSymbolAction = (SpawnAction) getGeneratingAction(debugSymbolArtifact); - assertThat(debugSymbolAction).isEqualTo(plistAction); - - String dsymUnzipActionArg = - "unzip -p " - + execPath - + "/x.app.dSYM.temp.zip" - + " Contents/Info.plist > " - + plistArtifact.getExecPathString() - + " && unzip -p " - + execPath - + "/x.app.dSYM.temp.zip" - + " Contents/Resources/DWARF/x_bin > " - + debugSymbolArtifact.getExecPathString(); - assertThat(plistAction.getArguments()).contains(dsymUnzipActionArg); - } - -} diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcBinaryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcBinaryTest.java deleted file mode 100644 index 110180c2c0..0000000000 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcBinaryTest.java +++ /dev/null @@ -1,961 +0,0 @@ -// 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 static com.google.devtools.build.lib.rules.objc.BinaryLinkingTargetFactory.REQUIRES_AT_LEAST_ONE_LIBRARY_OR_SOURCE_FILE; -import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.ReleaseBundlingRule.APP_ICON_ATTR; -import static com.google.devtools.build.lib.rules.objc.ObjcRuleClasses.ReleaseBundlingRule.LAUNCH_IMAGE_ATTR; - -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableListMultimap; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMultiset; -import com.google.common.collect.ImmutableSetMultimap; -import com.google.common.collect.Multiset; -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.analysis.ConfiguredTarget; -import com.google.devtools.build.lib.analysis.RunfilesProvider; -import com.google.devtools.build.lib.analysis.actions.SpawnAction; -import com.google.devtools.build.lib.analysis.config.CompilationMode; -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.objc.CompilationSupport.ExtraLinkArgs; -import com.google.devtools.build.xcode.bundlemerge.proto.BundleMergeProtos; -import com.google.devtools.build.xcode.bundlemerge.proto.BundleMergeProtos.BundleFile; -import com.google.devtools.build.xcode.bundlemerge.proto.BundleMergeProtos.MergeZip; -import java.util.List; -import java.util.Map; -import java.util.regex.Pattern; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Test case for objc_binary. */ -@RunWith(JUnit4.class) -@LegacyTest -public class ObjcBinaryTest extends ObjcRuleTestCase { - static final RuleType RULE_TYPE = new BinaryRuleType("objc_binary"); - - protected ConfiguredTarget addMockBinAndLibs(List<String> srcs) throws Exception { - createLibraryTargetWriter("//lib1:lib1") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "hdr.h") - .write(); - createLibraryTargetWriter("//lib2:lib2") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "hdr.h") - .write(); - - return createBinaryTargetWriter("//bin:bin") - .setAndCreateFiles("srcs", srcs) - .setList("deps", "//lib1:lib1", "//lib2:lib2") - .write(); - } - - @Before - public final void initializeToolsConfigMock() throws Exception { - MockProtoSupport.setup(mockToolsConfig); - MockObjcSupport.setup(mockToolsConfig); - } - - @Test - public void testCreate_runfiles() throws Exception { - ConfiguredTarget binary = addMockBinAndLibs(ImmutableList.of("a.m")); - RunfilesProvider runfiles = binary.getProvider(RunfilesProvider.class); - assertThat(runfiles.getDefaultRunfiles().getArtifacts()).isEmpty(); - assertThat(Artifact.toRootRelativePaths(runfiles.getDataRunfiles().getArtifacts())) - .containsExactly( - "bin/bin.ipa", - "bin/bin_bin"); - } - - @Test - public void testFilesToRun() throws Exception { - checkFilesToRun(RULE_TYPE); - } - - @Test - public void testNoRunfilesSupportForDevice() throws Exception { - checkNoRunfilesSupportForDevice(RULE_TYPE); - } - - @Test - public void testGenerateRunnerScriptAction() throws Exception { - checkGenerateRunnerScriptAction(RULE_TYPE); - } - - @Test - public void testGenerateRunnerScriptAction_escaped() throws Exception { - checkGenerateRunnerScriptAction_escaped(RULE_TYPE); - } - - @Test - public void testLinkActionDuplicateInputs() throws Exception { - checkLinkActionDuplicateInputs(RULE_TYPE, new ExtraLinkArgs()); - } - - @Test - /** - * Tests that bitcode is disabled for simulator builds even if enabled by flag. - */ - public void testLinkActionsWithBitcode_simulator() throws Exception { - useConfiguration("--apple_bitcode=embedded", "--ios_multi_cpus=x86_64"); - createBinaryTargetWriter("//objc:bin").setAndCreateFiles("srcs", "a.m").write(); - - CommandAction linkAction = linkAction("//objc:bin"); - - String commandLine = Joiner.on(" ").join(linkAction.getArguments()); - assertThat(commandLine).doesNotContain("-fembed-bitcode"); - assertThat(commandLine).doesNotContain("-fembed-bitcode-marker"); - } - - @Test - public void testLinkActionsWithNoBitcode() throws Exception { - useConfiguration("--apple_bitcode=none", "--ios_multi_cpus=arm64"); - createBinaryTargetWriter("//objc:bin").setAndCreateFiles("srcs", "a.m").write(); - - CommandAction linkAction = linkAction("//objc:bin"); - - String commandLine = Joiner.on(" ").join(linkAction.getArguments()); - assertThat(commandLine).doesNotContain("-fembed-bitcode"); - assertThat(commandLine).doesNotContain("-fembed-bitcode-marker"); - } - - @Test - public void testSigningAction() throws Exception { - checkDeviceSigningAction(RULE_TYPE); - } - - @Test - public void testSigningWithCertName() throws Exception { - checkSigningWithCertName(RULE_TYPE); - } - - @Test - public void testProvisioningProfile_simulatorBuild() throws Exception { - useConfiguration("--cpu=ios_i386"); - addMockBinAndLibs(ImmutableList.of("a.m")); - - Artifact provisioningProfile = - getFileConfiguredTarget("//tools/objc:foo.mobileprovision").getArtifact(); - SpawnAction spawnAction = bundleMergeAction("//bin:bin"); - assertThat(spawnAction.getInputs()).doesNotContain(provisioningProfile); - - BundleMergeProtos.Control control = bundleMergeControl("//bin:bin"); - assertThat(mobileProvisionProfiles(control)).isEmpty(); - } - - @Test - public void testProvisioningProfile_deviceBuild() throws Exception { - useConfiguration("--cpu=ios_armv7"); - - addMockBinAndLibs(ImmutableList.of("a.m")); - - Artifact provisioningProfile = - getFileConfiguredTarget("//tools/objc:foo.mobileprovision").getArtifact(); - SpawnAction spawnAction = bundleMergeAction("//bin:bin"); - assertThat(spawnAction.getInputs()).contains(provisioningProfile); - - BundleMergeProtos.Control control = bundleMergeControl("//bin:bin"); - Map<String, String> profiles = mobileProvisionProfiles(control); - ImmutableMap<String, String> expectedProfiles = ImmutableMap.of( - provisioningProfile.getExecPathString(), - ReleaseBundlingSupport.PROVISIONING_PROFILE_BUNDLE_FILE); - assertThat(profiles).isEqualTo(expectedProfiles); - } - - @Test - public void testUserSpecifiedProvisioningProfile_deviceBuild() throws Exception { - useConfiguration("--cpu=ios_armv7"); - scratch.file("custom/BUILD", "exports_files(['pp.mobileprovision'])"); - scratch.file("custom/pp.mobileprovision"); - createLibraryTargetWriter("//lib1:lib1") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "hdr.h") - .write(); - createLibraryTargetWriter("//lib2:lib2") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "hdr.h") - .write(); - createBinaryTargetWriter("//bin:bin") - .setAndCreateFiles("srcs", "a.m") - .setList("deps", "//lib1:lib1", "//lib2:lib2") - .set("provisioning_profile", "'//custom:pp.mobileprovision'") - .write(); - - Artifact defaultProvisioningProfile = - getFileConfiguredTarget("//tools/objc:foo.mobileprovision").getArtifact(); - Artifact customProvisioningProfile = - getFileConfiguredTarget("//custom:pp.mobileprovision").getArtifact(); - SpawnAction spawnAction = bundleMergeAction("//bin:bin"); - assertThat(spawnAction.getInputs()).contains(customProvisioningProfile); - assertThat(spawnAction.getInputs()).doesNotContain(defaultProvisioningProfile); - - BundleMergeProtos.Control control = bundleMergeControl("//bin:bin"); - Map<String, String> profiles = mobileProvisionProfiles(control); - Map<String, String> expectedProfiles = ImmutableMap.of( - customProvisioningProfile.getExecPathString(), - ReleaseBundlingSupport.PROVISIONING_PROFILE_BUNDLE_FILE); - assertThat(profiles).isEqualTo(expectedProfiles); - } - - @Test - public void testCreate_mergeControlAction() throws Exception { - createLibraryTargetWriter("//lib1:lib1") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "hdr.h") - .write(); - createLibraryTargetWriter("//lib2:lib2") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "hdr.h") - .write(); - createBinaryTargetWriter("//bin:bin") - .setAndCreateFiles("srcs", "a.m") - .setList("deps", "//lib1:lib1", "//lib2:lib2") - .set("infoplist", "'bin-Info.plist'") - .write(); - - Action mergeAction = bundleMergeAction("//bin:bin"); - Action action = bundleMergeControlAction("//bin:bin"); - assertThat(action.getInputs()).isEmpty(); - assertThat(Artifact.toRootRelativePaths(action.getOutputs())).containsExactly( - "bin/bin.ipa-control"); - assertThat(bundleMergeControl("//bin:bin")) - .isEqualTo( - BundleMergeProtos.Control.newBuilder() - .addBundleFile( - BundleFile.newBuilder() - .setSourceFile(execPathEndingWith(mergeAction.getInputs(), "bin")) - .setBundlePath("bin") - .setExternalFileAttribute(BundleableFile.EXECUTABLE_EXTERNAL_FILE_ATTRIBUTE) - .build()) - .setBundleRoot("Payload/bin.app") - .setBundleInfoPlistFile( - execPathEndingWith(mergeAction.getInputs(), "bin-MergedInfo.plist")) - .setOutFile(execPathEndingWith(mergeAction.getOutputs(), "bin.unprocessed.ipa")) - .setMinimumOsVersion(DEFAULT_IOS_SDK_VERSION.toString()) - .setSdkVersion(DEFAULT_IOS_SDK_VERSION.toString()) - .setPlatform("IOS_SIMULATOR") - .setFallbackBundleIdentifier("example.bin") - .build()); - } - - @Test - public void testCreate_mergeBundleAction() throws Exception { - createLibraryTargetWriter("//lib1:lib1") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "hdr.h") - .write(); - createLibraryTargetWriter("//lib2:lib2") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "hdr.h") - .write(); - createBinaryTargetWriter("//bin:bin") - .setAndCreateFiles("srcs", "a.m") - .setList("deps", "//lib1:lib1", "//lib2:lib2") - .set("infoplist", "'bin-Info.plist'") - .write(); - - SpawnAction action = bundleMergeAction("//bin:bin"); - assertThat(Artifact.toRootRelativePaths(action.getInputs())) - .containsExactly( - MOCK_BUNDLEMERGE_PATH, - "bin/bin_lipobin", - "bin/bin.ipa-control", - "bin/bin-MergedInfo.plist"); - assertThat(Artifact.toRootRelativePaths(action.getOutputs())) - .containsExactly("bin/bin.unprocessed.ipa"); - assertNotRequiresDarwin(action); - assertThat(action.getEnvironment()).isEmpty(); - assertThat(action.getArguments()) - .containsExactly( - MOCK_BUNDLEMERGE_PATH, execPathEndingWith(action.getInputs(), "bin.ipa-control")) - .inOrder(); - } - - @Test - public void testCheckPrimaryBundleIdInMergedPlist() throws Exception { - checkPrimaryBundleIdInMergedPlist(RULE_TYPE); - } - - @Test - public void testCheckFallbackBundleIdInMergedPlist() throws Exception { - checkFallbackBundleIdInMergedPlist(RULE_TYPE); - } - - @Test - public void testCreate_errorForNoSourceOrDep() throws Exception { - scratch.file("x/Foo.plist"); - checkError("x", "x", REQUIRES_AT_LEAST_ONE_LIBRARY_OR_SOURCE_FILE, - "objc_binary(name='x')"); - } - - @Test - public void testCompileWithDotMFileInHeaders() throws Exception { - checkCompileWithDotMFileInHeaders(RULE_TYPE); - } - - @Test - public void testCreate_NoDebugSymbolActionWithoutAppleFlag() throws Exception { - checkNoDebugSymbolFileWithoutAppleFlag(RULE_TYPE); - } - - @Test - public void testErrorForLaunchImageGivenWithNoAssetCatalog() throws Exception { - checkAssetCatalogAttributeError(RULE_TYPE, LAUNCH_IMAGE_ATTR); - } - - @Test - public void testErrorForAppIconGivenWithNoAssetCatalog() throws Exception { - checkAssetCatalogAttributeError(RULE_TYPE, APP_ICON_ATTR); - } - - @Test - public void testCollectsAssetCatalogsTransitively() throws Exception { - scratch.file("lib/ac.xcassets/foo"); - scratch.file("lib/ac.xcassets/bar"); - createLibraryTargetWriter("//lib:lib") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .set("asset_catalogs", "glob(['ac.xcassets/**'])") - .write(); - scratch.file("bin/ac.xcassets/baz"); - scratch.file("bin/ac.xcassets/42"); - createBinaryTargetWriter("//bin:bin") - .setAndCreateFiles("srcs", "src.m") - .setList("deps", "//lib:lib") - .set("asset_catalogs", "glob(['ac.xcassets/**'])") - .write(); - - // Test that the actoolzip Action has arguments and inputs obtained from dependencies. - SpawnAction actoolZipAction = actoolZipActionForIpa("//bin:bin"); - assertThat(Artifact.toExecPaths(actoolZipAction.getInputs())).containsExactly( - "lib/ac.xcassets/foo", "lib/ac.xcassets/bar", "bin/ac.xcassets/baz", "bin/ac.xcassets/42", - MOCK_ACTOOLWRAPPER_PATH); - assertContainsSublist(actoolZipAction.getArguments(), - ImmutableList.of("lib/ac.xcassets", "bin/ac.xcassets")); - } - - @Test - public void testCcDependencyLinkoptsArePropagatedToLinkAction() throws Exception { - useConfiguration("--experimental_disable_go", "--cpu=ios_i386", - "--crosstool_top=//tools/osx/crosstool:crosstool"); - - scratch.file("bin/BUILD", - "cc_library(", - " name = 'cclib1',", - " srcs = ['dep1.c'],", - " linkopts = ['-framework F1', '-framework F2', '-Wl,--other-opt'],", - ")", - "cc_library(", - " name = 'cclib2',", - " srcs = ['dep2.c'],", - " linkopts = ['-another-opt', '-framework F2'],", - " deps = ['cclib1'],", - ")", - "cc_library(", - " name = 'cclib3',", - " srcs = ['dep2.c'],", - " linkopts = ['-one-more-opt', '-framework UIKit'],", - " deps = ['cclib1'],", - ")", - "objc_binary(", - " name = 'bin',", - " srcs = ['bin.m'],", - " deps = [':cclib2', ':cclib3'],", - ")"); - - // Frameworks from the CROSSTOOL "apply_implicit_frameworks" feature should be present. - assertThat(Joiner.on(" ").join(linkAction("//bin").getArguments())) - .contains("-framework Foundation -framework UIKit"); - // Frameworks included in linkopts by the user should get placed together with no duplicates. - // (They may duplicate the ones inserted by the CROSSTOOL feature, but we don't test that here.) - assertThat(Joiner.on(" ").join(linkAction("//bin").getArguments())) - .contains("-framework F2 -framework F1"); - // Linkopts should also be grouped together. - assertThat(Joiner.on(" ").join(linkAction("//bin").getArguments())) - .contains("-another-opt -Wl,--other-opt -one-more-opt"); - } - - @Test - public void testAlwaysLinkCcDependenciesAreForceLoaded() throws Exception { - useConfiguration("--experimental_disable_go", "--cpu=ios_i386", - "--crosstool_top=//tools/osx/crosstool:crosstool"); - - scratch.file("bin/BUILD", - "cc_library(", - " name = 'cclib1',", - " srcs = ['dep1.c'],", - " alwayslink = 1,", - ")", - "cc_library(", - " name = 'cclib2',", - " srcs = ['dep2.c'],", - " deps = [':cclib1'],", - ")", - "objc_binary(", - " name = 'bin',", - " srcs = ['bin.m'],", - " deps = [':cclib2'],", - ")"); - - // cclib1 is force loaded. - assertThat(Joiner.on(" ").join(linkAction("//bin").getArguments())) - .containsMatch(Pattern.compile(" -force_load [^\\s]+/libcclib1.lo\\b")); - } - - @Test - public void testSpecifyAppIconAndLaunchImageUsingXcassetsOfDependency() throws Exception { - checkSpecifyAppIconAndLaunchImageUsingXcassetsOfDependency(RULE_TYPE); - } - - @Test - public void testCreate_actoolAction() throws Exception { - addTargetWithAssetCatalogs(RULE_TYPE); - checkActoolActionCorrectness(DEFAULT_IOS_SDK_VERSION); - } - - @Test - public void testPassesFamiliesToActool() throws Exception { - checkPassesFamiliesToActool(RULE_TYPE); - } - - @Test - public void testPassesFamiliesToIbtool() throws Exception { - checkPassesFamiliesToIbtool(RULE_TYPE); - } - - @Test - public void testReportsErrorsForInvalidFamiliesAttribute() throws Exception { - checkReportsErrorsForInvalidFamiliesAttribute(RULE_TYPE); - } - - @SuppressWarnings("deprecation") // getMergeWithoutNamePrefixZipList is deprecated - @Test - public void testCreate_mergeActionsWithAssetCatalog() throws Exception { - // TODO(matvore): add this test to IosTestTest.java. - addTargetWithAssetCatalogs(RULE_TYPE); - - Artifact actoolZipOut = getBinArtifact("x.actool.zip", "//x:x"); - assertThat(bundleMergeAction("//x:x").getInputs()).contains(actoolZipOut); - - BundleMergeProtos.Control mergeControl = bundleMergeControl("//x:x"); - assertThat(mergeControl.getMergeZipList()).containsExactly(MergeZip.newBuilder() - .setEntryNamePrefix("Payload/x.app/") - .setSourcePath(actoolZipOut.getExecPathString()) - .build()); - } - - private void addBinAndLibWithRawResources() throws Exception { - addBinAndLibWithResources("resources", "resource1.txt", "ja.lproj/resource2.txt", - "objc_binary"); - } - - private void addBinAndLibWithStrings() throws Exception { - addBinAndLibWithResources("strings", "foo.strings", "ja.lproj/bar.strings", - "objc_binary"); - } - - @Test - public void testCollectsRawResourceFilesTransitively() throws Exception { - addBinAndLibWithRawResources(); - checkCollectsResourceFilesTransitively( - "//bin:bin", - ImmutableList.of("lib/resource1.txt", "bin/ja.lproj/resource2.txt"), - ImmutableList.of("lib/resource1.txt"), - ImmutableSetMultimap.<String, Multiset<String>>of( - "bin_bin", - ImmutableMultiset.of("bin/ja.lproj/resource2.txt", "lib/resource1.txt"), - "bin_static_lib_bin", - ImmutableMultiset.of("bin/ja.lproj/resource2.txt", "lib/resource1.txt"), - "lib_lib", - ImmutableMultiset.of("lib/resource1.txt"))); - } - - @Test - public void testCollectsStringsFilesTransitively() throws Exception { - addBinAndLibWithStrings(); - checkCollectsResourceFilesTransitively( - "//bin:bin", - ImmutableList.of("bin/lib/foo.strings.binary", "bin/bin/ja.lproj/bar.strings.binary"), - ImmutableList.of("lib/foo.strings.binary"), - ImmutableSetMultimap.<String, Multiset<String>>of( - "bin_bin", - ImmutableMultiset.of("bin/ja.lproj/bar.strings", "lib/foo.strings"), - "bin_static_lib_bin", - ImmutableMultiset.of("bin/ja.lproj/bar.strings", "lib/foo.strings"), - "lib_lib", - ImmutableMultiset.of("lib/foo.strings"))); - } - - @Test - public void testResourceFilesMergedInBundle() throws Exception { - addBinAndLibWithRawResources(); - checkBundleablesAreMerged("//bin:bin", - ImmutableListMultimap.of( - "resource1.txt", "resource1.txt", - "ja.lproj/resource2.txt", "ja.lproj/resource2.txt")); - } - - @Test - public void testStringsFilesMergedInBundle() throws Exception { - addBinAndLibWithStrings(); - checkBundleablesAreMerged("//bin:bin", - ImmutableListMultimap.of( - "foo.strings.binary", "foo.strings", - "ja.lproj/bar.strings.binary", "ja.lproj/bar.strings")); - } - - @Test - public void testLinksFrameworksOfSelfAndTransitiveDependencies() throws Exception { - checkLinksFrameworksOfSelfAndTransitiveDependencies(RULE_TYPE); - } - - @Test - public void testLinksWeakFrameworksOfSelfAndTransitiveDependencies() throws Exception { - checkLinksWeakFrameworksOfSelfAndTransitiveDependencies(RULE_TYPE); - } - - @Test - public void testMergesXcdatamodelZips() throws Exception { - checkMergesXcdatamodelZips(RULE_TYPE); - } - - @Test - public void testPlistRequiresDotInName() throws Exception { - checkError("x", "x", - "'//x:Infoplist' does not produce any objc_binary infoplist files (expected .plist)", - "objc_binary(", - " name = 'x',", - " srcs = ['a.m'],", - " infoplist = 'Infoplist'", - ")"); - } - - @Test - public void testLinkIncludeOrder_staticLibsFirst() throws Exception { - checkLinkIncludeOrderStaticLibsFirst(RULE_TYPE); - } - - @Test - public void testLinksDylibsTransitively() throws Exception { - checkLinksDylibsTransitively(RULE_TYPE); - } - - @Test - public void testPopulatesCompilationArtifacts() throws Exception { - checkPopulatesCompilationArtifacts(RULE_TYPE); - } - - @Test - public void testArchivesPrecompiledObjectFiles() throws Exception { - checkArchivesPrecompiledObjectFiles(RULE_TYPE); - } - - @Test - public void testPopulatesBundling() throws Exception { - checkPopulatesBundling(RULE_TYPE); - } - - @Test - public void testRegistersStoryboardCompilationActions() throws Exception { - checkRegistersStoryboardCompileActions(RULE_TYPE, "iphone"); - } - - @Test - public void testSwiftStdlibActions() throws Exception { - checkRegisterSwiftStdlibActions(RULE_TYPE, "iphonesimulator"); - } - - @Test - public void testSwiftStdlibActionsWithToolchain() throws Exception { - useConfiguration("--xcode_toolchain=test_toolchain"); - checkRegisterSwiftStdlibActions(RULE_TYPE, "iphonesimulator", "test_toolchain"); - } - - @Test - public void testRegistersSwiftSupportActions() throws Exception { - checkRegisterSwiftSupportActions(RULE_TYPE, "iphonesimulator"); - } - - @Test - public void testRegistersSwiftSupportActionsWithToolchain() throws Exception { - useConfiguration("--xcode_toolchain=test_toolchain"); - checkRegisterSwiftSupportActions(RULE_TYPE, "iphonesimulator", "test_toolchain"); - } - - @Test - public void testErrorsWrongFileTypeForSrcsWhenCompiling() throws Exception { - checkErrorsWrongFileTypeForSrcsWhenCompiling(RULE_TYPE); - } - - @Test - public void testObjcCopts() throws Exception { - checkObjcCopts(RULE_TYPE); - } - - @Test - public void testObjcCopts_argumentOrdering() throws Exception { - checkObjcCopts_argumentOrdering(RULE_TYPE); - } - - @Test - public void testMergesActoolPartialInfoplist() throws Exception { - checkMergesPartialInfoplists(RULE_TYPE); - } - - @Test - public void checkDefinesFromCcLibraryDep() throws Exception { - checkDefinesFromCcLibraryDep(RULE_TYPE); - } - - @Test - public void testCompileXibActions() throws Exception { - checkCompileXibActions(RULE_TYPE); - } - - @Test - public void testNibZipsMergedIntoBundle() throws Exception { - checkNibZipsMergedIntoBundle(RULE_TYPE); - } - - @Test - public void testAllowVariousNonBlacklistedTypesInHeaders() throws Exception { - checkAllowVariousNonBlacklistedTypesInHeaders(RULE_TYPE); - } - - @Test - public void testWarningForBlacklistedTypesInHeaders() throws Exception { - checkWarningForBlacklistedTypesInHeaders(RULE_TYPE); - } - - @Test - public void testCppSourceCompilesWithCppFlags() throws Exception { - checkCppSourceCompilesWithCppFlags(RULE_TYPE); - } - - @Test - public void testPassesFallbackBundleIdToBundleMerging() throws Exception { - checkBundleIdPassedAsFallbackId(RULE_TYPE); - } - - @Test - public void testPassesPrimaryBundleIdToBundleMerging() throws Exception { - checkBundleIdPassedAsPrimaryId(RULE_TYPE); - } - - @Test - public void testNestedBundleIdIsNotAffectedByParent() throws Exception { - scratch.file("bndl/BUILD", - "objc_bundle_library(", - " name = 'bndl',", - ")"); - - createLibraryTargetWriter("//lib:lib") - .setAndCreateFiles("hdrs", "lib.h") - .setList("bundles", "//bndl:bndl") - .write(); - - createBinaryTargetWriter("//bin:bin") - .setAndCreateFiles("srcs", "a.m") - .setList("deps", "//lib:lib") - .set("bundle_id", "'com.main.bundle'") - .write(); - - BundleMergeProtos.Control control = bundleMergeControl("//bin:bin"); - - assertThat(control.getPrimaryBundleIdentifier()).isEqualTo("com.main.bundle"); - // The nested bndl should not get its parent's bundle_id - assertThat(control.getNestedBundleList().get(0).getPrimaryBundleIdentifier()) - .isNotEqualTo("com.main.bundle"); - } - - @Test - public void testAutomaticPlistEntries() throws Exception { - checkAutomaticPlistEntries(RULE_TYPE); - } - - @Test - public void testBundleMergeInputContainsPlMergeOutput() throws Exception { - checkBundleMergeInputContainsPlMergeOutput(RULE_TYPE); - } - - @Test - public void testMultipleInfoPlists() throws Exception { - checkMultipleInfoPlists(RULE_TYPE); - } - - @Test - public void testInfoplistAndInfoplistsTogether() throws Exception { - checkInfoplistAndInfoplistsTogether(RULE_TYPE); - } - - @Test - public void testLinkOpts() throws Exception { - checkLinkopts(RULE_TYPE); - } - - @Test - public void testProtoBundlingAndLinking() throws Exception { - checkProtoBundlingAndLinking(RULE_TYPE); - } - - @Test - public void testProtoBundlingWithTargetsWithNoDeps() throws Exception { - checkProtoBundlingWithTargetsWithNoDeps(RULE_TYPE); - } - - @Test - public void testCanUseCrosstool() throws Exception { - checkLinkingRuleCanUseCrosstool(RULE_TYPE); - } - - @Test - public void testBinaryStrippings() throws Exception { - checkBinaryStripAction(RULE_TYPE); - } - - @Test - public void testAppleSdkVersionEnv() throws Exception { - addMockBinAndLibs(ImmutableList.of("a.m")); - CommandAction action = linkAction("//bin:bin"); - - assertAppleSdkVersionEnv(action); - } - - @Test - public void testNonDefaultAppleSdkVersionEnv() throws Exception { - useConfiguration("--ios_sdk_version=8.1"); - - addMockBinAndLibs(ImmutableList.of("a.m")); - CommandAction action = linkAction("//bin:bin"); - - assertAppleSdkVersionEnv(action, "8.1"); - } - - @Test - public void testAppleSdkDefaultPlatformEnv() throws Exception { - addMockBinAndLibs(ImmutableList.of("a.m")); - CommandAction action = linkAction("//bin:bin"); - - assertAppleSdkPlatformEnv(action, "iPhoneSimulator"); - } - - @Test - public void testAppleSdkDevicePlatformEnv() throws Exception { - useConfiguration("--cpu=ios_arm64"); - - addMockBinAndLibs(ImmutableList.of("a.m")); - CommandAction action = linkAction("//bin:bin"); - - assertAppleSdkPlatformEnv(action, "iPhoneOS"); - } - - @Test - public void testMergeBundleActionsWithNestedBundle() throws Exception { - checkMergeBundleActionsWithNestedBundle(RULE_TYPE); - } - - @Test - public void testIncludesStoryboardOutputZipsAsMergeZips() throws Exception { - checkIncludesStoryboardOutputZipsAsMergeZips(RULE_TYPE); - } - - @Test - public void testCompilationActionsForDebug() throws Exception { - checkClangCoptsForCompilationMode(RULE_TYPE, CompilationMode.DBG, CodeCoverageMode.NONE); - } - - @Test - public void testClangCoptsForDebugModeWithoutGlib() throws Exception { - checkClangCoptsForDebugModeWithoutGlib(RULE_TYPE); - } - - @Test - public void testCompilationActionsForOptimized() throws Exception { - checkClangCoptsForCompilationMode(RULE_TYPE, CompilationMode.OPT, CodeCoverageMode.NONE); - } - - @Test - public void testCcDependency() throws Exception { - checkCcDependency(RULE_TYPE); - } - - @Test - public void testLinkActionCorrect() throws Exception { - checkLinkActionCorrect(RULE_TYPE, new ExtraLinkArgs()); - } - - @Test - public void testFrameworkDepLinkFlags() throws Exception { - checkFrameworkDepLinkFlags(RULE_TYPE, new ExtraLinkArgs()); - } - - @Test - public void testLinkActionsWithEmbeddedBitcode() throws Exception { - useConfiguration("--apple_bitcode=embedded", "--ios_multi_cpus=arm64"); - createBinaryTargetWriter("//objc:bin").setAndCreateFiles("srcs", "a.m").write(); - - CommandAction linkAction = linkAction("//objc:bin"); - String commandLine = Joiner.on(" ").join(linkAction.getArguments()); - - assertThat(commandLine).contains("-fembed-bitcode"); - assertThat(commandLine).contains("-Xlinker -bitcode_verify"); - assertThat(commandLine).contains("-Xlinker -bitcode_hide_symbols"); - } - - @Test - public void testLinkActionsWithEmbeddedBitcodeMarkers() throws Exception { - useConfiguration("--apple_bitcode=embedded_markers", "--ios_multi_cpus=arm64"); - createBinaryTargetWriter("//objc:bin").setAndCreateFiles("srcs", "a.m").write(); - - CommandAction linkAction = linkAction("//objc:bin"); - - assertThat(Joiner.on(" ").join(linkAction.getArguments())).contains("-fembed-bitcode-marker"); - } - - @Test - public void testCompilationActionsForDebugInGcovCoverage() throws Exception { - checkClangCoptsForCompilationMode(RULE_TYPE, CompilationMode.DBG, - CodeCoverageMode.GCOV); - } - - @Test - public void testCompilationActionsForDebugInLlvmCovCoverage() throws Exception { - checkClangCoptsForCompilationMode(RULE_TYPE, CompilationMode.DBG, - CodeCoverageMode.LLVMCOV); - } - - @Test - public void testCompilationActionsForOptimizedInGcovCoverage() throws Exception { - checkClangCoptsForCompilationMode(RULE_TYPE, CompilationMode.OPT, - CodeCoverageMode.GCOV); - } - - @Test - public void testCompilationActionsForOptimizedInLlvmCovCoverage() throws Exception { - checkClangCoptsForCompilationMode(RULE_TYPE, CompilationMode.OPT, - CodeCoverageMode.LLVMCOV); - } - - @Test - public void testXcodeVersionEnv() throws Exception { - useConfiguration("--xcode_version=5.8"); - - addMockBinAndLibs(ImmutableList.of("a.m")); - CommandAction action = linkAction("//bin:bin"); - - assertXcodeVersionEnv(action, "5.8"); - } - - @Test - public void testCompileWithTextualHeaders() throws Exception { - checkCompileWithTextualHeaders(RULE_TYPE); - } - - @Test - public void testCompilesWithHdrs() throws Exception { - checkCompilesWithHdrs(RULE_TYPE); - } - - @Test - public void testCompilesSources() throws Exception { - checkCompilesSources(RULE_TYPE); - } - - @Test - public void testLinkActionWithTransitiveCppDependency() throws Exception { - checkLinkActionWithTransitiveCppDependency(RULE_TYPE, new ExtraLinkArgs()); - } - - @Test - public void testLinkWithFrameworkImportsIncludesFlagsAndInputArtifacts() throws Exception { - checkLinkWithFrameworkImportsIncludesFlagsAndInputArtifacts(RULE_TYPE); - } - - @Test - public void testForceLoadsAlwayslinkTargets() throws Exception { - checkForceLoadsAlwayslinkTargets(RULE_TYPE, new ExtraLinkArgs()); - } - - @Test - public void testReceivesTransitivelyPropagatedDefines() throws Exception { - checkReceivesTransitivelyPropagatedDefines(RULE_TYPE); - } - - @Test - public void testSdkIncludesUsedInCompileAction() throws Exception { - checkSdkIncludesUsedInCompileAction(RULE_TYPE); - } - - @Test - public void testCreate_debugSymbolActionWithAppleFlag() throws Exception { - useConfiguration("--apple_generate_dsym"); - RULE_TYPE.scratchTarget(scratch, "srcs", "['a.m']"); - ConfiguredTarget target = getConfiguredTarget("//x:x"); - - Artifact artifact = getBinArtifact("x.app.dSYM.temp.zip", target); - String execPath = artifact.getExecPath().getParentDirectory().toString(); - CommandAction linkAction = (CommandAction) getGeneratingAction(artifact); - assertThat(linkAction.getArguments()).containsAllOf( - "DSYM_HINT_LINKED_BINARY=" + execPath + "/x_bin", - "DSYM_HINT_DSYM_PATH=" + execPath + "/x.app.dSYM.temp", - "DSYM_HINT_DSYM_BUNDLE_ZIP=" + artifact.getExecPathString()); - - Artifact plistArtifact = getBinArtifact("x.app.dSYM/Contents/Info.plist", target); - Artifact debugSymbolArtifact = - getBinArtifact("x.app.dSYM/Contents/Resources/DWARF/x_bin", target); - SpawnAction plistAction = (SpawnAction) getGeneratingAction(plistArtifact); - SpawnAction debugSymbolAction = (SpawnAction) getGeneratingAction(debugSymbolArtifact); - assertThat(debugSymbolAction).isEqualTo(plistAction); - - String dsymUnzipActionArg = - "unzip -p " - + execPath - + "/x.app.dSYM.temp.zip" - + " Contents/Info.plist > " - + plistArtifact.getExecPathString() - + " && unzip -p " - + execPath - + "/x.app.dSYM.temp.zip" - + " Contents/Resources/DWARF/x_bin > " - + debugSymbolArtifact.getExecPathString(); - assertThat(plistAction.getArguments()).contains(dsymUnzipActionArg); - } - - @Test - public void testTargetHasDebugSymbols() throws Exception { - checkTargetHasDebugSymbols(RULE_TYPE); - } - - @Test - public void testFilesToCompileOutputGroup() throws Exception { - checkFilesToCompileOutputGroup(RULE_TYPE); - } - - @Test - public void testCustomModuleMap() throws Exception { - checkCustomModuleMap(RULE_TYPE); - } - - @Test - public void testGenruleDependency() throws Exception { - checkGenruleDependency(RULE_TYPE); - } -} diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcBundleLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcBundleLibraryTest.java index 8f7e2862db..a076ba852f 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcBundleLibraryTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcBundleLibraryTest.java @@ -19,10 +19,7 @@ import static com.google.devtools.build.lib.rules.objc.ObjcProvider.NESTED_BUNDL 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.testutil.Scratch; -import com.google.devtools.build.xcode.bundlemerge.proto.BundleMergeProtos; -import com.google.devtools.build.xcode.plmerge.proto.PlMergeProtos; import java.io.IOException; import java.util.Set; import org.junit.Test; @@ -67,85 +64,6 @@ public class ObjcBundleLibraryTest extends ObjcRuleTestCase { } @Test - public void testProvidesBundling() throws Exception { - addBundleWithResource(); - scratch.file( - "bin/BUILD", - "objc_binary(", - " name = 'bin',", - " srcs = ['bin.m'],", - " bundles = ['//bndl:bndl'],", - ")"); - BundleMergeProtos.Control mergeControl = bundleMergeControl("//bin:bin"); - BundleMergeProtos.Control nestedControl = - Iterables.getOnlyElement(mergeControl.getNestedBundleList()); - BundleMergeProtos.BundleFile bundleFile = - BundleMergeProtos.BundleFile.newBuilder() - .setBundlePath("foo.data") - .setSourceFile(getSourceArtifact("bndl/foo.data").getExecPathString()) - .setExternalFileAttribute(BundleableFile.DEFAULT_EXTERNAL_FILE_ATTRIBUTE) - .build(); - - // Should put resource in .bundle directory, not bundle root (.app dir) - assertThat(nestedControl.getBundleFileList()).containsExactly(bundleFile); - assertThat(mergeControl.getBundleFileList()).doesNotContain(bundleFile); - } - - @Test - public void testDoesNotMergeInfoplistOfNestedBundle() throws Exception { - scratch.file("bndl1/bndl1-Info.plist"); - scratch.file("bndl1/BUILD", - "objc_bundle_library(", - " name = 'bndl1',", - " infoplist = 'bndl1-Info.plist',", - ")"); - scratch.file("bndl2/bndl2-Info.plist"); - scratch.file("bndl2/BUILD", - "objc_bundle_library(", - " name = 'bndl2',", - " bundles = ['//bndl1:bndl1'],", - " infoplist = 'bndl2-Info.plist',", - ")"); - scratch.file("bin/bin-Info.plist"); - scratch.file("bin/bin.m"); - scratch.file("bin/BUILD", - "objc_binary(", - " name = 'bin',", - " srcs = ['bin.m'],", - " bundles = ['//bndl2:bndl2'],", - " infoplist = 'bin-Info.plist'", - ")"); - Artifact bundle1Infoplist = getSourceArtifact("bndl1/bndl1-Info.plist"); - Artifact bundle2Infoplist = getSourceArtifact("bndl2/bndl2-Info.plist"); - Artifact binaryInfoplist = getSourceArtifact("bin/bin-Info.plist"); - Artifact binaryMergedInfoplist = getMergedInfoPlist(getConfiguredTarget("//bin:bin")); - - PlMergeProtos.Control binaryPlMergeControl = plMergeControl("//bin:bin"); - - assertThat(binaryPlMergeControl.getSourceFileList()) - .contains(binaryInfoplist.getExecPathString()); - assertThat(binaryPlMergeControl.getSourceFileList()) - .containsNoneOf(bundle1Infoplist.getExecPathString(), bundle2Infoplist.getExecPathString()); - - assertThat(bundleMergeAction("//bin:bin").getInputs()) - .containsAllOf(bundle1Infoplist, bundle2Infoplist, binaryMergedInfoplist); - - BundleMergeProtos.Control binControl = bundleMergeControl("//bin:bin"); - assertThat(binControl.getBundleInfoPlistFile()) - .isEqualTo(binaryMergedInfoplist.getExecPathString()); - - BundleMergeProtos.Control bundle2Control = - Iterables.getOnlyElement(binControl.getNestedBundleList()); - assertThat(bundle2Control.getBundleInfoPlistFile()) - .isEqualTo(bundle2Infoplist.getExecPathString()); - - BundleMergeProtos.Control bundle1Control = - Iterables.getOnlyElement(bundle2Control.getNestedBundleList()); - assertThat(bundle1Control.getBundleInfoPlistFile()) - .isEqualTo(bundle1Infoplist.getExecPathString()); - } - - @Test public void testRegistersStoryboardCompilationActions() throws Exception { checkRegistersStoryboardCompileActions(RULE_TYPE, "iphone"); } diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcFrameworkTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcFrameworkTest.java index e4a9dded52..6e90760563 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcFrameworkTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcFrameworkTest.java @@ -25,10 +25,7 @@ import static com.google.devtools.build.lib.rules.objc.ObjcProvider.WEAK_SDK_FRA import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.devtools.build.lib.analysis.ConfiguredTarget; -import com.google.devtools.build.lib.analysis.actions.SpawnAction; import com.google.devtools.build.lib.vfs.PathFragment; -import com.google.devtools.build.xcode.bundlemerge.proto.BundleMergeProtos; -import com.google.devtools.build.xcode.bundlemerge.proto.BundleMergeProtos.BundleFile; import java.util.Set; import org.junit.Test; import org.junit.runner.RunWith; @@ -226,94 +223,4 @@ public class ObjcFrameworkTest extends ObjcRuleTestCase { " })", ")"); } - - @Test - public void testDynamicFrameworkInFinalBundle() throws Exception { - scratch.file("x/Foo.framework/Foo"); - scratch.file("x/Foo.framework/Info.plist"); - scratch.file("x/Foo.framework/Headers/Foo.h"); - scratch.file("x/Foo.framework/Resources/bar.png"); - scratch.file( - "x/BUILD", - "objc_framework(", - " name = 'foo_framework',", - " framework_imports = glob(['Foo.framework/**']),", - " is_dynamic = 1,", - ")", - "", - "objc_binary(", - " name = 'bin',", - " srcs = [ 'a.m' ],", - " deps = [ ':foo_framework' ],", - ")", - "", - "ios_application(", - " name = 'x',", - " binary = ':bin',", - ")"); - - BundleMergeProtos.Control mergeControl = bundleMergeControl("//x:x"); - - assertThat(mergeControl.getBundleFileList()) - .containsAllOf( - BundleFile.newBuilder() - .setBundlePath("Frameworks/Foo.framework/Foo") - .setSourceFile(getSourceArtifact("x/Foo.framework/Foo").getExecPathString()) - .setExternalFileAttribute(BundleableFile.EXECUTABLE_EXTERNAL_FILE_ATTRIBUTE) - .build(), - BundleFile.newBuilder() - .setBundlePath("Frameworks/Foo.framework/Info.plist") - .setSourceFile(getSourceArtifact("x/Foo.framework/Info.plist").getExecPathString()) - .setExternalFileAttribute(BundleableFile.EXECUTABLE_EXTERNAL_FILE_ATTRIBUTE) - .build(), - BundleFile.newBuilder() - .setBundlePath("Frameworks/Foo.framework/Resources/bar.png") - .setSourceFile( - getSourceArtifact("x/Foo.framework/Resources/bar.png").getExecPathString()) - .setExternalFileAttribute(BundleableFile.DEFAULT_EXTERNAL_FILE_ATTRIBUTE) - .build()); - - assertThat(mergeControl.getBundleFileList()) - .doesNotContain( - BundleFile.newBuilder() - .setBundlePath("Frameworks/Foo.framework/Headers/Foo.h") - .setSourceFile( - getSourceArtifact("x/Foo.framework/Headers/Foo.h").getExecPathString()) - .setExternalFileAttribute(BundleableFile.DEFAULT_EXTERNAL_FILE_ATTRIBUTE) - .build()); - } - - @Test - public void testDynamicFrameworkSigned() throws Exception { - useConfiguration("--ios_cpu=arm64"); - - scratch.file("x/Foo.framework/Foo"); - scratch.file("x/Foo.framework/Info.plist"); - scratch.file("x/Foo.framework/Headers/Foo.h"); - scratch.file("x/Foo.framework/Resources/bar.png"); - scratch.file( - "x/BUILD", - "objc_framework(", - " name = 'foo_framework',", - " framework_imports = glob(['Foo.framework/**']),", - " is_dynamic = 1,", - ")", - "", - "objc_binary(", - " name = 'bin',", - " srcs = [ 'a.m' ],", - " deps = [ ':foo_framework' ],", - ")", - "", - "ios_application(", - " name = 'x',", - " binary = ':bin',", - ")"); - - SpawnAction signingAction = (SpawnAction) ipaGeneratingAction(); - - assertThat(normalizeBashArgs(signingAction.getArguments())) - .containsAllOf("--sign", "${t}/Payload/x.app/Frameworks/*", "--sign", "${t}/Payload/x.app") - .inOrder(); - } } diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcImportTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcImportTest.java index fd3e065a6b..d312405810 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcImportTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcImportTest.java @@ -122,12 +122,6 @@ public class ObjcImportTest extends ObjcRuleTestCase { public void testProvidesStoryboardObjects() throws Exception { checkProvidesStoryboardObjects(RULE_TYPE); } - - @Test - public void testNestedBundleInformationPropagatedToDependers() throws Exception { - checkNestedBundleInformationPropagatedToDependers(RULE_TYPE); - } - @Test public void testSdkIncludesUsedInCompileActionsOfDependers() throws Exception { checkSdkIncludesUsedInCompileActionsOfDependers(RULE_TYPE); diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java index 4e426c3d5e..0803dd0756 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcLibraryTest.java @@ -1229,11 +1229,6 @@ public class ObjcLibraryTest extends ObjcRuleTestCase { } @Test - public void testBundleInformationPropagatedThroughLibraries() throws Exception { - checkNestedBundleInformationPropagatedToDependers(RULE_TYPE); - } - - @Test public void testAppleSdkVersionEnv() throws Exception { createLibraryTargetWriter("//objc:lib") .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") @@ -1639,15 +1634,17 @@ public class ObjcLibraryTest extends ObjcRuleTestCase { public void testApplePlatformEnvForCcLibraryDep() throws Exception { useConfiguration("--cpu=ios_i386"); - scratch.file("package/BUILD", + scratch.file( + "package/BUILD", "cc_library(", " name = 'cc_lib',", " srcs = ['a.cc'],", ")", "", - "objc_binary(", + "apple_binary(", " name = 'objc_bin',", " srcs = ['b.m'],", + " platform_type = 'ios',", " deps = [':cc_lib'],", ")"); 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 35adffbd07..ae80e06379 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 @@ -19,10 +19,10 @@ import static com.google.common.truth.Truth.assertThat; 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.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.vfs.PathFragment; import org.junit.Before; import org.junit.Test; @@ -31,7 +31,7 @@ import org.junit.runners.JUnit4; /** Test case for the objc_proto_library aspect. */ @RunWith(JUnit4.class) -public final class ObjcProtoAspectTest extends BuildViewTestCase { +public final class ObjcProtoAspectTest extends ObjcRuleTestCase { @Before public final void initializeToolsConfigMock() throws Exception { @@ -80,8 +80,8 @@ public final class ObjcProtoAspectTest extends BuildViewTestCase { PathFragment includePath = header.getExecPath().getParentDirectory(); PathFragment genIncludePath = PathFragment.create( - getConfiguration(targetConfig, AppleCrosstoolTransition.APPLE_CROSSTOOL_TRANSITION) - .getGenfilesFragment() + configurationGenfiles( + "x86_64", ConfigurationDistinguisher.APPLEBIN_IOS, DEFAULT_IOS_SDK_VERSION) + "/" + includePath); @@ -163,8 +163,8 @@ public final class ObjcProtoAspectTest extends BuildViewTestCase { assertThat(Artifact.toExecPaths(objcProtoProvider.getPortableProtoFilters())) .containsExactly( - getConfiguration(targetConfig, AppleCrosstoolTransition.APPLE_CROSSTOOL_TRANSITION) - .getGenfilesFragment() + configurationGenfiles( + "x86_64", ConfigurationDistinguisher.APPLEBIN_IOS, DEFAULT_IOS_SDK_VERSION) + "/x/_proto_filters/objc_proto/generated_filter_file.pbascii"); } @@ -206,15 +206,17 @@ public final class ObjcProtoAspectTest extends BuildViewTestCase { assertThat(Artifact.toExecPaths(objcProtoProvider.getPortableProtoFilters())) .containsAllOf( "x/filter.pbascii", - getConfiguration(targetConfig, AppleCrosstoolTransition.APPLE_CROSSTOOL_TRANSITION) - .getGenfilesFragment() + configurationGenfiles( + "x86_64", ConfigurationDistinguisher.APPLEBIN_IOS, DEFAULT_IOS_SDK_VERSION) + "/x/_proto_filters/objc_proto_2/generated_filter_file.pbascii"); } private ConfiguredTarget getObjcProtoAspectConfiguredTarget(String label) throws Exception { - scratch.file("bin/BUILD", - "objc_binary(", + scratch.file( + "bin/BUILD", + "apple_binary(", " name = 'link_target',", + " platform_type = 'ios',", " deps = ['" + label + "'],", ")"); diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java index b28980800f..631eaf77c3 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java @@ -205,8 +205,6 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase { switch (configurationDistinguisher) { case UNKNOWN: return String.format("%s-out/ios_%s-fastbuild/", TestConstants.PRODUCT_NAME, arch); - case IOS_EXTENSION: // Intentional fall-through. - case IOS_APPLICATION: case APPLEBIN_IOS: return String.format( "%1$s-out/ios-%2$s-min%4$s-%3$s-ios_%2$s-fastbuild/", @@ -249,15 +247,13 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase { protected static String iosConfigurationCcDepsBin( String arch, ConfigurationDistinguisher configurationDistinguisher) { switch (configurationDistinguisher) { - case IOS_EXTENSION: case APPLEBIN_IOS: return String.format( "%s-out/%s-ios_%s-fastbuild/bin/", TestConstants.PRODUCT_NAME, configurationDistinguisher.toString().toLowerCase(Locale.US), arch); - case UNKNOWN: // Intentional fall-through. - case IOS_APPLICATION: + case UNKNOWN: return String.format("%s-out/ios_%s-fastbuild/bin/", TestConstants.PRODUCT_NAME, arch); default: throw new AssertionError(); @@ -272,9 +268,6 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase { ConfigurationDistinguisher configurationDistinguisher) { switch (configurationDistinguisher) { case UNKNOWN: - case IOS_EXTENSION: - return IosExtension.EXTENSION_MINIMUM_OS_VERSION; - case IOS_APPLICATION: case APPLEBIN_IOS: return DEFAULT_IOS_SDK_VERSION; case APPLEBIN_WATCHOS: @@ -322,11 +315,10 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase { return ScratchAttributeWriter.fromLabelString(this, "objc_library", labelString); } - /** - * Creates an {@code objc_binary} target writer for the label indicated by the given String. - */ + /** Creates an {@code apple_binary} target writer for the label indicated by the given String. */ protected ScratchAttributeWriter createBinaryTargetWriter(String labelString) { - return ScratchAttributeWriter.fromLabelString(this, "objc_binary", labelString); + return ScratchAttributeWriter.fromLabelString(this, "apple_binary", labelString) + .set("platform_type", "'ios'"); } private static String compilationModeFlag(CompilationMode mode) { @@ -2767,17 +2759,23 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase { .write(); String sdkIncludeDir = AppleToolchain.sdkDir() + "/usr/include"; + CommandAction archiveAction = archiveAction("//lib:lib"); + Artifact aObj = getFirstArtifactEndingWith(archiveAction.getInputs(), "a.o"); + CommandAction aCompileAction = (CommandAction) getGeneratingAction(aObj); + // We remove spaces because the crosstool case does not use spaces for include paths. - String compileAArgs = Joiner.on("") - .join(compileAction("//lib:lib", "a.o").getArguments()) - .replace(" ", ""); + String compileAArgs = Joiner.on("").join(aCompileAction.getArguments()).replace(" ", ""); assertThat(compileAArgs).contains("-I" + sdkIncludeDir + "/from_lib"); assertThat(compileAArgs).contains("-I" + sdkIncludeDir + "/foo"); assertThat(compileAArgs).contains("-I" + sdkIncludeDir + "/bar/baz"); - String compileBArgs = Joiner.on("") - .join(compileAction("//bin:bin", "b.o").getArguments()) - .replace(" ", ""); + CommandAction linkAction = linkAction("//bin:bin"); + Artifact binLib = getFirstArtifactEndingWith(linkAction.getInputs(), "libbin.a"); + CommandAction binArchiveAction = (CommandAction) getGeneratingAction(binLib); + Artifact bObj = getFirstArtifactEndingWith(binArchiveAction.getInputs(), "b.o"); + CommandAction bCompileAction = (CommandAction) getGeneratingAction(bObj); + + String compileBArgs = Joiner.on("").join(bCompileAction.getArguments()).replace(" ", ""); assertThat(compileBArgs).contains("-I" + sdkIncludeDir + "/from_bin"); assertThat(compileBArgs).contains("-I" + sdkIncludeDir + "/from_lib"); assertThat(compileBArgs).contains("-I" + sdkIncludeDir + "/foo"); @@ -3257,45 +3255,6 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase { assertThat(control.getBundleFileList()).containsAllIn(expectedBundleFiles); } - protected void checkNestedBundleInformationPropagatedToDependers(RuleType ruleType) - throws Exception { - scratch.file("bndl/bndl-Info.plist"); - scratch.file("bndl/bndl.png"); - scratch.file("bndl/BUILD", - "objc_bundle_library(", - " name = 'bndl',", - " infoplist = 'bndl-Info.plist',", - " resources = ['bndl.png'],", - ")"); - - ruleType.scratchTarget(scratch, "bundles", "['//bndl:bndl']"); - - scratch.file("bin/bin.m"); - scratch.file("bin/BUILD", - "objc_binary(", - " name = 'bin',", - " srcs = ['bin.m'],", - " deps = ['//x:x'],", - ")"); - - assertThat(bundleMergeAction("//bin:bin").getInputs()) - .containsAllOf( - getSourceArtifact("bndl/bndl-Info.plist"), getSourceArtifact("bndl/bndl.png")); - - BundleMergeProtos.Control binControl = bundleMergeControl("//bin:bin"); - BundleMergeProtos.Control bundleControl = - Iterables.getOnlyElement(binControl.getNestedBundleList()); - - assertThat(bundleControl.getBundleInfoPlistFile()).isEqualTo("bndl/bndl-Info.plist"); - - assertThat(bundleControl.getBundleFileList()) - .containsExactly(BundleMergeProtos.BundleFile.newBuilder() - .setBundlePath("bndl.png") - .setSourceFile("bndl/bndl.png") - .setExternalFileAttribute(BundleableFile.DEFAULT_EXTERNAL_FILE_ATTRIBUTE) - .build()); - } - protected void checkConvertStringsAction(BinaryRuleTypePair ruleTypePair) throws Exception { scratch.file("lib/foo.strings"); scratch.file("lib/es.lproj/bar.strings"); diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcSkylarkTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcSkylarkTest.java index a5453e5b51..e45e623ceb 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcSkylarkTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcSkylarkTest.java @@ -203,8 +203,9 @@ public class ObjcSkylarkTest extends ObjcRuleTestCase { " srcs = ['a.m'],", " defines = ['mock_define']", ")", - "objc_binary(", + "apple_binary(", " name = 'bin',", + " platform_type = 'ios',", " deps = [':my_target']", ")"); @@ -240,8 +241,9 @@ public class ObjcSkylarkTest extends ObjcRuleTestCase { " srcs = ['a.m'],", " deps = [':my_target']", ")", - "objc_binary(", + "apple_binary(", " name = 'bin',", + " platform_type = 'ios',", " deps = [':lib']", ")"); |