aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/rules/proto
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-12-21 19:04:39 +0000
committerGravatar Klaus Aehlig <aehlig@google.com>2016-12-22 09:55:42 +0000
commitafa8d0b4076bb42dbac9f4e2459a7cef7442a6d8 (patch)
tree81d93717966ac47c92743469eaf64cf779d896e5 /src/test/java/com/google/devtools/build/lib/rules/proto
parentcf582615487a3dd541f073479f2a26a9376887b2 (diff)
Move the descriptorset output to the ProtoSourcesProvider and expose it to skylark.
This does mean that the type name 'ProtoSourcesProvider' is a little inaccurate, since descriptorSet() is an output. Alternatively we could expose the DescriptorSetProvider to skylark. RELNOTES: expose proto_library descriptor set to skylark via <dep>.proto.descriptor_set -- PiperOrigin-RevId: 142680666 MOS_MIGRATED_REVID=142680666
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/rules/proto')
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/proto/BazelProtoLibraryTest.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/proto/BazelProtoLibraryTest.java b/src/test/java/com/google/devtools/build/lib/rules/proto/BazelProtoLibraryTest.java
index d0a1211975..504e07c99b 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/proto/BazelProtoLibraryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/proto/BazelProtoLibraryTest.java
@@ -40,6 +40,7 @@ public class BazelProtoLibraryTest extends BuildViewTestCase {
Artifact file =
ActionsTestUtil.getFirstArtifactEndingWith(getFilesToBuild(target), ".proto.bin");
assertThat(file.getRootRelativePathString()).isEqualTo("x/foo-descriptor-set.proto.bin");
+ assertThat(target.getProvider(ProtoSourcesProvider.class).descriptorSet()).isEqualTo(file);
assertThat(getGeneratingSpawnAction(file).getRemainingArguments())
.containsAllOf(
@@ -73,6 +74,38 @@ public class BazelProtoLibraryTest extends BuildViewTestCase {
ConfiguredTarget target = scratchConfiguredTarget("x", "foo", "proto_library(name='foo')");
assertThat(ActionsTestUtil.getFirstArtifactEndingWith(getFilesToBuild(target), ".proto.bin"))
.isNull();
+
+ assertThat(target.getProvider(ProtoSourcesProvider.class).descriptorSet()).isNull();
+ }
+
+ @Test
+ public void testDescriptorSetOutput_noSrcs_transitive() throws Exception {
+ ConfiguredTarget target =
+ scratchConfiguredTarget(
+ "x",
+ "foo",
+ "proto_library(name='foo', deps = [':dep1'])",
+ "proto_library(name='dep1', deps = [':dep2'])",
+ "proto_library(name='dep2')");
+ assertThat(ActionsTestUtil.getFirstArtifactEndingWith(getFilesToBuild(target), ".proto.bin"))
+ .isNull();
+
+ assertThat(target.getProvider(ProtoSourcesProvider.class).descriptorSet()).isNull();
+ }
+
+ @Test
+ public void testDescriptorSetOutput_srcs_transitive() throws Exception {
+ ConfiguredTarget target =
+ scratchConfiguredTarget(
+ "x",
+ "foo",
+ "proto_library(name='foo', deps = [':dep1'])",
+ "proto_library(name='dep1', deps = [':dep2'])",
+ "proto_library(name='dep2', srcs=['foo.proto'])");
+ Artifact file =
+ ActionsTestUtil.getFirstArtifactEndingWith(getFilesToBuild(target), ".proto.bin");
+ assertThat(file.getRootRelativePathString()).isEqualTo("x/foo-descriptor-set.proto.bin");
+ assertThat(target.getProvider(ProtoSourcesProvider.class).descriptorSet()).isEqualTo(file);
}
@Test