-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
62 lines (56 loc) · 1.52 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
import pathlib
import subprocess
from importlib.metadata import version
from invoke import task
from MyFirstLibrary import myfirstlibrary
ROOT = pathlib.Path(__file__).parent.resolve().as_posix()
VERSION = version("robotframework-myfirstlibrary")
@task
def utests(context):
cmd = [
"coverage",
"run",
"--source=MyFirstLibrary",
"-p",
"-m",
"pytest",
f"{ROOT}/utest",
]
subprocess.run(" ".join(cmd), shell=True, check=False)
@task
def atests(context):
cmd = [
"coverage",
"run",
"--source=MyFirstLibrary",
"-p",
"-m",
"robot",
"--loglevel=TRACE:DEBUG",
f"{ROOT}/atest",
]
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)
@task
def libdoc(context):
print(f"Generating libdoc for library version {VERSION}")
target = f"{ROOT}/docs/myfirstlibrary.html"
cmd = [
"python",
"-m",
"robot.libdoc",
"-n MyFirstLibrary",
f"-v {VERSION}",
"MyFirstLibrary",
target,
]
subprocess.run(" ".join(cmd), shell=True, check=False)
@task
def readme(context):
with open(f"{ROOT}/docs/README.md", "w", encoding="utf-8") as readme:
doc_string = myfirstlibrary.__doc__
readme.write(str(doc_string))