fix: complete issue17 cleanup and bounded native verification
This commit is contained in:
1 parent
14cacb1d1c
commit
07eab61695
12 files changed
+642
-26
No files matched your search
@@ -88,7 +88,7 @@ End Class
|
||||
|
||||
|
||||
def run_helper(tmp_path, *, save_body='Save = True', close_body='Close = True',
|
||||
is_saved='True', gated=False, cancelled=False):
|
||||
is_saved='True', gated=False, cancelled=False, transform=None):
|
||||
source = Path('src/cbb_refresh_verify/save_verified_block.vbs').read_text('utf-8')
|
||||
classes = '''
|
||||
Class FakePi
|
||||
@@ -145,6 +145,8 @@ End Class
|
||||
source = source.replace('Option Explicit', 'Option Explicit\nDim closedDoc\n' + classes)
|
||||
source = source.replace('GetObject(, "MGCPCB.Application")', 'New FakeApp')
|
||||
source = source.replace('CreateObject("MGCPCBAutomationLicensing.Application")', 'New FakeLic')
|
||||
if transform is not None:
|
||||
source = transform(source)
|
||||
harness = tmp_path/'facts.vbs'
|
||||
harness.write_text(source, encoding='ascii')
|
||||
cancel = tmp_path/'cancel.signal'
|
||||
@@ -201,3 +203,23 @@ def test_unopened_gate_cancellation_exits_before_com(tmp_path):
|
||||
assert 'TEST_SAVE_CALLED' not in result.stdout
|
||||
assert 'VALIDATE_START' not in result.stdout
|
||||
assert result.returncode == 9
|
||||
|
||||
|
||||
def test_post_save_identity_failure_names_actual_and_expected_values(tmp_path):
|
||||
result = run_helper(tmp_path, transform=lambda source:source.replace(
|
||||
'ProjectFile = WScript.Arguments(0)',
|
||||
'If afterSave Then\nProjectFile = "other.prj"\nElse\nProjectFile = WScript.Arguments(0)\nEnd If')
|
||||
.replace('Dim closedDoc', 'Dim closedDoc, afterSave')
|
||||
.replace('Save = True', 'afterSave = True\nSave = True'))
|
||||
assert result.returncode == 8, result.stdout + result.stderr
|
||||
assert 'POST_SAVE_IDENTITY|project=other.prj|expected=expected.prj|document=CBB.pcb|expected_document=CBB.pcb' in result.stdout
|
||||
assert 'CLOSE_START' not in result.stdout
|
||||
|
||||
|
||||
def test_post_save_transient_unsaved_state_retries_before_closing(tmp_path):
|
||||
def transform(source):
|
||||
return source.replace('Dim closedDoc', 'Dim closedDoc, savedCalls').replace(
|
||||
'IsSaved = True', 'savedCalls = savedCalls + 1\nIsSaved = (savedCalls <> 2)')
|
||||
result = run_helper(tmp_path, transform=transform)
|
||||
assert result.returncode == 0, result.stdout + result.stderr
|
||||
assert 'CLOSE_OK' in result.stdout
|
||||
Reference in new issue
Block a user