@@ -67,13 +67,14 @@ private void validateStarlarkProtoLangToolchain(StarlarkInfo toolchain) throws E
67
67
TransitiveInfoCollection runtimes = (TransitiveInfoCollection ) toolchain .getValue ("runtime" );
68
68
assertThat (runtimes .getLabel ())
69
69
.isEqualTo (Label .parseAbsolute ("//third_party/x:runtime" , ImmutableMap .of ()));
70
+ }
70
71
71
- Label protoc = Label . parseAbsoluteUnchecked ( ProtoConstants . DEFAULT_PROTOC_LABEL );
72
+ private void validateProtoCompiler ( StarlarkInfo toolchain , Label protoCompiler ) {
72
73
assertThat (
73
74
((FilesToRunProvider ) toolchain .getValue ("proto_compiler" ))
74
75
.getExecutable ()
75
76
.prettyPrint ())
76
- .isEqualTo (protoc .toPathFragment ().getPathString ());
77
+ .isEqualTo (protoCompiler .toPathFragment ().getPathString ());
77
78
}
78
79
79
80
@ Override
@@ -103,10 +104,49 @@ public void protoToolchain() throws Exception {
103
104
")" );
104
105
105
106
update (ImmutableList .of ("//foo:toolchain" ), false , 1 , true , new EventBus ());
107
+ StarlarkInfo toolchain =
108
+ (StarlarkInfo )
109
+ getConfiguredTarget ("//foo:toolchain" ).get (getStarlarkProtoLangToolchainInfoKey ());
110
+ Label protoc = Label .parseAbsoluteUnchecked (ProtoConstants .DEFAULT_PROTOC_LABEL );
111
+
112
+ validateStarlarkProtoLangToolchain (toolchain );
113
+ validateProtoCompiler (toolchain , protoc );
114
+ }
115
+
116
+ @ Test
117
+ public void protoToolchain_setProtoCompiler () throws Exception {
118
+ scratch .file (
119
+ "third_party/x/BUILD" ,
120
+ "licenses(['unencumbered'])" ,
121
+ "cc_binary(name = 'plugin', srcs = ['plugin.cc'])" ,
122
+ "cc_library(name = 'runtime', srcs = ['runtime.cc'])" ,
123
+ "filegroup(name = 'descriptors', srcs = ['metadata.proto', 'descriptor.proto'])" ,
124
+ "filegroup(name = 'any', srcs = ['any.proto'])" ,
125
+ "proto_library(name = 'denied', srcs = [':descriptors', ':any'])" ,
126
+ "cc_binary(name = 'compiler')" );
127
+
128
+ scratch .file (
129
+ "foo/BUILD" ,
130
+ TestConstants .LOAD_PROTO_LANG_TOOLCHAIN ,
131
+ "licenses(['unencumbered'])" ,
132
+ "proto_lang_toolchain(" ,
133
+ " name = 'toolchain'," ,
134
+ " command_line = 'cmd-line:$(OUT)'," ,
135
+ " plugin_format_flag = '--plugin=%s'," ,
136
+ " plugin = '//third_party/x:plugin'," ,
137
+ " runtime = '//third_party/x:runtime'," ,
138
+ " progress_message = 'Progress Message %{label}'," ,
139
+ " mnemonic = 'MyMnemonic'," ,
140
+ " proto_compiler = '//third_party/x:compiler'," ,
141
+ ")" );
106
142
107
- validateStarlarkProtoLangToolchain (
143
+ StarlarkInfo toolchain =
108
144
(StarlarkInfo )
109
- getConfiguredTarget ("//foo:toolchain" ).get (getStarlarkProtoLangToolchainInfoKey ()));
145
+ getConfiguredTarget ("//foo:toolchain" ).get (getStarlarkProtoLangToolchainInfoKey ());
146
+ Label protoc = Label .parseAbsoluteUnchecked ("//third_party/x:compiler" );
147
+
148
+ validateStarlarkProtoLangToolchain (toolchain );
149
+ validateProtoCompiler (toolchain , protoc );
110
150
}
111
151
112
152
@ Override
@@ -135,10 +175,13 @@ public void protoToolchainBlacklistProtoLibraries() throws Exception {
135
175
")" );
136
176
137
177
update (ImmutableList .of ("//foo:toolchain" ), false , 1 , true , new EventBus ());
138
-
139
- validateStarlarkProtoLangToolchain (
178
+ StarlarkInfo toolchain =
140
179
(StarlarkInfo )
141
- getConfiguredTarget ("//foo:toolchain" ).get (getStarlarkProtoLangToolchainInfoKey ()));
180
+ getConfiguredTarget ("//foo:toolchain" ).get (getStarlarkProtoLangToolchainInfoKey ());
181
+ Label protoc = Label .parseAbsoluteUnchecked (ProtoConstants .DEFAULT_PROTOC_LABEL );
182
+
183
+ validateStarlarkProtoLangToolchain (toolchain );
184
+ validateProtoCompiler (toolchain , protoc );
142
185
}
143
186
144
187
@ Override
@@ -167,10 +210,13 @@ public void protoToolchainBlacklistTransitiveProtos() throws Exception {
167
210
")" );
168
211
169
212
update (ImmutableList .of ("//foo:toolchain" ), false , 1 , true , new EventBus ());
170
-
171
- validateStarlarkProtoLangToolchain (
213
+ StarlarkInfo toolchain =
172
214
(StarlarkInfo )
173
- getConfiguredTarget ("//foo:toolchain" ).get (getStarlarkProtoLangToolchainInfoKey ()));
215
+ getConfiguredTarget ("//foo:toolchain" ).get (getStarlarkProtoLangToolchainInfoKey ());
216
+ Label protoc = Label .parseAbsoluteUnchecked (ProtoConstants .DEFAULT_PROTOC_LABEL );
217
+
218
+ validateStarlarkProtoLangToolchain (toolchain );
219
+ validateProtoCompiler (toolchain , protoc );
174
220
}
175
221
176
222
@ Override
0 commit comments