-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.py
45 lines (32 loc) · 1.06 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
from invoke import Collection, task
# pty=True added so that the tasks understand they're being run in a terminal
# and keep their pretty colored output
@task
def watch_for_mypy(c):
c.run(
"watchmedo shell-command --drop --command='mypy tests qcware_transpile' --recursive tests qcware_transpile",
pty=True,
)
@task
def mypy(c):
c.run("mypy tests qcware_transpile", pty=True)
@task
def watch_for_tests(c, test_path="tests"):
c.run(
f"watchmedo shell-command --drop --command='pytest --workers auto --tests-per-worker auto {test_path}' --recursive tests qcware_transpile",
pty=True,
)
@task
def test(c, test_path="tests"):
c.run(f"pytest -n auto {test_path}", pty=True)
@task
def test_serial(c, test_path="tests"):
c.run(f"pytest {test_path}", pty=True)
watches = Collection("watch")
watches.add_task(watch_for_mypy, "mypy")
watches.add_task(watch_for_tests, "tests")
ns = Collection()
ns.add_collection(watches, "watch")
ns.add_task(test, "test")
ns.add_task(test_serial, "test_serial")
ns.add_task(mypy, "mypy")