@@ -103,7 +103,34 @@ 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+ '''Almost exactly like checkGolden, but only compares the result->satisfiable field of the reponses'''
108+ if os .path .exists (resp_golden_path ):
109+ debug ("Checking against golden file..." )
110+ with open (resp_golden_path , 'rb' ) as resp_golden_raw :
111+ golden_json = json .loads (resp_golden_raw .read ())
112+ resp_json = json .loads (resp )
113+ if golden_json .get ("result" , {"IMPOSSIBLE" : "IMPOSSIBLE" }).get ("satisfiable" , "IMPOSSIBLE" ) != resp_json .get ("result" , {}).get ("satisfiable" , "" ):
114+ print (f"Test '{ name } ' { red } failed.{ endred } " )
115+ info (diff_strings (str (golden_json ), str (resp )))
116+ if RECREATE_BROKEN_GOLDEN :
117+ with open (resp_golden_path , 'wb' ) as resp_golden_writer :
118+ resp_golden_writer .write (resp )
119+ else :
120+ info ("Expected" )
121+ info (golden_json )
122+ info ("but got" )
123+ info (resp )
124+ exit (1 )
125+ else :
126+ info (f"Test '{ name } ' { green } passed{ endgreen } " )
127+ elif CREATE_MISSING_GOLDEN or RECREATE_BROKEN_GOLDEN :
128+ with open (resp_golden_path , 'wb' ) as resp_golden_writer :
129+ resp_golden_writer .write (resp )
130+ else :
131+ debug (resp )
132+ info (f"Golden file { red } not found{ endred } " )
133+ exit (1 )
107134
108135def runTest (def_path , req , resp_golden_path , smt_tactic = None ):
109136 smt_options = ["--smt-tactic" , str (smt_tactic )] if smt_tactic else []
@@ -122,7 +149,11 @@ def runTest(def_path, req, resp_golden_path, smt_tactic = None):
122149 debug (resp )
123150 process .kill ()
124151
125- checkGolden (resp , resp_golden_path )
152+ req_method = json .loads (req )["method" ]
153+ if req_method == "get-model" :
154+ checkGoldenGetModel (resp , resp_golden_path )
155+ else :
156+ checkGolden (resp , resp_golden_path )
126157
127158print ("Running execute tests:" )
128159
0 commit comments