run_tests.py 764 B

12345678910111213141516171819202122232425262728293031
  1. import os
  2. import sys
  3. def test_file(filepath):
  4. if sys.platform == 'win32':
  5. return os.system("pocketpy.exe " + filepath) == 0
  6. else:
  7. return os.system("./pocketpy " + filepath) == 0
  8. def test_dir(path):
  9. has_error = False
  10. for filename in os.listdir(path):
  11. if not filename.endswith('.py'):
  12. continue
  13. filepath = os.path.join(path, filename)
  14. print("> " + filepath)
  15. code = test_file(filepath)
  16. if not code:
  17. has_error = True
  18. exit(1)
  19. return not has_error
  20. if __name__ == '__main__':
  21. if len(sys.argv) > 1:
  22. d = sys.argv[1]
  23. else:
  24. d = 'tests/'
  25. print("Testing directory:", d)
  26. ok = test_dir(d)
  27. if ok:
  28. print("ALL TESTS PASSED")