-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathparse_omt.py
118 lines (107 loc) · 4.16 KB
/
parse_omt.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
from omv.engines import OMVEngines
from omv.engines.engine import EngineInstallationError, EngineExecutionError
from omv.omt_mep_parser import OMVTestParser
from omv.common.inout import inform, check, trim_path
from omv.tally import Tallyman
import sys
import platform
def parse_omt(omt_path, do_not_run=False, engine_version=None, ignore_non_py3=False):
inform("")
action = "Running"
if do_not_run:
action = "Checking"
inform(
action + " the tests defined in ",
trim_path(omt_path),
underline="=",
center=False,
)
mepomt = OMVTestParser(omt_path)
if mepomt.engine not in OMVEngines:
inform(
"Error! Unrecognised engine: %s (try running: omv list-engines)"
% mepomt.engine
)
exit(1)
engine = OMVEngines[mepomt.engine](
mepomt.modelpath, do_not_check_install=do_not_run, engine_version=engine_version
)
experiments = [exp for exp in mepomt.generate_exps(engine)]
tally = Tallyman(mepomt)
inform(
"Found %i experiment(s) to run on engine: %s "
% (len(experiments), engine.name),
indent=1,
)
# print('%s, %s, %s'%(platform.python_version_tuple()[0],ignore_non_py3,engine.python3_compatible))
if (
platform.python_version_tuple()[0] == "3"
and ignore_non_py3
and not engine.python3_compatible
):
inform(
"Not running experiment(s) on: %s, as this is Python %s and engine is not Python 3 compatible..."
% (engine.name, platform.python_version()),
indent=1,
)
tally.report_passing_if_no_exps = True
elif not do_not_run:
try:
engine.run()
some_failed = False
for exp in experiments:
inform("Running checks for experiment: ", exp.name, indent=1)
inform("")
results = exp.check_all()
inform(
"{:<30}{:^20}".format("Observable", "Test Passed"),
underline="-",
indent=3,
)
for rn, rv in results.items():
if sys.version_info >= (3, 0):
inform("{:<30}{:^20}".format(rn, check(rv)), indent=3)
else:
inform("{:<30}{:^20}".format(rn, check(rv)), indent=3)
if not rv:
some_failed = True
tally.add_experiment(exp, results)
if some_failed:
inform("+++++++++++++++++++++ Error info ++++++++++++++++++", indent=3)
inform(" Return code: %s" % engine.returncode, indent=3)
if hasattr(engine, "stdout"):
if isinstance(engine.stdout, str):
out = engine.stdout
else:
out = str(engine.stdout.decode())
inform(
" Output: %s"
% out.replace(
"\n", "\n[omv] %s:%s > " % (mepomt.omt_path, exp.name)
),
indent=3,
)
inform("+++++++++++++++++++++++++++++++++++++++++++++++++++", indent=3)
except (EngineInstallationError, EngineExecutionError):
# TODO: serialize exception info
inform(
"ERROR running engine ",
engine.name,
indent=1,
underline="-",
overline="-",
)
inform("+++++++++++++++++++++ Error info ++++++++++++++++++", indent=3)
inform(" Return code: %s" % engine.returncode, indent=3)
if hasattr(engine, "stdout"):
if isinstance(engine.stdout, str):
out = engine.stdout
else:
out = str(engine.stdout.decode())
inform(
" Output: %s"
% out.replace("\n", "\n[omv] %s > " % (mepomt.omt_path)),
indent=3,
)
inform("+++++++++++++++++++++++++++++++++++++++++++++++++++", indent=3)
return tally