Skip to content

Commit 4c7a5d0

Browse files
committed
Special-case the test script for get-model
1 parent 08dbeab commit 4c7a5d0

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

test/rpc-server/runTests.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,33 @@ def checkGolden (resp, resp_golden_path):
103103
info(f"Golden file {red}not found{endred}")
104104
exit(1)
105105

106-
106+
def checkGoldenGetModel(resp, resp_golden_path):
107+
if os.path.exists(resp_golden_path):
108+
debug("Checking against golden file...")
109+
with open(resp_golden_path, 'rb') as resp_golden_raw:
110+
golden_json = json.loads(resp_golden_raw.read())
111+
resp_json = json.loads(resp)
112+
if golden_json["result"]["satisfiable"] != resp_json["result"]["satisfiable"]:
113+
print(f"Test '{name}' {red}failed.{endred}")
114+
info(diff_strings(str(golden_json), str(resp)))
115+
if RECREATE_BROKEN_GOLDEN:
116+
with open(resp_golden_path, 'wb') as resp_golden_writer:
117+
resp_golden_writer.write(resp)
118+
else:
119+
info("Expected")
120+
info(golden_json)
121+
info("but got")
122+
info(resp)
123+
exit(1)
124+
else:
125+
info(f"Test '{name}' {green}passed{endgreen}")
126+
elif CREATE_MISSING_GOLDEN or RECREATE_BROKEN_GOLDEN:
127+
with open(resp_golden_path, 'wb') as resp_golden_writer:
128+
resp_golden_writer.write(resp)
129+
else:
130+
debug(resp)
131+
info(f"Golden file {red}not found{endred}")
132+
exit(1)
107133

108134
def runTest(def_path, req, resp_golden_path, smt_tactic = None):
109135
smt_options = ["--smt-tactic", str(smt_tactic)] if smt_tactic else []
@@ -122,7 +148,11 @@ def runTest(def_path, req, resp_golden_path, smt_tactic = None):
122148
debug(resp)
123149
process.kill()
124150

125-
checkGolden(resp, resp_golden_path)
151+
req_method = json.loads(req)["method"]
152+
if req_method == "get-model":
153+
checkGoldenGetModel(resp, resp_golden_path)
154+
else:
155+
checkGolden(resp, resp_golden_path)
126156

127157
print("Running execute tests:")
128158

0 commit comments

Comments
 (0)