Debian Codegraph @

scripts/ci/run-crt-tests

raw
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
6 import os
7 import sys
8 from contextlib import contextmanager
9 from subprocess import check_call
10
11 _dname = os.path.dirname
12
13 REPO_ROOT = _dname(_dname(_dname(os.path.abspath(__file__))))
14
15
16 @contextmanager
17 def cd(path):
18 """Change directory while inside context manager."""
19 cwd = os.getcwd()
20 try:
21 os.chdir(path)
22 yield
23 finally:
24 os.chdir(cwd)
25
26
27 def run(command, env=None):
28 return check_call(command, shell=True, env=env)
29
30
31 try:
32 import awscrt # noqa: F401
33 except ImportError:
34 print("MISSING DEPENDENCY: awscrt must be installed to run the crt tests.")
35 sys.exit(1)
36
37
38 if __name__ == "__main__":
39 with cd(os.path.join(REPO_ROOT, "tests")):
40 run(f"{REPO_ROOT}/scripts/ci/run-tests unit/ functional/")