feat: complete native BOM and Harness execution acceptance

This commit is contained in:
阿白叔 committed 2026-11-12 19:21:55 +08:00
1 parent 4f8fbd7806
commit 65438cb7e5
234 files changed
+24402 -865

No files matched your search

@@ -438,6 +438,54 @@ Require Len(QP_App.ProjectPath)=0,"retry would be blocked by an open recovery pr
''')
@pytest.mark.parametrize('source_unchanged', [False, True])
def test_source_only_recovery_cannot_restore_or_accept_a_target(tmp_path, source_unchanged):
original = '''
Set Attr=Comp.FindAttribute("Part Number"): Attr.Value="OLD"
Set Attr=Comp.FindAttribute("Part Name"): Attr.Value="OLD_NAME"
Set Attr=Comp.FindAttribute("Part Label"): Attr.Value="OLD_LABEL"
Set Attr=Comp.FindAttribute("Value"): Attr.Value="OLD_VALUE"
QPRestoreDisplay Attr,Saved,"R1"
''' if source_unchanged else '''
Command.Add "recovery_part_name","NEW_NAME"
Command.Add "recovery_part_label","NEW_LABEL"
'''
run_vbs(tmp_path, 'part_number', '''
Command.Add "recovery_source_only","1"
''' + original + '''
On Error Resume Next
QPRecoverSavedJob Command,SnapshotPath
Failure=Err.Number
Err.Clear
On Error GoTo 0
Require QP_App.TransactionCount=0,"source-only recovery modified attributes"
Require Not QP_App.SaveCalled,"source-only recovery saved"
Require QP_App.UndoCount=0,"source-only recovery undid work"
''' + ('''
Require Failure=0,"unchanged source rejected"
Require QPReadState(QP_Fso.BuildPath(QP_Root,"status.tsv"),QP_CurrentJobId)="retry_ready","source not certified"
''' if source_unchanged else '''
Require Failure<>0,"source-only recovery accepted a target"
Require QPReadState(QP_Fso.BuildPath(QP_Root,"status.tsv"),QP_CurrentJobId)<>"restored_ok","source-only claimed target success"
'''))
def test_source_only_readback_does_not_require_a_target_part_name(tmp_path, monkeypatch):
monkeypatch.setitem(globals(), 'SETUP', SETUP.replace(
'Set Attr=Comp.FindAttribute("Part Name"): Attr.Value="NEW_NAME"', ''))
run_vbs(tmp_path, 'part_number', '''
Command.Add "recovery_source_only","1"
Set Attr=Comp.FindAttribute("Part Number"):Attr.Value="OLD"
Set Attr=Comp.FindAttribute("Part Label"):Attr.Value="OLD_LABEL"
Set Attr=Comp.FindAttribute("Value"):Attr.Value="OLD_VALUE"
QPRestoreDisplay Attr,Saved,"R1"
QPRecoverSavedJob Command,SnapshotPath
Require QPReadState(QP_Fso.BuildPath(QP_Root,"status.tsv"),QP_CurrentJobId)="retry_ready","source with empty original part name rejected"
Require QP_App.TransactionCount=0,"source-only recovery wrote attributes"
Require Not QP_App.SaveCalled,"source-only recovery saved"
''', before='Comp.RemoveAttribute "Part Name"')
@pytest.mark.parametrize('change', ['QP_App.DocumentCount=2', 'QP_App.RefuseClose=True'])
def test_readonly_recovery_does_not_unlock_if_document_ownership_or_close_fails(tmp_path, change):
run_vbs(tmp_path, 'part_number', '''
@@ -929,6 +977,31 @@ Require Attr.InstanceValue="","existing NC marker created a redundant instance o
after='Set Attr=Comp.FindAttribute("Value"): Attr.Value="R0805/NC"')
@pytest.mark.parametrize('mode,expected', [
('preserve', 'R0805/NC'), ('part_label', 'R0805/NC'),
('part_number', 'NEW/NC'), ('custom', '47k/NC')])
def test_leading_nc_segment_is_preserved_in_every_value_mode(tmp_path, mode, expected):
run_vbs(tmp_path, mode, f'''
QPRestoreAfterOperatorReplace Command,SnapshotPath
Set Attr=Comp.FindAttribute("Value")
Require QPEffectiveAttributeValue(Attr)="{expected}","leading NC segment was lost"
QPVerifyDisplay Attr,Saved,"R1"
''', custom_value='47k' if mode == 'custom' else '',
before='Set Attr=Comp.FindAttribute("Value"): Attr.Value="NC/402K/1%"',
after='Set Attr=Comp.FindAttribute("Part Label"): Attr.Value="R0805": '
'Set Attr=Comp.FindAttribute("Value"): Attr.Value="R0805"')
@pytest.mark.parametrize('native_value', ['NC/0R', 'nc/0R'])
def test_existing_leading_nc_segment_is_not_duplicated(tmp_path, native_value):
run_vbs(tmp_path, 'preserve', f'''
QPRestoreAfterOperatorReplace Command,SnapshotPath
Set Attr=Comp.FindAttribute("Value")
Require QPEffectiveAttributeValue(Attr)="{native_value}","existing leading NC was duplicated"
''', before='Set Attr=Comp.FindAttribute("Value"): Attr.Value="10K/NC"',
after=f'Set Attr=Comp.FindAttribute("Value"): Attr.Value="{native_value}"')
def test_nc_marker_is_not_detected_when_rule_option_is_unchecked(tmp_path):
run_vbs(tmp_path, 'preserve', '''
QPRestoreAfterOperatorReplace Command,SnapshotPath