gen_build_yaml.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Copyright 2015 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. """Generates the list of end2end test cases from generate_tests.bzl"""
  15. import os
  16. import sys
  17. import yaml
  18. _ROOT = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../../..'))
  19. os.chdir(_ROOT)
  20. def load(*args):
  21. """Replacement of bazel's load() function"""
  22. pass
  23. def struct(**kwargs):
  24. return kwargs # all the args as a dict
  25. # generate_tests.bzl is now the source of truth for end2end tests.
  26. # The .bzl file is basically a python file and we can "execute" it
  27. # to get access to the variables it defines.
  28. exec(
  29. compile(
  30. open('test/core/end2end/generate_tests.bzl', "rb").read(),
  31. 'test/core/end2end/generate_tests.bzl', 'exec'))
  32. def main():
  33. json = {
  34. # needed by end2end_tests.cc.template and end2end_nosec_tests.cc.template
  35. 'core_end2end_tests':
  36. dict((t, END2END_TESTS[t]['secure']) for t in END2END_TESTS.keys())
  37. }
  38. print(yaml.dump(json))
  39. if __name__ == '__main__':
  40. main()