@@ -39,10 +39,27 @@ public void setUp() throws Exception {
3939 invalidatePackages ();
4040 }
4141
42+ private void validateProtoLangToolchain (ProtoLangToolchainProvider toolchain ) throws Exception {
43+ assertThat (toolchain .commandLine ()).isEqualTo ("cmd-line" );
44+ assertThat (toolchain .pluginExecutable ().getExecutable ().getRootRelativePathString ())
45+ .isEqualTo ("third_party/x/plugin" );
46+
47+ TransitiveInfoCollection runtimes = toolchain .runtime ();
48+ assertThat (runtimes .getLabel ())
49+ .isEqualTo (Label .parseAbsolute ("//third_party/x:runtime" , ImmutableMap .of ()));
50+
51+ assertThat (prettyArtifactNames (toolchain .blacklistedProtos ()))
52+ .containsExactly (
53+ "third_party/x/metadata.proto" ,
54+ "third_party/x/descriptor.proto" ,
55+ "third_party/x/any.proto" );
56+ }
57+
4258 @ Test
4359 public void protoToolchain () throws Exception {
4460 scratch .file (
45- "x/BUILD" ,
61+ "third_party/x/BUILD" ,
62+ "licenses(['unencumbered'])" ,
4663 "cc_binary(name = 'plugin', srcs = ['plugin.cc'])" ,
4764 "cc_library(name = 'runtime', srcs = ['runtime.cc'])" ,
4865 "filegroup(name = 'descriptors', srcs = ['metadata.proto', 'descriptor.proto'])" ,
@@ -52,29 +69,82 @@ public void protoToolchain() throws Exception {
5269 scratch .file (
5370 "foo/BUILD" ,
5471 TestConstants .LOAD_PROTO_LANG_TOOLCHAIN ,
72+ "licenses(['unencumbered'])" ,
5573 "proto_lang_toolchain(" ,
5674 " name = 'toolchain'," ,
5775 " command_line = 'cmd-line'," ,
58- " plugin = '//x:plugin'," ,
59- " runtime = '//x:runtime'," ,
60- " blacklisted_protos = ['//x:blacklist']" ,
76+ " plugin = '//third_party/ x:plugin'," ,
77+ " runtime = '//third_party/ x:runtime'," ,
78+ " blacklisted_protos = ['//third_party/ x:blacklist']" ,
6179 ")" );
6280
6381 update (ImmutableList .of ("//foo:toolchain" ), false , 1 , true , new EventBus ());
6482
65- ProtoLangToolchainProvider toolchain =
66- getConfiguredTarget ("//foo:toolchain" ).getProvider (ProtoLangToolchainProvider .class );
83+ validateProtoLangToolchain (
84+ getConfiguredTarget ("//foo:toolchain" ).getProvider (ProtoLangToolchainProvider .class ));
85+ }
6786
68- assertThat (toolchain .commandLine ()).isEqualTo ("cmd-line" );
69- assertThat (toolchain .pluginExecutable ().getExecutable ().getRootRelativePathString ())
70- .isEqualTo ("x/plugin" );
87+ @ Test
88+ public void protoToolchainBlacklistProtoLibraries () throws Exception {
89+ scratch .file (
90+ "third_party/x/BUILD" ,
91+ TestConstants .LOAD_PROTO_LIBRARY ,
92+ "licenses(['unencumbered'])" ,
93+ "cc_binary(name = 'plugin', srcs = ['plugin.cc'])" ,
94+ "cc_library(name = 'runtime', srcs = ['runtime.cc'])" ,
95+ "proto_library(name = 'descriptors', srcs = ['metadata.proto', 'descriptor.proto'])" ,
96+ "proto_library(name = 'any', srcs = ['any.proto'], strip_import_prefix = '/third_party')" );
7197
72- TransitiveInfoCollection runtimes = toolchain .runtime ();
73- assertThat (runtimes .getLabel ())
74- .isEqualTo (Label .parseAbsolute ("//x:runtime" , ImmutableMap .of ()));
98+ scratch .file (
99+ "foo/BUILD" ,
100+ TestConstants .LOAD_PROTO_LANG_TOOLCHAIN ,
101+ "proto_lang_toolchain(" ,
102+ " name = 'toolchain'," ,
103+ " command_line = 'cmd-line'," ,
104+ " plugin = '//third_party/x:plugin'," ,
105+ " runtime = '//third_party/x:runtime'," ,
106+ " blacklisted_protos = ['//third_party/x:descriptors', '//third_party/x:any']" ,
107+ ")" );
75108
76- assertThat (prettyArtifactNames (toolchain .blacklistedProtos ()))
77- .containsExactly ("x/metadata.proto" , "x/descriptor.proto" , "x/any.proto" );
109+ update (ImmutableList .of ("//foo:toolchain" ), false , 1 , true , new EventBus ());
110+
111+ validateProtoLangToolchain (
112+ getConfiguredTarget ("//foo:toolchain" ).getProvider (ProtoLangToolchainProvider .class ));
113+ }
114+
115+ @ Test
116+ public void protoToolchainMixedBlacklist () throws Exception {
117+ scratch .file (
118+ "third_party/x/BUILD" ,
119+ TestConstants .LOAD_PROTO_LIBRARY ,
120+ "licenses(['unencumbered'])" ,
121+ "cc_binary(name = 'plugin', srcs = ['plugin.cc'])" ,
122+ "cc_library(name = 'runtime', srcs = ['runtime.cc'])" ,
123+ "proto_library(name = 'metadata', srcs = ['metadata.proto'])" ,
124+ "proto_library(" ,
125+ " name = 'descriptor'," ,
126+ " srcs = ['descriptor.proto']," ,
127+ " strip_import_prefix = '/third_party')" ,
128+ "filegroup(name = 'any', srcs = ['any.proto'])" );
129+
130+ scratch .file (
131+ "foo/BUILD" ,
132+ TestConstants .LOAD_PROTO_LANG_TOOLCHAIN ,
133+ "proto_lang_toolchain(" ,
134+ " name = 'toolchain'," ,
135+ " command_line = 'cmd-line'," ,
136+ " plugin = '//third_party/x:plugin'," ,
137+ " runtime = '//third_party/x:runtime'," ,
138+ " blacklisted_protos = [" ,
139+ " '//third_party/x:metadata'," ,
140+ " '//third_party/x:descriptor'," ,
141+ " '//third_party/x:any']" ,
142+ ")" );
143+
144+ update (ImmutableList .of ("//foo:toolchain" ), false , 1 , true , new EventBus ());
145+
146+ validateProtoLangToolchain (
147+ getConfiguredTarget ("//foo:toolchain" ).getProvider (ProtoLangToolchainProvider .class ));
78148 }
79149
80150 @ Test
0 commit comments