diff options
Diffstat (limited to 'src/test/java/com')
-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", |