-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_standalone.py
executable file
·76 lines (62 loc) · 1.44 KB
/
test_standalone.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
#!/usr/bin/env python3
import sys
from subprocess import check_call, run, check_output, PIPE
from pathlib import Path
from os.path import join
from shutil import copy
from tempfile import TemporaryDirectory
from typing import List, Dict
standalone: List[str] = [
'cannon.py',
'kompress.py',
'kjson.py',
'kjq.py',
'kerror.py',
'konsume.py',
'kimport.py',
'state.py',
]
def check(p: Path) -> List[str]:
checks = []
def check(*args, **kwargs):
print(' '.join(args))
checks.append(run(args, **kwargs))
with TemporaryDirectory() as tdir:
# TODO how to make sure they won't autoimport
tmp = join(tdir, p.name)
copy(p, tmp)
check(
'pytest',
'--doctest-modules',
'-s',
tmp,
)
check(
'mypy',
'--strict-optional',
'--check-untyped-defs',
tmp,
)
check(
'pylint',
'-E',
tmp,
)
errs = []
for c in checks:
if c.returncode == 0:
continue
errs.append(f'ERROR WHILE CHECKING {p}')
return errs
def main():
errors: List[str] = []
for s in standalone:
errors.extend(check(Path('kython').joinpath(s)))
if len(errors) > 0:
for e in errors:
print(e)
sys.exit(1)
else:
print("All good!")
if __name__ == '__main__':
main()