diff options
author | 2017-07-06 22:00:21 -0400 | |
---|---|---|
committer | 2017-07-07 07:08:36 -0400 | |
commit | 6cfffdf37e11018c7e6e2cabc90440d6d29c819b (patch) | |
tree | 79620427c42b614fa4094876533d98b7f8fea1d8 /src/test | |
parent | cf483e472790fad1503c5728f7c91dd84f7d9348 (diff) |
Automated rollback of commit 9000e61fc1737444392ffe251727e8331fab3cf2.
*** Reason for rollback ***
Fixed handling of pch, so this should work again
*** Original change description ***
Automated rollback of commit 29ec1b89989db411d2038e2df8657b6435f80403.
*** Reason for rollback ***
Breaks the classroom_ios TAP project [1] in the presence of --experimental_objc_crosstool=all, which was added to the global .blazerc last week.
[1] []
*** Original change description ***
Change ProtobufSupport to use CrosstoolCompilationSupport if experimental_objc_crosstool=all
PiperOrigin-RevId: 161159846
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/rules/objc/AppleBinaryTest.java | 4 | ||||
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/rules/objc/ObjcRuleTestCase.java | 46 |
2 files changed, 44 insertions, 6 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 37a12f9626..db30b9a0ac 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 @@ -544,7 +544,9 @@ public class AppleBinaryTest extends ObjcRuleTestCase { assertThat(getFirstArtifactEndingWith(binObjectFiles, "DataB.pbobjc.o")).isNull(); Action dataAObjectAction = getGeneratingAction(getFirstArtifactEndingWith(binObjectFiles, "DataA.pbobjc.o")); - assertThat(getFirstArtifactEndingWith(dataAObjectAction.getInputs(), "DataB.pbobjc.h")) + assertThat( + getFirstArtifactEndingWith( + getExpandedActionInputs(dataAObjectAction), "DataB.pbobjc.h")) .isNotNull(); } 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 2fb8a81a48..1224433700 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 @@ -89,6 +89,7 @@ import com.google.devtools.build.lib.rules.apple.DottedVersion; import com.google.devtools.build.lib.rules.apple.Platform; import com.google.devtools.build.lib.rules.apple.Platform.PlatformType; import com.google.devtools.build.lib.rules.apple.XcodeVersionProperties; +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; @@ -1365,6 +1366,9 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase { assertOnlyRequiredInputsArePresentForBundledCompilation(topTarget); assertCoptsAndDefinesForBundlingTarget(topTarget); assertBundledGroupsGetCreatedAndLinked(topTarget); + if (getObjcCrosstoolMode() == ObjcCrosstoolMode.ALL) { + assertBundledCompilationUsesCrosstool(topTarget); + } } protected ImmutableList<Artifact> getAllObjectFilesLinkedInBin(Artifact bin) { @@ -1463,6 +1467,22 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase { .doesNotContain("protos/data_b.proto"); } + /** + * Ensures that all middleman artifacts in the action input are expanded so that the real inputs + * are also included. + */ + protected Iterable<Artifact> getExpandedActionInputs(Action action) { + List<Artifact> containedArtifacts = new ArrayList<>(); + for (Artifact input : action.getInputs()) { + if (input.isMiddlemanArtifact()) { + Action middlemanAction = getGeneratingAction(input); + Iterables.addAll(containedArtifacts, getExpandedActionInputs(middlemanAction)); + } + containedArtifacts.add(input); + } + return containedArtifacts; + } + private void assertOnlyRequiredInputsArePresentForBundledCompilation(ConfiguredTarget topTarget) { Artifact protoHeaderA = getBinArtifact("_generated_protos/x/protos/DataA.pbobjc.h", topTarget); Artifact protoHeaderB = getBinArtifact("_generated_protos/x/protos/DataB.pbobjc.h", topTarget); @@ -1488,15 +1508,15 @@ public abstract class ObjcRuleTestCase extends BuildViewTestCase { assertThat(protoObjectActionC).isNotNull(); assertThat(protoObjectActionD).isNotNull(); - assertThat(protoObjectActionA.getInputs()) + assertThat(getExpandedActionInputs(protoObjectActionA)) .containsNoneOf(protoHeaderB, protoHeaderC, protoHeaderD); - assertThat(protoObjectActionB.getInputs()) + assertThat(getExpandedActionInputs(protoObjectActionB)) .containsNoneOf(protoHeaderA, protoHeaderC, protoHeaderD); - assertThat(protoObjectActionC.getInputs()) + assertThat(getExpandedActionInputs(protoObjectActionC)) .containsNoneOf(protoHeaderA, protoHeaderB, protoHeaderD); - assertThat(protoObjectActionD.getInputs()) + assertThat(getExpandedActionInputs(protoObjectActionD)) .containsAllOf(protoHeaderA, protoHeaderC, protoHeaderD); - assertThat(protoObjectActionD.getInputs()) + assertThat(getExpandedActionInputs(protoObjectActionD)) .doesNotContain(protoHeaderB); } @@ -1540,6 +1560,22 @@ 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", |