blob: df54293cbd0f4972c7ebfe3ec01dade3270af511 [file] [log] [blame]
Yannic948740b2020-01-15 19:27:35 +01001"""Contains a unittest to verify that `cc_proto_library` does not generate code for blacklisted `.proto` sources (i.e. WKPs)."""
2
3load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest")
4
5def _cc_proto_blacklist_test_impl(ctx):
6 """Verifies that there are no C++ compile actions for Well-Known-Protos.
7
8 Args:
9 ctx: The rule context.
10
11 Returns: A (not further specified) sequence of providers.
12 """
13
14 env = unittest.begin(ctx)
15
16 for dep in ctx.attr.deps:
17 files = len(dep.files.to_list())
18 asserts.equals(
19 env,
20 0,
21 files,
22 "Expected that target '{}' does not provide files, got {}".format(
23 dep.label,
24 files,
25 ),
26 )
27
28 return unittest.end(env)
29
30cc_proto_blacklist_test = unittest.make(
31 impl = _cc_proto_blacklist_test_impl,
32 attrs = {
33 "deps": attr.label_list(
34 mandatory = True,
35 providers = [CcInfo],
36 ),
37 },
38)