diff options
author | cpeyser <cpeyser@google.com> | 2017-11-03 18:42:59 +0100 |
---|---|---|
committer | Damien Martin-Guillerez <dmarting@google.com> | 2017-11-06 20:19:54 +0100 |
commit | 2a41993d1c2967ee64e7e1c50955de1684f71d73 (patch) | |
tree | 1e22c53f9ce0d5541f4665d58d6379ba0ede322c /src/test/java/com/google/devtools | |
parent | 79fb46712975935a7517d8fdf6e0011b4b8df710 (diff) |
Remove legacy implementation of objc compilation/archiving/linking.
PiperOrigin-RevId: 174481563
Diffstat (limited to 'src/test/java/com/google/devtools')
22 files changed, 13 insertions, 1123 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/AppleBinaryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/AppleBinaryTest.java index 33c5e26218..e12739d7d2 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/AppleBinaryTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/AppleBinaryTest.java @@ -35,7 +35,6 @@ 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.objc.AppleBinary.BinaryType; import com.google.devtools.build.lib.rules.objc.CompilationSupport.ExtraLinkArgs; -import com.google.devtools.build.lib.rules.objc.ObjcCommandLineOptions.ObjcCrosstoolMode; import com.google.devtools.build.lib.syntax.SkylarkDict; import com.google.devtools.build.lib.testutil.Scratch; import com.google.devtools.build.lib.vfs.PathFragment; @@ -795,7 +794,6 @@ public class AppleBinaryTest extends ObjcRuleTestCase { @Test public void testLinksImplicitFrameworksWithCrosstoolIos() throws Exception { useConfiguration( - ObjcCrosstoolMode.ALL, "--ios_multi_cpus=x86_64", "--ios_sdk_version=10.0", "--ios_minimum_os=8.0"); @@ -811,7 +809,6 @@ public class AppleBinaryTest extends ObjcRuleTestCase { @Test public void testLinksImplicitFrameworksWithCrosstoolWatchos() throws Exception { useConfiguration( - ObjcCrosstoolMode.ALL, "--watchos_cpus=i386", "--watchos_sdk_version=3.0", "--watchos_minimum_os=2.0"); @@ -827,7 +824,6 @@ public class AppleBinaryTest extends ObjcRuleTestCase { @Test public void testLinksImplicitFrameworksWithCrosstoolTvos() throws Exception { useConfiguration( - ObjcCrosstoolMode.ALL, "--tvos_cpus=x86_64", "--tvos_sdk_version=10.1", "--tvos_minimum_os=10.0"); @@ -843,7 +839,6 @@ public class AppleBinaryTest extends ObjcRuleTestCase { @Test public void testLinksImplicitFrameworksWithCrosstoolMacos() throws Exception { useConfiguration( - ObjcCrosstoolMode.ALL, "--macos_cpus=x86_64", "--macos_sdk_version=10.11", "--macos_minimum_os=10.11"); @@ -861,7 +856,6 @@ public class AppleBinaryTest extends ObjcRuleTestCase { @Test public void testLinkCocoaFeatureWithCrosstoolMacos() throws Exception { useConfiguration( - ObjcCrosstoolMode.ALL, "--macos_cpus=x86_64", "--macos_sdk_version=10.11", "--macos_minimum_os=10.11"); diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/AppleStaticLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/AppleStaticLibraryTest.java index 80ffb24d51..a66dca4e8d 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/AppleStaticLibraryTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/AppleStaticLibraryTest.java @@ -27,8 +27,6 @@ import com.google.devtools.build.lib.actions.CommandAction; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.actions.SymlinkAction; import com.google.devtools.build.lib.rules.apple.AppleConfiguration.ConfigurationDistinguisher; -import com.google.devtools.build.lib.rules.cpp.CppLinkAction; -import com.google.devtools.build.lib.rules.objc.ObjcCommandLineOptions.ObjcCrosstoolMode; import com.google.devtools.build.lib.testutil.Scratch; import java.io.IOException; import java.util.Set; @@ -89,32 +87,6 @@ public class AppleStaticLibraryTest extends ObjcRuleTestCase { } @Test - public void testCanUseCrosstool() throws Exception { - useConfiguration(ObjcCrosstoolMode.ALL); - RULE_TYPE.scratchTarget(scratch); - - // If the target is indeed using the c++ backend, then its archive action should be a - // CppLinkAction. - Action lipoLibAction = lipoLibAction("//x:x"); - Artifact archive = getFirstArtifactEndingWith(lipoLibAction.getInputs(), ".a"); - Action archiveAction = getGeneratingAction(archive); - assertThat(archiveAction).isInstanceOf(CppLinkAction.class); - } - - @Test - public void testCanUseCrosstool_multiArch() throws Exception { - useConfiguration(ObjcCrosstoolMode.ALL, "--ios_multi_cpus=i386,x86_64"); - RULE_TYPE.scratchTarget(scratch); - - // If the target is indeed using the c++ backend, then its archive action should be a - // CppLinkAction. - Action lipoLibAction = lipoLibAction("//x:x"); - Artifact archive = getFirstArtifactEndingWith(lipoLibAction.getInputs(), ".a"); - Action archiveAction = getGeneratingAction(archive); - assertThat(archiveAction).isInstanceOf(CppLinkAction.class); - } - - @Test public void testSymlinkInsteadOfLipoSingleArch() throws Exception { RULE_TYPE.scratchTarget(scratch); 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 3133cc37d6..663d31a609 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 @@ -25,7 +25,6 @@ import com.google.devtools.build.lib.analysis.util.ScratchAttributeWriter; 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; -import com.google.devtools.build.lib.rules.objc.ObjcCommandLineOptions.ObjcCrosstoolMode; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -34,11 +33,6 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) public class AppleToolchainSelectionTest extends ObjcRuleTestCase { - @Override - protected void useConfiguration(String... args) throws Exception { - useConfiguration(ObjcCrosstoolMode.LIBRARY, args); - } - @Test public void testToolchainSelectionDefault() throws Exception { createLibraryTargetWriter("//a:lib").write(); @@ -79,7 +73,7 @@ public class AppleToolchainSelectionTest extends ObjcRuleTestCase { String x8664Bin = configurationBin("x86_64", ConfigurationDistinguisher.APPLEBIN_IOS, null) + "a/bin_bin"; Artifact binArtifact = getFirstArtifactEndingWith(lipoAction.getInputs(), x8664Bin); - CommandAction linkAction = getGeneratingSpawnAction(binArtifact); + CppLinkAction linkAction = (CppLinkAction) getGeneratingAction(binArtifact); CppLinkAction ccArchiveAction = (CppLinkAction) getGeneratingAction(getFirstArtifactEndingWith(linkAction.getInputs(), "liblib.a")); @@ -102,7 +96,7 @@ public class AppleToolchainSelectionTest extends ObjcRuleTestCase { String armv7Bin = configurationBin("armv7", ConfigurationDistinguisher.APPLEBIN_IOS, null) + "a/bin_bin"; Artifact binArtifact = getFirstArtifactEndingWith(lipoAction.getInputs(), armv7Bin); - CommandAction linkAction = getGeneratingSpawnAction(binArtifact); + CppLinkAction linkAction = (CppLinkAction) getGeneratingAction(binArtifact); CppLinkAction ccArchiveAction = (CppLinkAction) getGeneratingAction(getFirstArtifactEndingWith(linkAction.getInputs(), "liblib.a")); @@ -130,7 +124,7 @@ public class AppleToolchainSelectionTest extends ObjcRuleTestCase { configurationBin("arm64", ConfigurationDistinguisher.APPLEBIN_IOS, null) + "a/bin_bin"; Artifact binArtifact = getFirstArtifactEndingWith(lipoAction.getInputs(), armv64Bin); - CommandAction linkAction = getGeneratingSpawnAction(binArtifact); + CppLinkAction linkAction = (CppLinkAction) getGeneratingAction(binArtifact); CppLinkAction objcLibArchiveAction = (CppLinkAction) getGeneratingAction( getFirstArtifactEndingWith(linkAction.getInputs(), "liblib.a")); assertThat(Joiner.on(" ").join(objcLibArchiveAction.getArguments())).contains("ios_arm64"); diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/BUILD b/src/test/java/com/google/devtools/build/lib/rules/objc/BUILD index 5c8bbec4a1..95299e9bd8 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/BUILD +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/BUILD @@ -22,20 +22,11 @@ java_library( "AppleToolchainSelectionTest.java", "BinaryRuleType.java", "BinaryRuleTypePair.java", - "HeaderDiscoveryTest.java", "HeaderThinningTest.java", "InterspersingTest.java", "IosDeviceTest.java", "J2ObjcLibraryTest.java", "J2ObjcSourceTest.java", - "LegacyAppleBinaryTest.java", - "LegacyAppleDynamicLibraryTest.java", - "LegacyAppleStaticLibraryTest.java", - "LegacyObjcBundleLibraryTest.java", - "LegacyObjcBundleTest.java", - "LegacyObjcFrameworkTest.java", - "LegacyObjcImportTest.java", - "LegacyObjcLibraryTest.java", "LegacyTest.java", "ObjcBuildVariablesTest.java", "ObjcBundleLibraryTest.java", 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 c5755d03b5..978b08f5fe 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 @@ -38,7 +38,6 @@ 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; @@ -379,45 +378,6 @@ public class BazelJ2ObjcLibraryTest extends J2ObjcLibraryTest { } @Test - public void testCrosstoolCompilationSupport() throws Exception { - MockObjcSupport.createCrosstoolPackage(mockToolsConfig); - useConfiguration( - "--crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL, - "--experimental_objc_crosstool=all"); - addSimpleBinaryTarget("//java/com/google/dummy/test:transpile"); - assertThat(getConfiguredTarget("//app:app")).isNotNull(); - } - - @Test - public void testProtoCrosstoolCompilationSupport() throws Exception { - MockObjcSupport.createCrosstoolPackage(mockToolsConfig); - useConfiguration( - "--crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL, - "--experimental_objc_crosstool=all"); - scratch.file("x/test.java"); - scratch.file("x/test.proto"); - scratch.file("x/BUILD", - "package(default_visibility=['//visibility:public'])", - "proto_library(", - " name = 'test_proto',", - " srcs = ['test.proto'],", - " cc_api_version = 2,", - " java_api_version = 2,", - " j2objc_api_version = 1)", - "", - "java_library(", - " name = 'test',", - " srcs = ['test.java'],", - " deps = [':test_proto'])", - "", - "j2objc_library(", - " name = 'transpile',", - " deps = ['test'])"); - addSimpleBinaryTarget("//x:transpile"); - assertThat(getConfiguredTarget("//app:app")).isNotNull(); - } - - @Test public void testJ2ObjcHeaderMappingAction() throws Exception { scratch.file("java/com/google/transpile/BUILD", "java_library(name = 'lib1',", diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/HeaderDiscoveryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/HeaderDiscoveryTest.java deleted file mode 100644 index 7b99bca8aa..0000000000 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/HeaderDiscoveryTest.java +++ /dev/null @@ -1,86 +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.devtools.build.lib.actions.Artifact; -import com.google.devtools.build.lib.actions.CommandAction; -import com.google.devtools.build.lib.actions.util.ActionsTestUtil; -import com.google.devtools.build.lib.collect.nestedset.NestedSet; -import com.google.devtools.build.lib.rules.objc.ObjcCommandLineOptions.ObjcCrosstoolMode; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Test case for discovery of used headers during compilation. */ -@RunWith(JUnit4.class) -public class HeaderDiscoveryTest extends ObjcRuleTestCase { - - @Override - protected void useConfiguration(String... args) throws Exception { - // Don't test crosstool for header discovery - useConfiguration(ObjcCrosstoolMode.OFF, args); - } - - private NestedSet<Artifact> getDiscoveredInputsForDotdFile(String... lines) throws Exception { - createLibraryTargetWriter("//objc:lib") - .setList("srcs", "a.m") - .setList("hdrs", "used.h", "not_used.h") - .write(); - CommandAction commandAction = compileAction("//objc:lib", "a.o"); - assertThat(commandAction).isInstanceOf(ObjcCompileAction.class); - ObjcCompileAction objcCompileAction = (ObjcCompileAction) commandAction; - - Artifact dotdFile = ActionsTestUtil.getOutput(objcCompileAction, "a.d"); - scratch.file(dotdFile.getPath().toString(), lines); - return objcCompileAction.discoverInputsFromDotdFiles( - directories.getExecRoot(), view.getArtifactFactory()); - } - - @Test - public void testObjcHeaderDiscoveryFindsInputs() throws Exception { - NestedSet<Artifact> discoveredInputs = - getDiscoveredInputsForDotdFile("a.o: \\", " objc/a.m \\", " objc/used.h \\"); - assertThat(Artifact.toExecPaths(discoveredInputs)).containsExactly("objc/a.m", "objc/used.h"); - } - - @Test - public void testObjcHeaderDiscoveryIgnoresOutsideExecRoot() throws Exception { - NestedSet<Artifact> discoveredInputs = - getDiscoveredInputsForDotdFile("a.o: \\", " /foo/a.h \\", " /bar/b.h"); - assertThat(Artifact.toExecPaths(discoveredInputs)).isEmpty(); - } - - @Test - public void testInputsArePruned() throws Exception { - NestedSet<Artifact> discoveredInputs = - getDiscoveredInputsForDotdFile("a.o: \\", " objc/a.m \\", " objc/used.h \\"); - ObjcCompileAction compileAction = (ObjcCompileAction) compileAction("//objc:lib", "a.o"); - compileAction.updateActionInputs(discoveredInputs); - - assertThat(Artifact.toExecPaths(compileAction.getInputs())).doesNotContain("objc/not_used.h"); - } - - @Test - public void testSrcsAreMandatoryInputs() throws Exception { - NestedSet<Artifact> discoveredInputs = - getDiscoveredInputsForDotdFile("a.o: \\", " objc/used.h"); - ObjcCompileAction compileAction = (ObjcCompileAction) compileAction("//objc:lib", "a.o"); - compileAction.updateActionInputs(discoveredInputs); - - assertThat(Artifact.toExecPaths(compileAction.getInputs())).contains("objc/a.m"); - } -} 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 075087231d..7db0005a2e 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 @@ -34,7 +34,6 @@ 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.XcodeVersionProperties; -import com.google.devtools.build.lib.rules.objc.ObjcCommandLineOptions.ObjcCrosstoolMode; import com.google.devtools.build.xcode.plmerge.proto.PlMergeProtos; import java.util.List; import java.util.Map; @@ -280,12 +279,6 @@ public class IosTestTest extends ObjcRuleTestCase { } @Test - public void testXcTest_linkAction_Crosstool() throws Exception { - useConfiguration(ObjcCrosstoolMode.ALL); - testXcTest_linkAction(); - } - - @Test public void testVariableSubstitution() throws Exception { createLibraryTargetWriter("//lib1:lib1") .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyAppleBinaryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyAppleBinaryTest.java deleted file mode 100644 index 66b5f9ce91..0000000000 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyAppleBinaryTest.java +++ /dev/null @@ -1,38 +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 LegacyAppleBinaryTest extends AppleBinaryTest { - @Override - protected ObjcCrosstoolMode getObjcCrosstoolMode() { - return ObjcCrosstoolMode.OFF; - } - - @Test - @Override - public void testMacosFrameworkDirectories() throws Exception { - // This AppleBinaryTest fails due to lack of support in legacy mode. - } -} diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyAppleDynamicLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyAppleDynamicLibraryTest.java deleted file mode 100644 index 35ab21979b..0000000000 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyAppleDynamicLibraryTest.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 LegacyAppleDynamicLibraryTest extends AppleDynamicLibraryTest { - @Override - protected ObjcCrosstoolMode getObjcCrosstoolMode() { - return ObjcCrosstoolMode.OFF; - } - -} diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyAppleStaticLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyAppleStaticLibraryTest.java deleted file mode 100644 index 8a3c8ee95f..0000000000 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyAppleStaticLibraryTest.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 LegacyAppleStaticLibraryTest extends AppleStaticLibraryTest { - @Override - protected ObjcCrosstoolMode getObjcCrosstoolMode() { - return ObjcCrosstoolMode.OFF; - } -} diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyBazelJ2ObjcLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyBazelJ2ObjcLibraryTest.java deleted file mode 100644 index 12d7683445..0000000000 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyBazelJ2ObjcLibraryTest.java +++ /dev/null @@ -1,58 +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.common.collect.ImmutableList; -import com.google.devtools.build.lib.actions.Artifact; -import com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact; -import com.google.devtools.build.lib.actions.ArtifactOwner; -import com.google.devtools.build.lib.actions.CommandAction; -import com.google.devtools.build.lib.analysis.actions.ActionTemplate.ActionTemplateExpansionException; -import com.google.devtools.build.lib.analysis.actions.SpawnActionTemplate; -import com.google.devtools.build.lib.analysis.config.BuildConfiguration; -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 in - * devtools.build.lib.rules.objc - */ -@RunWith(JUnit4.class) -@LegacyTest -public class LegacyBazelJ2ObjcLibraryTest extends BazelJ2ObjcLibraryTest { - @Override - protected ObjcCrosstoolMode getObjcCrosstoolMode() { - return ObjcCrosstoolMode.OFF; - } - - @Override - protected BuildConfiguration getGenfilesConfig() { - return targetConfig; - } - - @Override - protected Iterable<CommandAction> getActionsForInputsOfGeneratingActionTemplate( - Artifact artifact, TreeFileArtifact treeFileArtifact) - throws ActionTemplateExpansionException { - SpawnActionTemplate template = - (SpawnActionTemplate) getActionGraph().getGeneratingAction(artifact); - return ImmutableList.<CommandAction>builder() - .addAll( - template.generateActionForInputArtifacts( - ImmutableList.of(treeFileArtifact), ArtifactOwner.NULL_OWNER)) - .build(); - } -} 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 deleted file mode 100644 index f955d3e635..0000000000 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyIosTestTest.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 LegacyIosTestTest extends IosTestTest { - @Override - protected ObjcCrosstoolMode getObjcCrosstoolMode() { - return ObjcCrosstoolMode.OFF; - } -} diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyObjcBundleLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyObjcBundleLibraryTest.java deleted file mode 100644 index 005509c0dd..0000000000 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyObjcBundleLibraryTest.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 LegacyObjcBundleLibraryTest extends ObjcBundleLibraryTest { - @Override - protected ObjcCrosstoolMode getObjcCrosstoolMode() { - return ObjcCrosstoolMode.OFF; - } -} diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyObjcBundleTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyObjcBundleTest.java deleted file mode 100644 index 3c735b95c4..0000000000 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyObjcBundleTest.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. The class is empty - * because each test is also run in the superclass, which tests --experimental_objc_crosstool=all. - */ -@RunWith(JUnit4.class) -@LegacyTest -public class LegacyObjcBundleTest extends ObjcBundleTest { - @Override - protected ObjcCrosstoolMode getObjcCrosstoolMode() { - return ObjcCrosstoolMode.OFF; - } -} diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyObjcFrameworkTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyObjcFrameworkTest.java deleted file mode 100644 index aa84c234bc..0000000000 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyObjcFrameworkTest.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. The class is empty - * because each test is also run in the superclass, which tests --experimental_objc_crosstool=all. - */ -@RunWith(JUnit4.class) -@LegacyTest -public class LegacyObjcFrameworkTest extends ObjcFrameworkTest { - @Override - protected ObjcCrosstoolMode getObjcCrosstoolMode() { - return ObjcCrosstoolMode.OFF; - } -} diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyObjcImportTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyObjcImportTest.java deleted file mode 100644 index 1779fe0fed..0000000000 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyObjcImportTest.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 LegacyObjcImportTest extends ObjcImportTest { - @Override - protected ObjcCrosstoolMode getObjcCrosstoolMode() { - return ObjcCrosstoolMode.OFF; - } - -} diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyObjcLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyObjcLibraryTest.java deleted file mode 100644 index 0df64354b5..0000000000 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/LegacyObjcLibraryTest.java +++ /dev/null @@ -1,533 +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.actions.util.ActionsTestUtil.baseArtifactNames; -import static org.junit.Assert.fail; - -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.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.packages.NoSuchTargetException; -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.HeaderDiscovery; -import com.google.devtools.build.lib.rules.objc.ObjcCommandLineOptions.ObjcCrosstoolMode; -import java.util.List; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Legacy test case (that is, without the OSX crosstool) for objc_library. */ -@RunWith(JUnit4.class) -@LegacyTest -public class LegacyObjcLibraryTest extends ObjcLibraryTest { - private static final RuleType RULE_TYPE = new OnlyNeedsSourcesRuleType("objc_library"); - private static final String XCRUNWRAPPER = "xcrunwrapper"; - private static final String LIBTOOL = "libtool"; - - @Override - protected void useConfiguration(String... args) throws Exception { - // Crosstool case is tested in {@link ObjcLibraryTest} - useConfiguration(ObjcCrosstoolMode.OFF, args); - } - - @Override - @Test - public void testObjcSourcesFeatureCC() throws Exception { - // Features are not exported by legacy actions. - } - - @Override - @Test - public void testObjcSourcesFeatureObjc() throws Exception { - // Features are not exported by legacy actions. - } - - @Override - @Test - public void testObjcSourcesFeatureObjcPlusPlus() throws Exception { - // Features are not exported by legacy actions. - } - - // Crosstool rules do not account for slashes in target names. - @Test - public void testLibFileIsCorrectForSlashInTargetName() throws Exception { - ConfiguredTarget target = - createLibraryTargetWriter("//objc:dir/Target") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .write(); - Iterable<Artifact> outputArtifacts = getFilesToBuild(target); - assertThat(Artifact.toRootRelativePaths(outputArtifacts)).containsExactly("objc/libTarget.a"); - } - - // Override required for distinct compiler path - @Override - @Test - public void testCompilationActions_simulator() throws Exception { - useConfiguration("--cpu=ios_i386", "--ios_minimum_os=1.0"); - ApplePlatform platform = ApplePlatform.IOS_SIMULATOR; - createLibraryTargetWriter("//objc:lib") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "c.h") - .setAndCreateFiles("non_arc_srcs", "not_arc.m") - .write(); - - CommandAction compileActionA = compileAction("//objc:lib", "a.o"); - CommandAction compileActionNotArc = compileAction("//objc:lib", "not_arc.o"); - - List<String> commonCompileFlags = - new ImmutableList.Builder<String>() - .add(MOCK_XCRUNWRAPPER_PATH) - .add(ObjcRuleClasses.CLANG) - .addAll(AppleToolchain.DEFAULT_WARNINGS.values()) - .add("-fexceptions") - .add("-fasm-blocks") - .add("-fobjc-abi-version=2") - .add("-fobjc-legacy-dispatch") - .addAll(CompilationSupport.DEFAULT_COMPILER_FLAGS) - .add("-mios-simulator-version-min=1.0") - .add("-arch", "i386") - .add("-isysroot", AppleToolchain.sdkDir()) - .add("-F", AppleToolchain.sdkDir() + "/Developer/Library/Frameworks") - .add("-F", frameworkDir(platform)) - .addAll(FASTBUILD_COPTS) - .addAll( - iquoteArgs( - getConfiguredTarget("//objc:lib").get(ObjcProvider.SKYLARK_CONSTRUCTOR), - getTargetConfiguration())) - .build(); - - assertThat(compileActionA.getArguments()) - .isEqualTo( - new ImmutableList.Builder<String>() - .addAll(commonCompileFlags) - .add("-fobjc-arc") - .add("-c", "objc/a.m") - .addAll(outputArgs(compileActionA.getOutputs())) - .build()); - assertThat(compileActionNotArc.getArguments()) - .isEqualTo( - new ImmutableList.Builder<String>() - .addAll(commonCompileFlags) - .add("-fno-objc-arc") - .add("-c", "objc/not_arc.m") - .addAll(outputArgs(compileActionNotArc.getOutputs())) - .build()); - - assertRequiresDarwin(compileActionA); - try { - reporter.removeHandler(failFastHandler); - getTarget("//objc:c.o"); - fail("should have thrown"); - } catch (NoSuchTargetException expected) {} - assertThat(baseArtifactNames(compileActionA.getOutputs())).containsExactly("a.o", "a.d"); - assertThat(baseArtifactNames(compileActionA.getInputs())) - .containsExactly("a.m", "c.h", "private.h", XCRUNWRAPPER); - } - - // Override required for distinct compiler path - @Override - @Test - public void testCompilationActions_device() throws Exception { - useConfiguration("--cpu=ios_armv7", "--ios_minimum_os=1.0"); - ApplePlatform platform = ApplePlatform.IOS_DEVICE; - - createLibraryTargetWriter("//objc:lib") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "c.h") - .setAndCreateFiles("non_arc_srcs", "not_arc.m") - .write(); - - CommandAction compileActionA = compileAction("//objc:lib", "a.o"); - CommandAction compileActionNotArc = compileAction("//objc:lib", "not_arc.o"); - - List<String> commonCompileFlags = - new ImmutableList.Builder<String>() - .add(MOCK_XCRUNWRAPPER_PATH) - .add(ObjcRuleClasses.CLANG) - .addAll(AppleToolchain.DEFAULT_WARNINGS.values()) - .addAll(CompilationSupport.DEFAULT_COMPILER_FLAGS) - .add("-miphoneos-version-min=1.0") - .add("-arch", "armv7") - .add("-isysroot", AppleToolchain.sdkDir()) - .add("-F", AppleToolchain.sdkDir() + "/Developer/Library/Frameworks") - .add("-F", frameworkDir(platform)) - .addAll(FASTBUILD_COPTS) - .addAll( - iquoteArgs( - getConfiguredTarget("//objc:lib").get(ObjcProvider.SKYLARK_CONSTRUCTOR), - getTargetConfiguration())) - .build(); - - assertThat(compileActionA.getArguments()) - .isEqualTo( - new ImmutableList.Builder<String>() - .addAll(commonCompileFlags) - .add("-fobjc-arc") - .add("-c", "objc/a.m") - .addAll(outputArgs(compileActionA.getOutputs())) - .build()); - assertThat(compileActionNotArc.getArguments()) - .isEqualTo( - new ImmutableList.Builder<String>() - .addAll(commonCompileFlags) - .add("-fno-objc-arc") - .add("-c", "objc/not_arc.m") - .addAll(outputArgs(compileActionNotArc.getOutputs())) - .build()); - - assertRequiresDarwin(compileActionA); - try { - reporter.removeHandler(failFastHandler); - getTarget("//objc:c.o"); - fail("should have thrown"); - } catch (NoSuchTargetException expected) {} - assertThat(baseArtifactNames(compileActionA.getOutputs())).containsExactly("a.o", "a.d"); - assertThat(baseArtifactNames(compileActionA.getInputs())) - .containsExactly("a.m", "c.h", "private.h", XCRUNWRAPPER); - } - - // Override required for distinct compiler path, command line args. - @Override - @Test - public void testCompilationActionsWithPch() throws Exception { - ApplePlatform platform = ApplePlatform.IOS_SIMULATOR; - scratch.file("objc/foo.pch"); - createLibraryTargetWriter("//objc:lib") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "c.h") - .set("pch", "'some.pch'") - .write(); - - CommandAction compileActionA = compileAction("//objc:lib", "a.o"); - - assertThat(compileActionA.getArguments()) - .containsExactlyElementsIn( - new ImmutableList.Builder<String>() - .add(MOCK_XCRUNWRAPPER_PATH) - .add(ObjcRuleClasses.CLANG) - .addAll(AppleToolchain.DEFAULT_WARNINGS.values()) - .add("-fexceptions") - .add("-fasm-blocks") - .add("-fobjc-abi-version=2") - .add("-fobjc-legacy-dispatch") - .addAll(CompilationSupport.DEFAULT_COMPILER_FLAGS) - .add("-mios-simulator-version-min=" + DEFAULT_IOS_SDK_VERSION) - .add("-arch", "x86_64") - .add("-isysroot", AppleToolchain.sdkDir()) - .add("-F", AppleToolchain.sdkDir() + "/Developer/Library/Frameworks") - .add("-F", frameworkDir(platform)) - .addAll(FASTBUILD_COPTS) - .addAll( - iquoteArgs( - getConfiguredTarget("//objc:lib").get(ObjcProvider.SKYLARK_CONSTRUCTOR), - getAppleCrosstoolConfiguration())) - .add("-include", "objc/some.pch") - .add("-fobjc-arc") - .add("-c", "objc/a.m") - .addAll(outputArgs(compileActionA.getOutputs())) - .build()) - .inOrder(); - - assertThat(compileActionA.getInputs()).contains( - getFileConfiguredTarget("//objc:some.pch").getArtifact()); - } - - // Override required for distinct compiler path - @Override - @Test - public void testCompilationActionsWithCopts() throws Exception { - useConfiguration("--cpu=ios_i386"); - ApplePlatform platform = ApplePlatform.IOS_SIMULATOR; - createLibraryTargetWriter("//objc:lib") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "c.h") - .setList("copts", "-Ifoo", "--monkeys=$(TARGET_CPU)") - .write(); - - CommandAction compileActionA = compileAction("//objc:lib", "a.o"); - - assertThat(compileActionA.getArguments()) - .containsExactlyElementsIn( - new ImmutableList.Builder<String>() - .add(MOCK_XCRUNWRAPPER_PATH) - .add(ObjcRuleClasses.CLANG) - .addAll(AppleToolchain.DEFAULT_WARNINGS.values()) - .add("-fexceptions") - .add("-fasm-blocks") - .add("-fobjc-abi-version=2") - .add("-fobjc-legacy-dispatch") - .addAll(CompilationSupport.DEFAULT_COMPILER_FLAGS) - .add("-mios-simulator-version-min=" + DEFAULT_IOS_SDK_VERSION) - .add("-arch", "i386") - .add("-isysroot", AppleToolchain.sdkDir()) - .add("-F", AppleToolchain.sdkDir() + "/Developer/Library/Frameworks") - .add("-F", frameworkDir(platform)) - .addAll(FASTBUILD_COPTS) - .addAll( - iquoteArgs( - getConfiguredTarget("//objc:lib").get(ObjcProvider.SKYLARK_CONSTRUCTOR), - getTargetConfiguration())) - .add("-fobjc-arc") - .add("-Ifoo") - .add("--monkeys=ios_i386") - .add("-c", "objc/a.m") - .addAll(outputArgs(compileActionA.getOutputs())) - .build()) - .inOrder(); - } - - // Override required since module map is not included in action inputs for the crosstool case - @Override - @Test - public void testCompilationActionsWithModuleMapsEnabled() throws Exception { - useConfiguration( - "--crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL, - "--experimental_objc_enable_module_maps"); - createLibraryTargetWriter("//objc:lib") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "c.h") - .write(); - - CommandAction compileActionA = compileAction("//objc:lib", "a.o"); - assertThat(compileActionA.getArguments()) - .containsAllIn(moduleMapArtifactArguments("//objc", "lib")); - assertThat(compileActionA.getArguments()).contains("-fmodule-maps"); - assertThat(Artifact.toRootRelativePaths(compileActionA.getInputs())) - .contains("objc/lib.modulemaps/module.modulemap"); - } - - // Override required for distinct libtool path - @Override - @Test - public void testArchiveAction_simulator() throws Exception { - useConfiguration("--cpu=ios_i386"); - createLibraryTargetWriter("//objc:lib") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "c.h") - .write(); - CommandAction archiveAction = archiveAction("//objc:lib"); - assertThat(archiveAction.getArguments()) - .isEqualTo( - ImmutableList.of( - MOCK_LIBTOOL_PATH, - "-static", - "-filelist", - getBinArtifact("lib-archive.objlist", "//objc:lib").getExecPathString(), - "-arch_only", - "i386", - "-syslibroot", - AppleToolchain.sdkDir(), - "-o", - Iterables.getOnlyElement(archiveAction.getOutputs()).getExecPathString())); - assertThat(baseArtifactNames(archiveAction.getInputs())) - .containsExactly("a.o", "b.o", "lib-archive.objlist", LIBTOOL); - assertThat(baseArtifactNames(archiveAction.getOutputs())).containsExactly("liblib.a"); - assertRequiresDarwin(archiveAction); - } - - // Override required for distinct libtool path - @Override - @Test - public void testArchiveAction_device() throws Exception { - useConfiguration("--cpu=ios_armv7"); - createLibraryTargetWriter("//objc:lib") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "c.h") - .write(); - CommandAction archiveAction = archiveAction("//objc:lib"); - assertThat(archiveAction.getArguments()) - .isEqualTo( - ImmutableList.of( - MOCK_LIBTOOL_PATH, - "-static", - "-filelist", - getBinArtifact("lib-archive.objlist", "//objc:lib").getExecPathString(), - "-arch_only", - "armv7", - "-syslibroot", - AppleToolchain.sdkDir(), - "-o", - Iterables.getOnlyElement(archiveAction.getOutputs()).getExecPathString())); - assertThat(baseArtifactNames(archiveAction.getInputs())) - .containsExactly("a.o", "b.o", "lib-archive.objlist", LIBTOOL); - assertThat(baseArtifactNames(archiveAction.getOutputs())).containsExactly("liblib.a"); - assertRequiresDarwin(archiveAction); - } - - // Override required for distinct libtool path - @Override - @Test - public void testFullyLinkArchiveAction_simulator() throws Exception { - useConfiguration("--cpu=ios_i386"); - createLibraryTargetWriter("//objc:lib_dep") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "a.h", "b.h") - .write(); - createLibraryTargetWriter("//objc2:lib") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "c.h", "d.h") - .setList("deps", "//objc:lib_dep") - .write(); - SpawnAction archiveAction = (SpawnAction) getGeneratingActionForLabel( - "//objc2:lib_fully_linked.a"); - assertRequiresDarwin(archiveAction); - assertThat(archiveAction.getArguments()) - .isEqualTo( - ImmutableList.of( - MOCK_LIBTOOL_PATH, - "-static", - "-arch_only", - "i386", - "-syslibroot", - AppleToolchain.sdkDir(), - "-o", - Iterables.getOnlyElement(archiveAction.getOutputs()).getExecPathString(), - getBinArtifact("liblib.a", "//objc2:lib").getExecPathString(), - getBinArtifact("liblib_dep.a", "//objc:lib_dep").getExecPathString())); - assertThat(baseArtifactNames(archiveAction.getInputs())) - .containsExactly("liblib_dep.a", "liblib.a", LIBTOOL); - } - - // Override required for distinct libtool path - @Override - @Test - public void testFullyLinkArchiveAction_device() throws Exception { - useConfiguration("--cpu=ios_armv7"); - createLibraryTargetWriter("//objc:lib_dep") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "a.h", "b.h") - .write(); - createLibraryTargetWriter("//objc2:lib") - .setAndCreateFiles("srcs", "a.m", "b.m", "private.h") - .setAndCreateFiles("hdrs", "c.h", "d.h") - .setList("deps", "//objc:lib_dep") - .write(); - SpawnAction archiveAction = (SpawnAction) getGeneratingActionForLabel( - "//objc2:lib_fully_linked.a"); - assertRequiresDarwin(archiveAction); - assertThat(archiveAction.getArguments()) - .isEqualTo( - ImmutableList.of( - MOCK_LIBTOOL_PATH, - "-static", - "-arch_only", - "armv7", - "-syslibroot", - AppleToolchain.sdkDir(), - "-o", - Iterables.getOnlyElement(archiveAction.getOutputs()).getExecPathString(), - getBinArtifact("liblib.a", "//objc2:lib").getExecPathString(), - getBinArtifact("liblib_dep.a", "//objc:lib_dep").getExecPathString())); - assertThat(baseArtifactNames(archiveAction.getInputs())) - .containsExactly("liblib_dep.a", "liblib.a", LIBTOOL); - } - - // Dotd pruning must be tested seperately for the legacy case, since it involves the - // ObjcCompileAction. - @Override - @Test - public void testUsesDotdPruning() throws Exception { - createLibraryTargetWriter("//lib:lib").setList("srcs", "a.m").write(); - CommandAction compileAction = compileAction("//lib:lib", "a.o"); - assertThat(compileAction).isInstanceOf(ObjcCompileAction.class); - assertThat(((ObjcCompileAction) compileAction).getDotdPruningPlan()) - .isEqualTo(HeaderDiscovery.DotdPruningMode.USE); - } - - @Override - @Test - public void testDoesNotUseDotdPruning() throws Exception { - useConfiguration("--objc_use_dotd_pruning=false"); - createLibraryTargetWriter("//lib:lib").setList("srcs", "a.m").write(); - CommandAction compileAction = compileAction("//lib:lib", "a.o"); - assertThat(compileAction).isInstanceOf(ObjcCompileAction.class); - assertThat(((ObjcCompileAction) compileAction).getDotdPruningPlan()) - .isEqualTo(HeaderDiscovery.DotdPruningMode.DO_NOT_USE); - } - - // Override required because CppCompileAction#getPossibleInputsForTesting is not available to - // test for the presence of inputs that will be pruned. - @Override - @Test - public void testPrecompiledHeaders() throws Exception { - useConfiguration("--crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL); - scratch.file("objc/a.m"); - scratch.file("objc/c.pch"); - scratch.file( - "objc/BUILD", - RULE_TYPE.target( - scratch, "objc", "x", "srcs", "['a.m']", "non_arc_srcs", "['b.m']", "pch", "'c.pch'")); - CommandAction compileAction = compileAction("//objc:x", "a.o"); - assertThat(Joiner.on(" ").join(compileAction.getArguments())).contains("-include objc/c.pch"); - } - - // Override required because CppCompileAction#getPossibleInputsForTesting is not available to - // test for the presence of inputs that will be pruned. - @Override - @Test - public void testCompilesSources() throws Exception { - useConfiguration("--crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL); - createLibraryTargetWriter("//objc/lib1") - .setAndCreateFiles("srcs", "a.m") - .setAndCreateFiles("hdrs", "hdr.h") - .write(); - - createLibraryTargetWriter("//objc/lib2") - .setAndCreateFiles("srcs", "a.m") - .setAndCreateFiles("hdrs", "hdr.h") - .setList("deps", "//objc/lib1") - .write(); - - createLibraryTargetWriter("//objc:x") - .setAndCreateFiles("srcs", "a.m", "private.h") - .setAndCreateFiles("hdrs", "hdr.h") - .setList("deps", "//objc/lib2:lib2") - .write(); - - CommandAction compileA = compileAction("//objc:x", "a.o"); - - assertThat(Artifact.toRootRelativePaths(compileA.getInputs())) - .contains("objc/a.m"); - assertThat(Artifact.toRootRelativePaths(compileA.getOutputs())) - .containsExactly("objc/_objs/x/objc/a.o", "objc/_objs/x/objc/a.d"); - } - - - @Override - @Test - public void testCompilationModeDbg() throws Exception { - // Feature requires crosstool - } - - @Override - @Test - public void testCompilationModeFastbuild() throws Exception { - // Feature requires crosstool - } - - @Override - @Test - public void testCompilationModeOpt() throws Exception { - // Feature requires crosstool - } -} diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcBuildVariablesTest.java b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcBuildVariablesTest.java index 58dc0e7e85..a7ca2273c2 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcBuildVariablesTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcBuildVariablesTest.java @@ -145,7 +145,6 @@ public class ObjcBuildVariablesTest extends LinkBuildVariablesTestCase { String dummyMinimumOsValue = "13.579"; useConfiguration( "--crosstool_top=//tools/osx/crosstool", - "--experimental_objc_crosstool=all", "--apple_crosstool_transition", "--cpu=darwin_x86_64", "--macos_minimum_os=" + dummyMinimumOsValue); @@ -211,7 +210,6 @@ public class ObjcBuildVariablesTest extends LinkBuildVariablesTestCase { String dummyMinimumOsValue = "13.579"; useConfiguration( "--crosstool_top=//tools/osx/crosstool", - "--experimental_objc_crosstool=all", "--apple_crosstool_transition", "--cpu=darwin_x86_64"); scratch.file( 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 043b791cd2..67862bdf3c 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 @@ -56,7 +56,6 @@ 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.CppModuleMapAction; import com.google.devtools.build.lib.rules.cpp.LinkerInput; -import com.google.devtools.build.lib.rules.objc.ObjcCommandLineOptions.ObjcCrosstoolMode; import com.google.devtools.build.lib.rules.objc.ObjcProvider.Key; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.common.options.OptionsParsingException; @@ -140,7 +139,7 @@ public class ObjcLibraryTest extends ObjcRuleTestCase { @Test public void testObjcPlusPlusCompileDarwin() throws Exception { - useConfiguration(ObjcCrosstoolMode.ALL, + useConfiguration( "--cpu=darwin_x86_64", "--macos_minimum_os=9.10.11", // TODO(b/36126423): Darwin should imply macos, so the @@ -1755,9 +1754,7 @@ public class ObjcLibraryTest extends ObjcRuleTestCase { @Test public void testObjcProtoLibraryDoesNotCrash() throws Exception { - useConfiguration( - "--crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL, - "--experimental_objc_crosstool=all"); + useConfiguration("--crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL); scratch.file( "x/BUILD", "objc_library(", @@ -1779,9 +1776,7 @@ public class ObjcLibraryTest extends ObjcRuleTestCase { @Test public void testLegacyObjcProtoLibraryDoesNotCrash() throws Exception { - useConfiguration( - "--crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL, - "--experimental_objc_crosstool=all"); + useConfiguration("--crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL); scratch.file( "x/BUILD", "objc_library(", @@ -1802,9 +1797,7 @@ public class ObjcLibraryTest extends ObjcRuleTestCase { @Test public void testObjcImportDoesNotCrash() throws Exception { - useConfiguration( - "--crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL, - "--experimental_objc_crosstool=all"); + useConfiguration("--crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL); scratch.file( "x/BUILD", "objc_library(", @@ -1888,7 +1881,6 @@ public class ObjcLibraryTest extends ObjcRuleTestCase { public void testSysrootArgSpecifiedWithGrteTopFlag() throws Exception { MockObjcSupport.setup(mockToolsConfig, "default_grte_top : '//x'"); useConfiguration( - ObjcCrosstoolMode.ALL, "--cpu=ios_x86_64", "--ios_cpu=x86_64"); scratch.file( @@ -1919,7 +1911,6 @@ public class ObjcLibraryTest extends ObjcRuleTestCase { " }", "}"); useConfiguration( - ObjcCrosstoolMode.ALL, "--cpu=ios_x86_64", "--ios_cpu=x86_64"); scratch.file( 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 cdbc8833b7..1a137a4f70 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 @@ -18,7 +18,7 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.baseArtifactNames; import static com.google.devtools.build.lib.actions.util.ActionsTestUtil.getFirstArtifactEndingWith; -import static com.google.devtools.build.lib.rules.objc.LegacyCompilationSupport.AUTOMATIC_SDK_FRAMEWORKS; +import static com.google.devtools.build.lib.rules.objc.CompilationSupport.AUTOMATIC_SDK_FRAMEWORKS; import static com.google.devtools.build.lib.rules.objc.ObjcProvider.HEADER; import static com.google.devtools.build.lib.rules.objc.ObjcProvider.INCLUDE; import static com.google.devtools.build.lib.rules.objc.ObjcProvider.MODULE_MAP; @@ -89,10 +89,8 @@ import com.google.devtools.build.lib.rules.apple.ApplePlatform; 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.CppCompileAction; import com.google.devtools.build.lib.rules.cpp.CppLinkAction; import com.google.devtools.build.lib.rules.objc.CompilationSupport.ExtraLinkArgs; -import com.google.devtools.build.lib.rules.objc.ObjcCommandLineOptions.ObjcCrosstoolMode; import com.google.devtools.build.lib.testutil.TestConstants; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.build.xcode.bundlemerge.proto.BundleMergeProtos; @@ -133,8 +131,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase { protected static final String MOCK_LIBTOOL_PATH = toolsRepoExecPath("tools/objc/libtool"); protected static final String MOCK_XCRUNWRAPPER_PATH = toolsRepoExecPath("tools/objc/xcrunwrapper"); - protected static final ImmutableList<String> FASTBUILD_COPTS = - ImmutableList.of("-O0", "-DDEBUG=1"); + protected static final ImmutableList<String> FASTBUILD_COPTS = ImmutableList.of("-O0", "-DDEBUG"); protected static final DottedVersion DEFAULT_IOS_SDK_VERSION = DottedVersion.fromString(AppleCommandLineOptions.DEFAULT_IOS_SDK_VERSION); @@ -344,35 +341,13 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase { return result.toString(); } - /** Returns the treatment of the crosstool for this test case. */ - protected ObjcCrosstoolMode getObjcCrosstoolMode() { - return ObjcCrosstoolMode.ALL; - } - @Override protected void useConfiguration(String... args) throws Exception { - // By default, objc tests assume the case of --experimental_objc_crosstool=all. The "Legacy" - // subclasses explicitly override to test --experimental_objc_crosstool=off. - useConfiguration(getObjcCrosstoolMode(), args); - } - - protected void useConfiguration(ObjcCrosstoolMode objcCrosstoolMode, String... args) - throws Exception { ImmutableList.Builder<String> extraArgsBuilder = ImmutableList.builder(); extraArgsBuilder.addAll(TestConstants.OSX_CROSSTOOL_FLAGS); - switch(objcCrosstoolMode) { - case ALL: - extraArgsBuilder.add("--experimental_objc_crosstool=all"); - break; - case LIBRARY: - extraArgsBuilder.add("--experimental_objc_crosstool=library"); - break; - case OFF: - extraArgsBuilder.add("--experimental_objc_crosstool=off"); - break; - } - + // TODO(b/68751876): Set --apple_crosstool_top and --crosstool_top using the + // AppleCrosstoolTransition extraArgsBuilder .add("--xcode_version_config=" + MockObjcSupport.XCODE_VERSION_CONFIG) .add("--apple_crosstool_top=" + MockObjcSupport.DEFAULT_OSX_CROSSTOOL) @@ -1352,9 +1327,6 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase { assertOnlyRequiredInputsArePresentForBundledCompilation(topTarget); assertCoptsAndDefinesNotPropagatedToProtos(topTarget); assertBundledGroupsGetCreatedAndLinked(topTarget); - if (getObjcCrosstoolMode() == ObjcCrosstoolMode.ALL) { - assertBundledCompilationUsesCrosstool(topTarget); - } } protected ImmutableList<Artifact> getAllObjectFilesLinkedInBin(Artifact bin) { @@ -1537,22 +1509,6 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase { .containsAllOf(protosGroup0Lib, protosGroup1Lib, protosGroup2Lib, protosGroup3Lib); } - private void assertBundledCompilationUsesCrosstool(ConfiguredTarget topTarget) { - Artifact protoObjectA = - getBinArtifact("_objs/x/x/_generated_protos/x/protos/DataA.pbobjc.o", topTarget); - Artifact protoObjectB = - getBinArtifact("_objs/x/x/_generated_protos/x/protos/DataB.pbobjc.o", topTarget); - Artifact protoObjectC = - getBinArtifact("_objs/x/x/_generated_protos/x/protos/DataC.pbobjc.o", topTarget); - Artifact protoObjectD = - getBinArtifact("_objs/x/x/_generated_protos/x/protos/DataD.pbobjc.o", topTarget); - - assertThat(getGeneratingAction(protoObjectA)).isInstanceOf(CppCompileAction.class); - assertThat(getGeneratingAction(protoObjectB)).isInstanceOf(CppCompileAction.class); - assertThat(getGeneratingAction(protoObjectC)).isInstanceOf(CppCompileAction.class); - assertThat(getGeneratingAction(protoObjectD)).isInstanceOf(CppCompileAction.class); - } - protected void checkProtoBundlingDoesNotHappen(RuleType ruleType) throws Exception { scratch.file( "protos/BUILD", @@ -4540,7 +4496,6 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase { } public void checkLinkingRuleCanUseCrosstool(RuleType ruleType) throws Exception { - useConfiguration(ObjcCrosstoolMode.ALL); ruleType.scratchTarget(scratch, "srcs", "['a.m']"); ConfiguredTarget target = getConfiguredTarget("//x:x"); @@ -4551,7 +4506,6 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase { } public void checkLinkingRuleCanUseCrosstool_singleArch(RuleType ruleType) throws Exception { - useConfiguration(ObjcCrosstoolMode.ALL); ruleType.scratchTarget(scratch); // If bin is indeed using the c++ backend, then its archive action should be a CppLinkAction. @@ -4564,7 +4518,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase { } public void checkLinkingRuleCanUseCrosstool_multiArch(RuleType ruleType) throws Exception { - useConfiguration(ObjcCrosstoolMode.ALL, "--ios_multi_cpus=i386,x86_64"); + useConfiguration("--ios_multi_cpus=i386,x86_64"); ruleType.scratchTarget(scratch); // If bin is indeed using the c++ backend, then its archive action should be a CppLinkAction. @@ -4651,7 +4605,7 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase { } public void checkAvoidDepsObjectsWithCrosstool(RuleType ruleType) throws Exception { - useConfiguration(ObjcCrosstoolMode.ALL, "--ios_multi_cpus=i386,x86_64"); + useConfiguration("--ios_multi_cpus=i386,x86_64"); assertAvoidDepsObjects(ruleType); } 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 2859878b69..c4b126de59 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 @@ -28,7 +28,6 @@ import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.packages.SkylarkInfo; 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.objc.ObjcCommandLineOptions.ObjcCrosstoolMode; import com.google.devtools.build.lib.syntax.SkylarkDict; import com.google.devtools.build.lib.syntax.SkylarkNestedSet; import com.google.devtools.build.lib.vfs.PathFragment; @@ -42,13 +41,6 @@ import org.junit.runners.JUnit4; */ @RunWith(JUnit4.class) public class ObjcSkylarkTest extends ObjcRuleTestCase { - - @Override - protected void useConfiguration(String... args) throws Exception { - // Do not test crosstool for skylark tests. - useConfiguration(ObjcCrosstoolMode.OFF, args); - } - @Test public void testSkylarkRuleCanDependOnNativeAppleRule() throws Exception { scratch.file("examples/rule/BUILD"); diff --git a/src/test/java/com/google/devtools/build/lib/rules/objc/README.md b/src/test/java/com/google/devtools/build/lib/rules/objc/README.md deleted file mode 100644 index 388dbc6e2b..0000000000 --- a/src/test/java/com/google/devtools/build/lib/rules/objc/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# Objc rule tests -This package contains subclasses of ObjcRuleTestCase. These test cases use ---experimental_objc_crosstool=all by default, as per -ObjcRuleTestCase#useConfiguration. This is meant to test the "crosstool" -case. - -The "legacy" case (that is, --experimental_objc_crosstool=off) is also tested -in subclasses prefixed with the word "Legacy". Tests in the superclass, then, -are tested for both crosstool configurations, while tests in the subclass are -only tested for --experimental_objc_crosstool=off. - -As the crosstool case is developed, tests will moved up to superclasses. -Eventually, the legacy subclasses will be removed. |