test2.py 1.1 KB

12345678910111213141516171819202122232425262728
  1. import argparse
  2. from lib.os_tools import *
  3. from sccd.runtime.test import *
  4. from sccd.runtime.xml_loader2 import *
  5. if __name__ == '__main__':
  6. parser = argparse.ArgumentParser(
  7. description="Run SCCD tests.",
  8. epilog="Set environment variable SCCDDEBUG=1 to display debug information about the inner workings of state machines.")
  9. parser.add_argument('path', metavar='PATH', type=str, nargs='*', help="Tests to run. Can be a XML file or a directory. If a directory, it will be recursively scanned for XML files.")
  10. parser.add_argument('--build-dir', metavar='BUILD_DIR', type=str, default='build', help="Directory for built tests. Defaults to 'build'")
  11. args = parser.parse_args()
  12. src_files = get_files(args.path, filter=lambda file: file.endswith(".test.xml"))
  13. suite = unittest.TestSuite()
  14. for src_file in src_files:
  15. tests = load_test(src_file)
  16. for test in tests:
  17. suite.addTest(test)
  18. if len(src_files) == 0:
  19. print("No input files specified.")
  20. print()
  21. parser.print_usage()
  22. else:
  23. unittest.TextTestRunner(verbosity=2).run(suite)