-
-
Notifications
You must be signed in to change notification settings - Fork 206
Expand file tree
/
Copy pathrun_tests.py
More file actions
executable file
·56 lines (48 loc) · 1.79 KB
/
Copy pathrun_tests.py
File metadata and controls
executable file
·56 lines (48 loc) · 1.79 KB
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
#!/usr/bin/env python3
"""Run novelWriter Tests.""" # noqa: CPY001
import argparse
import os
import shlex
import subprocess
import sys
if __name__ == "__main__":
"""Parse command line options and run the commands."""
parser = argparse.ArgumentParser(usage="run_tests.py [--flags]")
parser.add_argument("-o", action="store_true", help="Run off screen")
parser.add_argument("-r", action="store_true", help="Generate reports")
parser.add_argument("-t", action="store_true", help="Generate terminal report")
parser.add_argument("-u", action="store_true", help="Generate uncovered terminal report")
parser.add_argument("-lf", action="store_true", help="Re-run failed tests")
parser.add_argument("-sw", action="store_true", help="Run tests stepwise")
parser.add_argument("-m", help="Test modules", metavar="MARKEXPR")
parser.add_argument("-k", help="Test filters", metavar="EXPRESSION")
args = parser.parse_args()
env = os.environ.copy()
env["QT_SCALE_FACTOR"] = "1.0"
if args.r or args.t or args.u:
cmd = ["coverage", "run"]
if args.lf or args.sw:
cmd += ["--append"]
cmd += ["-m"]
else:
cmd = [sys.executable, "-m"]
cmd += ["pytest", "-vv"]
if args.o:
env["QT_QPA_PLATFORM"] = "offscreen"
if args.lf:
cmd += ["--last-failed"]
if args.sw:
cmd += ["--stepwise"]
if args.m:
cmd += ["-m", args.m]
if args.k:
cmd += ["-k", args.k]
print("Calling:", shlex.join(cmd))
subprocess.call(cmd, env=env)
if args.r:
subprocess.call(["coverage", "xml"])
subprocess.call(["coverage", "html"])
if args.t and not args.u:
subprocess.call(["coverage", "report"])
if args.u:
subprocess.call(["coverage", "report", "--skip-covered"])