run-crt-tests 909 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env python
  2. # Don't run tests from the root repo dir.
  3. # We want to ensure we're importing from the installed
  4. # binary package not from the CWD.
  5. import os
  6. import sys
  7. from contextlib import contextmanager
  8. from subprocess import check_call
  9. _dname = os.path.dirname
  10. REPO_ROOT = _dname(_dname(_dname(os.path.abspath(__file__))))
  11. @contextmanager
  12. def cd(path):
  13. """Change directory while inside context manager."""
  14. cwd = os.getcwd()
  15. try:
  16. os.chdir(path)
  17. yield
  18. finally:
  19. os.chdir(cwd)
  20. def run(command, env=None):
  21. return check_call(command, shell=True, env=env)
  22. try:
  23. import awscrt # noqa: F401
  24. except ImportError:
  25. print("MISSING DEPENDENCY: awscrt must be installed to run the crt tests.")
  26. sys.exit(1)
  27. if __name__ == "__main__":
  28. with cd(os.path.join(REPO_ROOT, "tests")):
  29. run(f"{REPO_ROOT}/scripts/ci/run-tests unit/ functional/")