Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

70 rindas
1.6KB

  1. #!/usr/bin/env python3
  2. import argparse
  3. from pathlib import Path
  4. from typing import List, NamedTuple
  5. import subprocess
  6. import sys
  7. class TestOptions(NamedTuple):
  8. exe: Path
  9. toolchain: str
  10. def run_test_dir(dir: Path, opts: TestOptions) -> bool:
  11. try:
  12. subprocess.check_call(
  13. [
  14. str(opts.exe),
  15. 'build',
  16. '--export',
  17. '--warnings',
  18. '--tests',
  19. '--toolchain',
  20. opts.toolchain,
  21. ],
  22. cwd=dir,
  23. )
  24. except subprocess.CalledProcessError:
  25. import traceback
  26. traceback.print_exc()
  27. return False
  28. return True
  29. def run_tests(opts: TestOptions) -> int:
  30. print('Sanity check...')
  31. subprocess.check_output([str(opts.exe), '--help'])
  32. tests_subdir = Path(__file__).parent.absolute() / 'tests'
  33. test_dirs = tests_subdir.glob('*.test')
  34. ret = 0
  35. for td in test_dirs:
  36. if not run_test_dir(td, opts):
  37. ret = 1
  38. return ret
  39. def main(argv: List[str]) -> int:
  40. parser = argparse.ArgumentParser()
  41. parser.add_argument(
  42. '--exe',
  43. '-e',
  44. help='Path to the ddslim executable to test',
  45. required=True)
  46. parser.add_argument(
  47. '--toolchain',
  48. '-T',
  49. help='The ddslim toolchain to use while testing',
  50. required=True,
  51. )
  52. args = parser.parse_args(argv)
  53. opts = TestOptions(exe=Path(args.exe).absolute(), toolchain=args.toolchain)
  54. return run_tests(opts)
  55. if __name__ == "__main__":
  56. sys.exit(main(sys.argv[1:]))