Skip to content

Commit 3ebfd95

Browse files
committed
further cleaning
1 parent a338e39 commit 3ebfd95

3 files changed

Lines changed: 222 additions & 79 deletions

File tree

main.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
from pathlib import Path
22
from umbtest.benchmarks import Tester
3-
from umbtest.tools import PrismCLI, StormCLI, UmbPython
3+
from umbtest.tools import PrismCLI, StormCLI, UmbPython, check_tools
44

55
# Note. The following can be used to configure the locations of the tools.
6-
# PrismCLI.prism_dir_path = "/Users/junges/prism-umb/"
7-
# StormCLI._storm_path = "/Users/junges/storm-umb/build/bin/storm"
6+
# PrismCLI.prism_dir_path = /path_to_prism_dir/
7+
# StormCLI._storm_path = /path_to_storm_binary
8+
check_tools(PrismCLI, StormCLI, UmbPython)
9+
810

911
tester = Tester()
12+
tester.set_chain(PrismCLI, UmbPython, StormCLI)
1013

11-
tester.check_prism_file(Path(PrismCLI.prism_dir_path) / "prism-examples/simple/dice/dice.pm", ["R=? [F d=7]"])
14+
tester.check_prism_file(
15+
Path(PrismCLI.prism_dir_path) / "prism-examples/simple/dice/dice.pm",
16+
["R=? [F d=7]"],
17+
)

umbtest/benchmarks.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import tempfile
22
from typing import List
3-
from umbtest.tools import UmbTool
3+
from umbtest.tools import UmbTool, ReportedResults
44
from pathlib import Path
55

66

77
class UmbBenchmark:
88
def __init__(self, location):
99
self._location = location
1010

11+
1112
benchmarks = []
1213

14+
1315
class Tester:
1416
def __init__(self):
1517
self._tmpdir = tempfile.TemporaryDirectory()
@@ -23,30 +25,40 @@ def _tmpumbfile(self):
2325
def _tmplogfile(self):
2426
return tempfile.NamedTemporaryFile(dir=self._tmpdir.name, suffix=".log")
2527

26-
def set_chain(self, loader: UmbTool, transformer: None | UmbTool, checker: UmbTool):
28+
def set_chain(
29+
self, loader: UmbTool, transformer: None | UmbTool, checker: UmbTool
30+
) -> None:
2731
self._loader = loader
2832
self._transformer = transformer
2933
self._checker = checker
3034

31-
def check_prism_file(self, prism_file: Path, properties: List[str]):
35+
def check_prism_file(
36+
self, prism_file: Path, properties: List[str]
37+
) -> dict[str, ReportedResults]:
38+
result = dict()
3239
if self._loader is None or self._checker is None:
3340
raise RuntimeError("You must first set the tool chain, using set_chain()")
3441
tmpfile_in = self._tmpumbfile()
3542
log_file_to_umb = self._tmplogfile()
36-
result1 = self._loader.prism_file_to_umb(prism_file, Path(tmpfile_in.name), log_file=Path(log_file_to_umb.name))
43+
result["loader"] = self._loader.prism_file_to_umb(
44+
prism_file, Path(tmpfile_in.name), log_file=Path(log_file_to_umb.name)
45+
)
3746
if result1.error_code != 0:
3847
with open(result1.logfile, "r") as f:
3948
print(f.read())
4049

4150
if self._transformer:
4251
tmpfile_out = self._tmpumbfile()
43-
result2 = self._transformer.umb_to_umb(Path(tmpfile_in.name), Path(tmpfile_out.name),
44-
log_file=Path(self._tmplogfile().name))
52+
result["transformer"] = self._transformer.umb_to_umb(
53+
Path(tmpfile_in.name),
54+
Path(tmpfile_out.name),
55+
log_file=Path(self._tmplogfile().name),
56+
)
4557
else:
4658
tmpfile_out = tmpfile_in
47-
result3 = self._checker.check_umb(Path(tmpfile_out.name), log_file=Path(self._tmplogfile().name), properties=properties)
48-
49-
print(result1)
50-
if self._transformer:
51-
print(result2)
52-
print(result3)
59+
result["checker"] = self._checker.check_umb(
60+
Path(tmpfile_out.name),
61+
log_file=Path(self._tmplogfile().name),
62+
properties=properties,
63+
)
64+
return result

0 commit comments

Comments
 (0)