test.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import argparse
  2. import unittest
  3. from lib.os_tools import *
  4. from lib.test import *
  5. from sccd.util.debug import *
  6. if __name__ == '__main__':
  7. argparser = argparse.ArgumentParser(
  8. description="Run SCCD tests.",
  9. epilog="Set environment variable SCCDDEBUG=1 to display debug information about the inner workings of the runtime.")
  10. argparser.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.")
  11. argparser.add_argument('--build-dir', metavar='BUILD_DIR', type=str, default='build', help="Directory for built tests. Defaults to 'build'")
  12. args = argparser.parse_args()
  13. src_files = get_files(args.path,
  14. filter=lambda file: (file.startswith("test_") or file.startswith("fail_")) and file.endswith(".xml"))
  15. if len(src_files) == 0:
  16. print("No input files specified.")
  17. print()
  18. argparser.print_usage()
  19. exit()
  20. suite = unittest.TestSuite()
  21. for src_file in src_files:
  22. should_fail = os.path.basename(src_file).startswith("fail_")
  23. if should_fail:
  24. suite.addTest(FailingTest(src_file))
  25. else:
  26. suite.addTest(Test(src_file))
  27. unittest.TextTestRunner(verbosity=2).run(suite)