cc_proto_blacklist_test.bzl 999 B

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