From e5ebc5d14e5eda1a9822d8a0dc2e5aaa530bdff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=98=BF=E7=99=BD=E5=8F=94?= <11794527+absfan@user.noreply.gitee.com> Date: Mon, 19 Oct 2026 09:48:54 +0800 Subject: [PATCH] perf(execution): close readback and no-match projects without resaving --- .../dxdesigner795/QuickPartReplace.vbs | 6 ++- tests/integration/test_quick_value_modes.py | 39 ++++++++++++++++++- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/integration/dxdesigner795/QuickPartReplace.vbs b/integration/dxdesigner795/QuickPartReplace.vbs index d3e0a3f..d3ff8e0 100644 --- a/integration/dxdesigner795/QuickPartReplace.vbs +++ b/integration/dxdesigner795/QuickPartReplace.vbs @@ -909,9 +909,11 @@ Sub QPFinishBatchItem() ValueStates.Item(CStr(Index)).Add "custom_value", QPCustomValue(Command) Next End If - If FinalState = "restored_ok" Or Not QP_SessionMode Then + If FinalState = "restored_ok" Then QPCloseBatchProject TargetPath, True QP_BatchSaveCommitted = True + ElseIf Not QP_SessionMode Then + QPCloseBatchProject TargetPath, False End If If FinalState = "restored_ok" Then QPProgress "verify_saved_project", 0, 1 @@ -927,7 +929,7 @@ Sub QPFinishBatchItem() Plans.Add CStr(Index), Candidate Next QPVerifyRestoredPlans Command, Records, Plans, ValueStates - If Not QP_SessionMode Then QPCloseBatchProject TargetPath, True + If Not QP_SessionMode Then QPCloseBatchProject TargetPath, False FinalState = "saved_ok" If QP_SessionMode Then QP_BatchMessage = QP_BatchMessage & " Saved and reopened for readback; owned project checkpoint verified." diff --git a/tests/integration/test_quick_value_modes.py b/tests/integration/test_quick_value_modes.py index b230cd1..177c9c1 100644 --- a/tests/integration/test_quick_value_modes.py +++ b/tests/integration/test_quick_value_modes.py @@ -77,7 +77,7 @@ Class ValuePin End Class Class ValueApp Public Components, Pins, ProjectPath, UndoCount, PinQueries, TransactionOpen, TransactionCount - Public DocumentCount, CloseCount, SaveCalled, RefuseClose + Public DocumentCount, CloseCount, SaveCalled, SaveCount, RefuseClose Public Function SchematicSheetDocuments() Set SchematicSheetDocuments=Me End Function @@ -90,7 +90,10 @@ Class ValueApp End Function Public Sub Close(ByVal SaveChanges,ByVal FileName) CloseCount=CloseCount+1 - If SaveChanges Then SaveCalled=True + If SaveChanges Then + SaveCalled=True + SaveCount=SaveCount+1 + End If End Sub Public Sub CloseProject() Require CloseCount=1,"project closed before document" @@ -327,6 +330,38 @@ Require SnapshotReads=1,"same boundary parsed its snapshot twice" ''', routines_transform=count_reads) +def test_non_session_batch_saves_once_and_closes_disk_readback_without_saving(tmp_path): + run_vbs(tmp_path, 'part_number', ''' +Dim FullChecks +FullChecks=0 +Command.Add "project_path",QPProjectPath() +QP_BatchMode=True: QP_SessionMode=False +QP_OwnedProject=True: QP_OwnedProjectPath=QPProjectPath() +QPRestoreAfterOperatorReplace Command,SnapshotPath +QPFinishBatchItem +Require QP_App.SaveCount=1,"read-only disk verification saved the project again" +Require Len(QP_App.ProjectPath)=0,"batch did not close the readback project" +Require QP_BatchSaveCommitted,"real replacement save was not recorded" +Require InStr(QPReadUtf8(QP_Fso.BuildPath(QP_Root,"status.tsv")),"saved_ok")>0,"no completion proof" +''', routines_transform=_batch_readback_fixture) + + +def test_non_session_no_match_closes_without_any_save(tmp_path): + run_vbs(tmp_path, 'part_number', ''' +Dim FullChecks +FullChecks=0 +Command.Add "project_path",QPProjectPath() +QP_BatchMode=True: QP_SessionMode=False +QP_OwnedProject=True: QP_OwnedProjectPath=QPProjectPath() +QPCaptureAndSelect Command,SnapshotPath +QPFinishBatchItem +Require Not QP_App.SaveCalled,"no-match project was saved despite no replacement writes" +Require Not QP_BatchSaveCommitted,"no-match was recorded as a save" +Require Len(QP_App.ProjectPath)=0,"no-match owned project did not close" +Require InStr(QPReadUtf8(QP_Fso.BuildPath(QP_Root,"status.tsv")),"no_match")>0,"no-match proof missing" +''', routines_transform=_batch_readback_fixture) + + @pytest.mark.parametrize('mode', ['preserve', 'part_label', 'part_number']) def test_recovery_repairs_attributes_without_native_replace(tmp_path, mode): run_vbs(tmp_path, mode, '''