test.py 1.1 KB

12345678910111213141516171819202122232425262728
  1. import argparse
  2. from lib.os_tools import *
  3. from sccd.test.xml_loader import *
  4. if __name__ == '__main__':
  5. parser = argparse.ArgumentParser(
  6. description="Run SCCD tests.",
  7. epilog="Set environment variable SCCDDEBUG=1 to display debug information about the inner workings of the runtime.")
  8. 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.")
  9. parser.add_argument('--build-dir', metavar='BUILD_DIR', type=str, default='build', help="Directory for built tests. Defaults to 'build'")
  10. args = parser.parse_args()
  11. src_files = get_files(args.path,
  12. filter=lambda file: (file.startswith("test_") or file.startswith("fail_")) and file.endswith(".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)