run_tests.py 694 B

12345678910111213141516171819202122232425
  1. import os
  2. def test_file(filepath):
  3. return os.system("./pocketpy " + filepath) == 0
  4. #return os.system("python3 " + filepath) == 0
  5. def test_dir(path):
  6. has_error = False
  7. for filename in os.listdir(path):
  8. if filename.endswith('.py'):
  9. if(filename == '1.py'):
  10. continue
  11. filepath = os.path.join(path, filename)
  12. code = test_file(filepath)
  13. if not code:
  14. print("[x] " + filepath)
  15. has_error = True
  16. else:
  17. print("[√] " + filepath)
  18. return not has_error
  19. if __name__ == '__main__':
  20. ok = test_dir('./tests')
  21. if ok:
  22. print("ALL TESTS PASSED")