forked from teleological/camxes-py
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcover.py
executable file
·40 lines (31 loc) · 1.01 KB
/
cover.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
#!/usr/bin/env python3
# pylint: disable=I0011, C0111, C0326
import os
import json
from camxes import configure_platform
from camxes_py.parsers import camxes_ilmen
from camxes_py.transformers import node_coverage
TEST_DIRECTORY = "test"
INPUT_FILENAME = "camxes_ilmen_js.json"
PWD = os.path.dirname(__file__)
INPUT_PATH = os.path.join(PWD, TEST_DIRECTORY, INPUT_FILENAME)
def main():
input_json = read_json(INPUT_PATH)
visits = process_input(input_json)
print(json.dumps(visits, indent=4))
def read_json(path):
with open(path) as input_file:
input_json = json.load(input_file)
return input_json
def process_input(input_json):
input_specs = input_json["specs"]
parser = camxes_ilmen.Parser()
transformer = node_coverage.Transformer(parser)
for spec in input_specs:
if spec["out"] != "ERROR":
parsed = parser.parse(spec["txt"])
transformer.visit(parsed)
return transformer.visits()
if __name__ == '__main__':
configure_platform()
main()