CIAssignExampleTest.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
  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. """
  15. Command line tool to assign example tests to CI test jobs.
  16. """
  17. # TODO: Need to handle running examples on different chips
  18. import os
  19. import sys
  20. import re
  21. import argparse
  22. try:
  23. from Utility.CIAssignTest import AssignTest
  24. except ImportError:
  25. test_fw_path = os.getenv("TEST_FW_PATH")
  26. if test_fw_path:
  27. sys.path.insert(0, test_fw_path)
  28. from Utility.CIAssignTest import AssignTest
  29. from Utility.CIAssignTest import Group
  30. class ExampleGroup(Group):
  31. SORT_KEYS = CI_JOB_MATCH_KEYS = ["env_tag", "chip"]
  32. class CIExampleAssignTest(AssignTest):
  33. CI_TEST_JOB_PATTERN = re.compile(r"^example_test_.+")
  34. if __name__ == '__main__':
  35. parser = argparse.ArgumentParser()
  36. parser.add_argument("test_case",
  37. help="test case folder or file")
  38. parser.add_argument("ci_config_file",
  39. help="gitlab ci config file")
  40. parser.add_argument("output_path",
  41. help="output path of config files")
  42. args = parser.parse_args()
  43. assign_test = CIExampleAssignTest(args.test_case, args.ci_config_file, case_group=ExampleGroup)
  44. assign_test.assign_cases()
  45. assign_test.output_configs(args.output_path)