run.py 948 B

1234567891011121314151617181920212223242526272829303132333435
  1. import subprocess
  2. import os.path
  3. import sys
  4. this_dir = os.path.dirname(sys.argv[0])
  5. new_env = dict(os.environ)
  6. new_env.update({
  7. 'LC_ALL': 'en_US.UTF-8',
  8. 'PYTHONPATH': os.path.join(this_dir, ".."),
  9. })
  10. def has_py(version):
  11. ret = subprocess.run("which %s" % version, shell=True, stdout=subprocess.DEVNULL)
  12. return ret.returncode == 0
  13. def run_test(versions):
  14. found = False
  15. for i in versions:
  16. if not has_py(i):
  17. # if this version doesn't exist in path, skip
  18. continue
  19. found = True
  20. print("Testing %s" % i)
  21. subprocess.run([i, os.path.join(this_dir, "test.py")], env=new_env, check=True)
  22. subprocess.run([i, os.path.join(this_dir, "libmagic_test.py")], env=new_env, check=True)
  23. if not found:
  24. sys.exit("No versions found: " + str(versions))
  25. run_test(["python2", "python2.7"])
  26. run_test(["python3.5", "python3.6", "python3.7", "python3.8", "python3.9"])