-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bazel] Fix blacklisted_protos in cc_toolchain and add test (#7075)
- Loading branch information
1 parent
2d9b178
commit 948740b
Showing
5 changed files
with
66 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"""Contains a unittest to verify that `cc_proto_library` does not generate code for blacklisted `.proto` sources (i.e. WKPs).""" | ||
|
||
load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest") | ||
|
||
def _cc_proto_blacklist_test_impl(ctx): | ||
"""Verifies that there are no C++ compile actions for Well-Known-Protos. | ||
Args: | ||
ctx: The rule context. | ||
Returns: A (not further specified) sequence of providers. | ||
""" | ||
|
||
env = unittest.begin(ctx) | ||
|
||
for dep in ctx.attr.deps: | ||
files = len(dep.files.to_list()) | ||
asserts.equals( | ||
env, | ||
0, | ||
files, | ||
"Expected that target '{}' does not provide files, got {}".format( | ||
dep.label, | ||
files, | ||
), | ||
) | ||
|
||
return unittest.end(env) | ||
|
||
cc_proto_blacklist_test = unittest.make( | ||
impl = _cc_proto_blacklist_test_impl, | ||
attrs = { | ||
"deps": attr.label_list( | ||
mandatory = True, | ||
providers = [CcInfo], | ||
), | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters