-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathrun.py
executable file
·62 lines (51 loc) · 1.34 KB
/
run.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python
import argparse
import os
import sys
parser = argparse.ArgumentParser()
parser.add_argument(
"-L",
"--no-lint",
action="store_false",
default=True,
dest="lint",
help="Skip file linting",
)
parser.add_argument(
"-C",
"--no-coverage",
action="store_false",
default=True,
dest="coverage",
help="Skip coverage report",
)
args, rest = parser.parse_known_args()
root_dir = os.path.split(os.path.dirname(sys.argv[0]))[0]
report_dir = os.path.join(root_dir, "reports")
if not os.path.exists(report_dir):
os.mkdir(report_dir, mode=0o755)
if "PLACEBO_MODE" not in os.environ:
os.environ["PLACEBO_MODE"] = "playback"
os.environ["PLACEBO_DIR"] = os.path.join(root_dir, "tests", "unit", "placebo")
cmd = ["pytest", "--verbose"]
if args.lint:
lint_args = [
"--black",
"--pylint",
f"--pylint-rcfile={os.path.join(root_dir, '.pylintrc')}",
]
cmd.extend(lint_args)
if args.coverage:
coverage_args = [
"--cov=aws_gate",
"--cov-fail-under=100",
"--cov-report=term-missing",
"--cov-report=xml:reports/coverage.xml",
"--cov-report=html:reports/coverage/aws-gate",
"--junitxml=reports/test.xml",
]
cmd.extend(coverage_args)
else:
cmd.append("--no-cov")
cmd.extend(rest)
os.execvp(cmd[0], cmd) # noqa: S606