test2.py 1.1 KB

1234567891011121314151617181920212223242526272829
  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 the runtime.")
  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,
  13. filter=lambda file: file.startswith("test_") and file.endswith(".xml"))
  14. suite = unittest.TestSuite()
  15. for src_file in src_files:
  16. tests = load_test(src_file)
  17. for test in tests:
  18. suite.addTest(test)
  19. if len(src_files) == 0:
  20. print("No input files specified.")
  21. print()
  22. parser.print_usage()
  23. else:
  24. unittest.TextTestRunner(verbosity=2).run(suite)