File: run-build-system-tests

package info (click to toggle)
awscli 2.31.35-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 156,692 kB
  • sloc: python: 213,816; xml: 14,082; makefile: 189; sh: 178; javascript: 8
file content (43 lines) | stat: -rwxr-xr-x 1,041 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3
import argparse
import os
import sys
from contextlib import contextmanager
from pathlib import Path
from subprocess import check_call

REPO_ROOT = Path(__file__).parents[2].absolute()
RUN_TESTS_SCRIPTS = os.path.join(REPO_ROOT, "scripts", "ci", "run-tests")


@contextmanager
def cd(path):
    """Change directory while inside context manager."""
    cwd = os.getcwd()
    try:
        os.chdir(path)
        yield
    finally:
        os.chdir(cwd)


def run(command):
    return check_call(command, shell=True)


def main(tests_path=None):
    if tests_path is None:
        tests_path = REPO_ROOT / "tests"
    with cd(tests_path):
        run(
            f"{sys.executable} {RUN_TESTS_SCRIPTS} "
            f"--tests-path {tests_path} "
            f"backends/build_system/ --allow-repo-root-on-path"
        )


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--tests-path", default=None, type=os.path.abspath)
    args = parser.parse_args()
    main(args.tests_path)