CIAssignExampleTest.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. test_fw_path = os.getenv("TEST_FW_PATH")
  23. if test_fw_path:
  24. sys.path.insert(0, test_fw_path)
  25. from Utility.CIAssignTest import AssignTest, Group
  26. class ExampleGroup(Group):
  27. SORT_KEYS = CI_JOB_MATCH_KEYS = ["env_tag", "chip"]
  28. class CIExampleAssignTest(AssignTest):
  29. CI_TEST_JOB_PATTERN = re.compile(r"^example_test_.+")
  30. if __name__ == '__main__':
  31. parser = argparse.ArgumentParser()
  32. parser.add_argument("test_case",
  33. help="test case folder or file")
  34. parser.add_argument("ci_config_file",
  35. help="gitlab ci config file")
  36. parser.add_argument("output_path",
  37. help="output path of config files")
  38. args = parser.parse_args()
  39. assign_test = CIExampleAssignTest(args.test_case, args.ci_config_file, case_group=ExampleGroup)
  40. assign_test.assign_cases()
  41. assign_test.output_configs(args.output_path)