@@ -175,6 +175,70 @@ def _target_for_spec(spec_file: Path) -> Target:
175
175
return Target (main_file , main_module_name )
176
176
177
177
178
+ def _test_prove (
179
+ spec_file : Path ,
180
+ kompiled_target_for : Callable [[Path ], Path ],
181
+ tmp_path : Path ,
182
+ caplog : LogCaptureFixture ,
183
+ no_use_booster : bool ,
184
+ use_booster_dev : bool ,
185
+ bug_report : BugReport | None ,
186
+ spec_name : str | None ,
187
+ workers : int | None = None ,
188
+ ) -> None :
189
+ caplog .set_level (logging .INFO )
190
+
191
+ if use_booster_dev and spec_file in FAILING_BOOSTER_DEV_TESTS :
192
+ pytest .skip ()
193
+
194
+ if spec_name is not None and str (spec_file ).find (spec_name ) < 0 :
195
+ pytest .skip ()
196
+
197
+ # Given
198
+ log_file = tmp_path / 'log.txt'
199
+ use_directory = tmp_path / 'kprove'
200
+ use_directory .mkdir ()
201
+
202
+ # When
203
+ try :
204
+ definition_dir = kompiled_target_for (spec_file )
205
+ name = str (spec_file .relative_to (SPEC_DIR ))
206
+ break_on_calls = name in TEST_PARAMS and TEST_PARAMS [name ].break_on_calls
207
+ break_on_basic_blocks = name in TEST_PARAMS and TEST_PARAMS [name ].break_on_basic_blocks
208
+ if workers is None :
209
+ workers = 1 if name not in TEST_PARAMS else TEST_PARAMS [name ].workers
210
+ options = ProveOptions (
211
+ {
212
+ 'spec_file' : spec_file ,
213
+ 'definition_dir' : definition_dir ,
214
+ 'includes' : [str (include_dir ) for include_dir in config .INCLUDE_DIRS ],
215
+ 'save_directory' : use_directory ,
216
+ 'md_selector' : 'foo' , # TODO Ignored flag, this is to avoid KeyError
217
+ 'use_booster' : not no_use_booster ,
218
+ 'use_booster_dev' : use_booster_dev ,
219
+ 'bug_report' : bug_report ,
220
+ 'break_on_calls' : break_on_calls ,
221
+ 'break_on_basic_blocks' : break_on_basic_blocks ,
222
+ 'workers' : workers ,
223
+ }
224
+ )
225
+ exec_prove (options = options )
226
+ if name in TEST_PARAMS :
227
+ params = TEST_PARAMS [name ]
228
+ if params .leaf_number is not None and params .main_claim_id is not None :
229
+ apr_proof = APRProof .read_proof_data (
230
+ proof_dir = use_directory ,
231
+ id = params .main_claim_id ,
232
+ )
233
+ expected_leaf_number = params .leaf_number
234
+ actual_leaf_number = leaf_number (apr_proof )
235
+ assert expected_leaf_number == actual_leaf_number
236
+ except BaseException :
237
+ raise
238
+ finally :
239
+ log_file .write_text (caplog .text )
240
+
241
+
178
242
@pytest .mark .parametrize (
179
243
'spec_file' ,
180
244
ALL_TESTS ,
@@ -299,68 +363,30 @@ def test_prove_functional(
299
363
)
300
364
301
365
302
- def _test_prove (
303
- spec_file : Path ,
366
+ def test_prove_dss (
304
367
kompiled_target_for : Callable [[Path ], Path ],
305
368
tmp_path : Path ,
306
369
caplog : LogCaptureFixture ,
307
- no_use_booster : bool ,
308
- use_booster_dev : bool ,
309
370
bug_report : BugReport | None ,
310
371
spec_name : str | None ,
311
- workers : int | None = None ,
312
372
) -> None :
373
+ spec_file = Path ('../tests/specs/mcd/vat-spec.k' )
313
374
caplog .set_level (logging .INFO )
314
375
315
- if use_booster_dev and spec_file in FAILING_BOOSTER_DEV_TESTS :
316
- pytest .skip ()
317
-
318
376
if spec_name is not None and str (spec_file ).find (spec_name ) < 0 :
319
377
pytest .skip ()
320
378
321
- # Given
322
- log_file = tmp_path / 'log.txt'
323
- use_directory = tmp_path / 'kprove'
324
- use_directory .mkdir ()
325
-
326
- # When
327
- try :
328
- definition_dir = kompiled_target_for (spec_file )
329
- name = str (spec_file .relative_to (SPEC_DIR ))
330
- break_on_calls = name in TEST_PARAMS and TEST_PARAMS [name ].break_on_calls
331
- break_on_basic_blocks = name in TEST_PARAMS and TEST_PARAMS [name ].break_on_basic_blocks
332
- if workers is None :
333
- workers = 1 if name not in TEST_PARAMS else TEST_PARAMS [name ].workers
334
- options = ProveOptions (
335
- {
336
- 'spec_file' : spec_file ,
337
- 'definition_dir' : definition_dir ,
338
- 'includes' : [str (include_dir ) for include_dir in config .INCLUDE_DIRS ],
339
- 'save_directory' : use_directory ,
340
- 'md_selector' : 'foo' , # TODO Ignored flag, this is to avoid KeyError
341
- 'use_booster' : not no_use_booster ,
342
- 'use_booster_dev' : use_booster_dev ,
343
- 'bug_report' : bug_report ,
344
- 'break_on_calls' : break_on_calls ,
345
- 'break_on_basic_blocks' : break_on_basic_blocks ,
346
- 'workers' : workers ,
347
- }
348
- )
349
- exec_prove (options = options )
350
- if name in TEST_PARAMS :
351
- params = TEST_PARAMS [name ]
352
- if params .leaf_number is not None and params .main_claim_id is not None :
353
- apr_proof = APRProof .read_proof_data (
354
- proof_dir = use_directory ,
355
- id = params .main_claim_id ,
356
- )
357
- expected_leaf_number = params .leaf_number
358
- actual_leaf_number = leaf_number (apr_proof )
359
- assert expected_leaf_number == actual_leaf_number
360
- except BaseException :
361
- raise
362
- finally :
363
- log_file .write_text (caplog .text )
379
+ _test_prove (
380
+ spec_file ,
381
+ kompiled_target_for ,
382
+ tmp_path ,
383
+ caplog ,
384
+ False ,
385
+ False ,
386
+ bug_report = bug_report ,
387
+ spec_name = spec_name ,
388
+ workers = 8 ,
389
+ )
364
390
365
391
366
392
def test_prove_optimizations (
@@ -410,29 +436,3 @@ def _get_optimization_proofs() -> list[APRProof]:
410
436
proof_display = '\n ' .join (' ' + line for line in proof_show .show (proof ))
411
437
_LOGGER .info (f'Proof { proof .id } :\n { proof_display } ' )
412
438
assert proof .passed
413
-
414
-
415
- def test_prove_dss (
416
- kompiled_target_for : Callable [[Path ], Path ],
417
- tmp_path : Path ,
418
- caplog : LogCaptureFixture ,
419
- bug_report : BugReport | None ,
420
- spec_name : str | None ,
421
- ) -> None :
422
- spec_file = Path ('../tests/specs/mcd/vat-spec.k' )
423
- caplog .set_level (logging .INFO )
424
-
425
- if spec_name is not None and str (spec_file ).find (spec_name ) < 0 :
426
- pytest .skip ()
427
-
428
- _test_prove (
429
- spec_file ,
430
- kompiled_target_for ,
431
- tmp_path ,
432
- caplog ,
433
- False ,
434
- False ,
435
- bug_report = bug_report ,
436
- spec_name = spec_name ,
437
- workers = 8 ,
438
- )
0 commit comments