run_tests.py 757 B

12345678910111213141516171819202122232425262728
  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 filename.endswith('.py'):
  12. if(filename == '1.py'):
  13. continue
  14. filepath = os.path.join(path, filename)
  15. code = test_file(filepath)
  16. if not code:
  17. print("[x] " + filepath)
  18. has_error = True
  19. else:
  20. print("[√] " + filepath)
  21. return not has_error
  22. if __name__ == '__main__':
  23. ok = test_dir('tests')
  24. if ok:
  25. print("ALL TESTS PASSED")