internal_python_rules.bzl 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # Copyright 2021 The gRPC Authors
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. """Python-related rules intended only for use internal to the repo."""
  15. load("//bazel:gevent_test.bzl", "py_grpc_gevent_test")
  16. def internal_py_grpc_test(name, **kwargs):
  17. """Runs a test under all supported environments.
  18. Args:
  19. name: The name of the test.
  20. **kwargs: Any additional arguments to add to the test.
  21. """
  22. native.py_test(
  23. name = name + ".native",
  24. python_version = "PY3",
  25. **kwargs
  26. )
  27. py_grpc_gevent_test(name, **kwargs)
  28. suite_kwargs = {}
  29. if "visibility" in kwargs:
  30. suite_kwargs["visibility"] = kwargs["visibility"]
  31. native.test_suite(
  32. name = name,
  33. tests = [
  34. name + ".native",
  35. name + ".gevent",
  36. ],
  37. **suite_kwargs
  38. )