-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest.py
More file actions
executable file
·42 lines (36 loc) · 1.47 KB
/
test.py
File metadata and controls
executable file
·42 lines (36 loc) · 1.47 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
"""With the pytest-cov plugin installed, run this using `py.test test.py --cov=nutshell/ --cov-report html`"""
import os
import sys
import ergo
import pytest
from nutshell.cli import cli
from nutshell.main import transpile, write_rule
from nutshell.common.utils import RAND_SEED, random as nutshell_rand
ARGV = sys.argv + [None, None][len(sys.argv):]
wtf = cli.commands['transpile']
cli.commands['transpile'].set_defaults(
comment_src='#### line {line}: {span} ####',
preserve_comments=True
)
def test_codecov():
for fname in list(os.walk('./examples/nutshells'))[0][2]:
with open('./examples/nutshells/' + fname) as fp:
transpile(fp)
if __name__ == '__main__':
main = ARGV[1]
if main is None:
pytest.main('test.py --cov=nutshell/ --cov-report=html'.split())
elif main in ('run', 'test'):
walk = list(os.walk('./examples/nutshells'))[0][2]
if main == 'run':
for fname in walk:
print(fname)
if len(ARGV) < 3 or fname.split('.')[0] in ARGV[2:]:
write_rule(infiles=['./examples/nutshells/' + fname], outdirs=['./examples/compiled_ruletables/'], find=False)
nutshell_rand.seed(RAND_SEED)
else:
for fname in walk:
if len(ARGV) < 3 or fname.split('.')[0] in ARGV[2:]:
with open('./examples/nutshells/' + fname) as fp:
transpile(fp)
nutshell_rand.seed(RAND_SEED)