-
Notifications
You must be signed in to change notification settings - Fork 21
/
tasks.py
108 lines (100 loc) · 2.89 KB
/
tasks.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import pathlib
import subprocess
from invoke import task
import DocTest
from DocTest import __version__ as VERSION
import inspect
if not hasattr(inspect, 'getargspec'):
inspect.getargspec = inspect.getfullargspec
ROOT = pathlib.Path(__file__).parent.resolve().as_posix()
utests_completed_process = None
atests_completed_process = None
@task
def utests(context):
cmd = [
"coverage",
"run",
"--source=DocTest",
"-p",
"-m",
"pytest",
"--junitxml=results/pytest.xml",
f"{ROOT}/utest",
]
global utests_completed_process
utests_completed_process = subprocess.run(" ".join(cmd), shell=True, check=False)
@task
def atests(context):
cmd = [
"coverage",
"run",
"--source=DocTest",
"-p",
"-m",
"robot",
"--loglevel=TRACE:DEBUG",
"--listener RobotStackTracer",
"-d results",
"--prerebotmodifier utilities.xom.XUnitOut:results/xunit.xml",
f"{ROOT}/atest/Compare.robot",
f"{ROOT}/atest/PdfContent.robot",
f"{ROOT}/atest/PrintJobs.robot",
f"{ROOT}/atest/MovementDetection.robot",
]
global atests_completed_process
atests_completed_process = subprocess.run(" ".join(cmd), shell=True, check=False)
@task(utests, atests)
def tests(context):
subprocess.run("coverage combine", shell=True, check=False)
subprocess.run("coverage report", shell=True, check=False)
subprocess.run("coverage html", shell=True, check=False)
if utests_completed_process.returncode != 0 or atests_completed_process.returncode != 0:
raise Exception("Tests failed")
@task
def coverage_report(context):
subprocess.run("coverage combine", shell=True, check=False)
subprocess.run("coverage report", shell=True, check=False)
subprocess.run("coverage html", shell=True, check=False)
@task
def libdoc(context):
source = f"{ROOT}/DocTest/VisualTest.py"
target = f"{ROOT}/docs/VisualTest.html"
cmd = [
"python",
"-m",
"robot.libdoc",
"-n VisualTest",
f"-v {VERSION}",
source,
target,
]
subprocess.run(" ".join(cmd), shell=True)
source = f"{ROOT}/DocTest/PdfTest.py"
target = f"{ROOT}/docs/PdfTest.html"
cmd = [
"python",
"-m",
"robot.libdoc",
"-n PdfTest",
f"-v {VERSION}",
source,
target,
]
subprocess.run(" ".join(cmd), shell=True)
source = f"{ROOT}/DocTest/PrintJobTests.py"
target = f"{ROOT}/docs/PrintJobTest.html"
cmd = [
"python",
"-m",
"robot.libdoc",
"-n PrintJobTest",
f"-v {VERSION}",
source,
target,
]
subprocess.run(" ".join(cmd), shell=True)
@task
def readme(context):
with open(f"{ROOT}/README.md", "w", encoding="utf-8") as readme:
doc_string = DocTest.__doc__
readme.write(str(doc_string))