test: verify native cleanup and fail packaged acceptance on queue errors
This commit is contained in:
1 parent
e2f76c3387
commit
bbf9bffe32
8 files changed
+416
-37
No files matched your search
@@ -0,0 +1,47 @@
|
||||
# Optional Cell release review — 2026-10-19
|
||||
|
||||
## Scope
|
||||
|
||||
- Reviewed commit range `81a8547..d12478e` against the requirement that target Cell is optional.
|
||||
- Read the changed source, documentation, and tests, plus the surrounding command, snapshot, native transaction, restoration, saved-file verification, recovery, and BOM code.
|
||||
- Confirmed the inspected production files match `d12478e`. Unrelated working-tree test harness cleanup was excluded.
|
||||
- No tests, CAD sessions, original CAD/library writes, source edits, or Git mutations were performed. This report is the only review output written.
|
||||
|
||||
## Strengths
|
||||
|
||||
- Native execution treats an absent `L` record as no selection and skips both catalog checks. It retains ordinary native part identity validation and transaction evidence.
|
||||
- VBS treats both an absent command field and an empty command field as no selection. `QPSetTargetCell` and `QPVerifyTargetCell` return before accessing the component in that case. Generic instance restoration is restricted to Comment, Notes, and user attributes, so it does not restore an old Cell Name instance value.
|
||||
- Mixed optional/explicit queues retain their complete original command rows when publishing the current command. Cell values remain part of queue-to-input comparison, including per-row comparisons, so swapping selections invalidates the queue.
|
||||
- Optional snapshots omit `L`; present `L` records still require exactly one nonempty, valid selection. Empty, duplicate, and extra-field records remain errors in the VBS reader and Python selection parser.
|
||||
- Explicit selections retain exact project library/catalog authority, the final catalog check before native submission, partition binding, the explicit instance write and immediate readback, and verification after restoration and saved-file reopening.
|
||||
- Recovery binds queue selection, snapshot hash, project/sheet/rule/source identities, and transaction evidence before launching the worker. Unselected snapshots reject added Cell evidence and skip catalog preflight. Explicit selections retain the original complete catalog comparison and active-library check. Protection is cleared only after correlated recovery success and unchanged original evidence checks.
|
||||
- The default BOM header remains the existing 11 columns, with no Cell column.
|
||||
|
||||
## Issues
|
||||
|
||||
### Critical
|
||||
|
||||
None found.
|
||||
|
||||
### Important
|
||||
|
||||
None found.
|
||||
|
||||
### Minor
|
||||
|
||||
None raised within this release review scope.
|
||||
|
||||
## Validation evidence
|
||||
|
||||
Read the existing XML summaries without executing tests:
|
||||
|
||||
| Evidence | Tests | Failures | Errors | Skipped |
|
||||
| --- | ---: | ---: | ---: | ---: |
|
||||
| `build/optional-cell-green-20261019.xml` | 73 | 0 | 0 | 0 |
|
||||
| `build/release-safety-fixes-20261019.xml` | 109 | 0 | 0 | 0 |
|
||||
|
||||
The reviewed test changes cover optional execution reaching native submission without catalog reads, empty/missing VBS selection no-ops, mixed queue binding, malformed `L` records, rejecting unexpected Cell transaction evidence, and optional recovery preserving protection until worker verification. Existing explicit-selection tests retain authority, write/readback, and catalog-drift checks.
|
||||
|
||||
## Assessment
|
||||
|
||||
**Approved for the reviewed scope.** No Critical or Important findings. The change makes selection optional while preserving explicit-selection authority and verification. This is a static code review supported by the supplied test reports; live CAD behavior was not exercised.
|
||||
@@ -0,0 +1,45 @@
|
||||
# Final acceptance tools review — 2026-10-19
|
||||
|
||||
## Scope and verdict
|
||||
|
||||
Reviewed the current uncommitted `tools/accept_packaged_ui.py`, `tools/probe_packaged_upgrade.py`, and `tests/integration/test_packaged_acceptance_guards.py`. Includes the final exact-entry-key assertion and its two malformed-checkpoint regression cases added during review.
|
||||
|
||||
**Approved for the reviewed tooling scope. No Critical or Important findings; no remaining Minor finding.** This does not approve the still-pending real execution acceptance in the corrected fixture root.
|
||||
|
||||
Review was read-only except for writing this report. No tests, CAD, application/process operations, product edits, or Git mutations were performed.
|
||||
|
||||
## Execution completion checks
|
||||
|
||||
- The driver snapshots existing queue filenames immediately before clicking the execution confirmation. Only newly created queue checkpoints are considered, and their ordered `task_ids` must match the tasks read in execution order.
|
||||
- Durable `failed`, `blocked`, or `skipped` entries now raise an acceptance failure even when the legacy database task status remains `running` or `ready`. The tool neither retries native execution nor rewrites checkpoints.
|
||||
- Success requires exactly one matching new queue, nonempty task states, all database tasks completed, and all queue entries completed. The final `set(entries) == set(queue['task_ids'])` assertion rejects missing, empty, or foreign task entries before completion is evaluated. This addresses the initially identified nonblocking vacuous-completion case.
|
||||
- Old queue failures are excluded using the pre-confirmation filename snapshot. Missing/running checkpoints cannot produce success. The surrounding execute stage still requires real saved/readback events for both tasks and subsequent CAD observation verification.
|
||||
- The product queue writer was inspected for schema/state alignment: it creates entries for every ordered task and persists safe failures as `failed`, unsafe failures as `blocked`. These are the states the new tool consumes.
|
||||
|
||||
## Other retained safeguards
|
||||
|
||||
- CLI BOM resource checks still inspect **all** inventory attempts. Uncertain/incomplete states and cleanup errors are rejected; every recorded workspace, Job/process, descendant-handle, and desktop cleanup record is checked. Successful project coverage is derived only from ready rows. The earlier Important filtering defect remains fixed.
|
||||
- Actual CAD sessions remain required by default for execution/independent-read observation. CLI-only BOM collection uses its separate resource proof.
|
||||
- Read-only BOM continuation still requires the saved functional evidence and exact persisted target rows; it does not repeat imports or mutate plans. Previous failed evidence is retained.
|
||||
- The legacy upgrade probe still verifies the old executable hash, creates/uses the real legacy fixture, backs it up to a separate destination, invokes the frozen candidate smoke migration, and compares task identities and every original rule value using strict rule-count pairing. Migrated Cell selections must be empty and the legacy source database hash unchanged.
|
||||
|
||||
## Evidence inspected
|
||||
|
||||
| Existing report | Tests | Failures | Errors |
|
||||
| --- | ---: | ---: | ---: |
|
||||
| `build/release-cli-resource-verifier-red-20261019.xml` | 4 | 3 | 0 |
|
||||
| `build/release-cli-resource-verifier-green-20261019.xml` | 4 | 0 | 0 |
|
||||
| `build/release-execution-verifier-red-20261019.xml` | 8 | 4 | 0 |
|
||||
| `build/release-execution-verifier-green-20261019.xml` | 8 | 0 | 0 |
|
||||
|
||||
The initial four new execution cases exercise failed/blocked entries with nonfailed database task states, exclusion of an old queue failure, and the requirement for both a current completed checkpoint and completed tasks. The final malformed-checkpoint cases additionally exercise empty and foreign entry keys; their matching source guard was inspected. This reviewer did not rerun any suite.
|
||||
|
||||
`build/packaged-optional-acceptance-20261019/v111-upgrade-report.json` records two preserved tasks, one preserved rule, empty migrated Cell selection, candidate exit code 0, and unchanged legacy source database. Accepting one rule reflects the actual legacy fixture rather than weakening preservation checks.
|
||||
|
||||
## Diagnosis update and limits
|
||||
|
||||
Both prepared v1 project files were read directly and contain `KEY CentralLibrary "S:\mentor_lib.lmc"` at line 28. A read-only existence check of that exact library returned false. The coordinator also reports that direct native row count was zero and both MTA/STA UIA calls returned without exception. Together these support the fixture's missing library binding and provide no evidence that freezing caused the empty DxDataBook.
|
||||
|
||||
The earlier diagnosis report's UIA/apartment/dependency possibilities remain historical hypotheses, not confirmed product defects. The coordinator's STA diagnostic worker pipe saturation/timeout and final `clean=false` are also diagnostic-tool outcomes; they do not establish a product failure. All original failures should remain preserved alongside the corrected v2 acceptance evidence.
|
||||
|
||||
A corrected build-only project/library fixture and a new real execution run are still needed to establish native replacement acceptance. Neither the verifier fixes nor the successful legacy metadata upgrade substitute for that result.
|
||||
@@ -0,0 +1,64 @@
|
||||
# Release test migration review — 2026-10-19
|
||||
|
||||
## Scope and method
|
||||
|
||||
Reviewed the current working-tree migration of `tests/ui`, the VBS harness changes in `tests/v1_1/test_accuracy_vbs_guards.py`, and the execution lease expectation in `tests/trial_task_center/test_permanent_delete.py`. Compared removed assertions with current production behavior and the existing current UI tests named in the review request. Also inspected related query-cancellation, replacement-log, and Value-policy coverage where relevant.
|
||||
|
||||
No tests or CAD were run. No source files or Git state were changed. This report is the only output written for this review.
|
||||
|
||||
## Assessment
|
||||
|
||||
**Approved with one nonblocking coverage recommendation. No Critical or Important findings.** The migration mostly replaces obsolete UI contracts and synchronous assumptions with current project-task behavior. Passing counts alone were not used as evidence of equivalent coverage.
|
||||
|
||||
The review reflects the final current contents, including the retained three-case `test_unresolved_queue_evidence_is_retained_after_task_purge`. An earlier intermediate diff omitted that test; it is present in the reviewed result.
|
||||
|
||||
## Safety and behavior mapping
|
||||
|
||||
| Original intent | Current evidence | Review |
|
||||
| --- | --- | --- |
|
||||
| Confirm before replacement; cancellation dispatches nothing | Migrated workflow parameterizes accept/decline and checks worker calls plus completion | Preserved |
|
||||
| Do not execute a stale Value policy | Migrated workflow tests both Value policy directions and requires zero worker calls; backend Value tests retain expected-item binding | Preserved with the current fail-closed behavior |
|
||||
| A no-match job completes as a skip | Migrated workflow checks queue completion, no-match count, and new-round availability | Preserved |
|
||||
| Mapping enablement changes persisted rules and execution gates | Migrated model-based toggle test checks persistence and disabled execution | Preserved without removed cell widgets |
|
||||
| Navigation and worker ownership are safe | Migrated tests cover mutation navigation lock and execution browsing; current responsiveness tests cover stale task/log results, execution completion after switching, and owner naming | Preserved for supported UI paths |
|
||||
| Closing cannot abandon execution or cleanup | Migrated close test requires boundary pause and ignored close; remediation/lifecycle tests retain cleanup waiting, cancellation, and unsaved-plan protection | Preserved |
|
||||
| Interrupted work offers recovery and cannot be repeated after declining recovery | Migrated shell test retains recovery visibility, disabled execution, unchanged lock, and zero worker calls | Preserved |
|
||||
| Permanent deletion requires explicit confirmation and rechecks state | Migrated recycle tests check default No, decline/accept, and concurrent restore; backend retains confirmation, deleted-state, rollback, evidence-retention, and project-file checks | Preserved |
|
||||
| Permanent deletion cannot overlap execution | Replacement lease test checks `quick_run_busy`, unchanged task/rules while leased, then success after release | Strengthened to match the current service gate |
|
||||
| Readable operator errors and logs | Migrated tests retain reason/error ID and formatting; current responsiveness/replacement-log tests retain task separation, saved-vs-unverified distinctions, and completed-task reopen behavior | Preserved |
|
||||
| Current layout and policy controls remain usable | Migrated tests cover task-local Value policy, custom Value/NC, optional Cell, current splitters/log dialog, and column persistence; workspace tests cover narrow-window plan visibility | Preserved for the current layout |
|
||||
|
||||
## Justified removals
|
||||
|
||||
- Multi-project table selection, scan, filtering, per-project skip/retry, and manual capture controls are absent from the current one-project task shell. Current project-task tests explicitly require several of these old controls to be absent and exercise directory selection and target-plan editing instead.
|
||||
- Backup override controls and `_continue_without_backup` no longer exist in the current UI. Removing tests for their dispatch does not weaken the current UI contract. Backend backup failure and explicit override behavior have separate tests.
|
||||
- Old tests that dispatch overlapping mutation workers to test shared-button generations do not match current `_run_async`, which rejects another mutation while `_workers` is nonempty. Current mutation navigation locking and asynchronous query ownership tests target the supported concurrency model.
|
||||
- Old imports of formatting helpers from `main_window` were moved to their actual owner, `ui.messages`. The formatting assertions remain intact.
|
||||
- The VBS harness changes add the real `QPTargetCell`/`QPDecode` routines now required by the extracted production routines. They do not replace production logic with stubs, relax expectations, add skips, or suppress errors.
|
||||
|
||||
## Findings
|
||||
|
||||
### Critical
|
||||
|
||||
None.
|
||||
|
||||
### Important
|
||||
|
||||
None.
|
||||
|
||||
### Minor — retain a mutation-worker destruction regression when convenient
|
||||
|
||||
The removed `test_worker_completion_does_not_touch_widgets_after_window_destruction` checked forced `deleteLater()` while a mutation worker was blocked. The migrated workflow close test (`tests/ui/test_trial_task_center_workflow.py:63`) covers an ordinary close request that is refused until completion. `test_deleted_receiver_does_not_receive_worker_completion` in the query-cancellation suite protects `LatestQuery`, a different implementation from the main window's `ServiceWorker` callbacks.
|
||||
|
||||
An adapted test using a current control would retain this defensive lifecycle coverage. This is nonblocking because current ordinary close handling explicitly waits for workers; the migration preserves that supported user path. No production failure was executed or claimed during this read-only review.
|
||||
|
||||
## Supplied execution evidence
|
||||
|
||||
Read the XML summaries without running tests:
|
||||
|
||||
| Report | Tests | Failures | Errors | Skipped |
|
||||
| --- | ---: | ---: | ---: | ---: |
|
||||
| `build/release-legacy-ui-initial-20261019.xml` | 47 | 42 | 1 | 0 |
|
||||
| `build/release-ui-migrated-final-20261019.xml` | 23 | 0 | 0 | 0 |
|
||||
|
||||
The initial report is consistent with obsolete controls/imports and asynchronous state assertions. The final 23-test report records a clean migrated UI run. Existing current UI suites were inspected as complementary coverage; their prior release-gate pass status was supplied by the coordinator and was not rerun here.
|
||||
@@ -0,0 +1,28 @@
|
||||
# Window lifecycle fix review — 2026-10-19
|
||||
|
||||
## Scope
|
||||
|
||||
Reviewed the current narrow `main_window.py` diff adding `shiboken6.isValid` guards to `ServiceWorker` callbacks, the parameterized forced-window-destruction regression in `tests/ui/test_trial_task_center_workflow.py`, and the surrounding worker/ordinary-close behavior. No tests, CAD, source edits, or Git mutations were performed; this report is the only output written.
|
||||
|
||||
## Findings
|
||||
|
||||
- **Critical:** None.
|
||||
- **Important:** None.
|
||||
- **Minor:** None raised.
|
||||
|
||||
## Assessment
|
||||
|
||||
**Approved for this narrow lifecycle fix.**
|
||||
|
||||
The successful callback checks C++ object validity before any window/widget work. The failed callback returns before `_finish_run`, error display, or other widget access when the window is destroyed or closed. The finished callback always removes its worker from the Python set, then checks validity before touching the plan panel, close timer, or gates. These guards address each callback path visible in the original deleted-widget failure.
|
||||
|
||||
For live windows, the existing generation/owner checks, error handling, plan cleanup, and pending-close scheduling remain in place. Ordinary close requests still wait for active workers and request cancellation/boundary pause. The change suppresses presentation callbacks after destruction; it does not cancel service work or release execution protection early. Service worker completion still emits its final cleanup signal through `finally`.
|
||||
|
||||
The new test blocks an actual `ServiceWorker`, force-deletes a separate window through Qt deferred deletion, then releases the worker. It covers both success and a raised exception. The primary fixture window remains alive, avoiding the earlier teardown misuse of a deleted fixture window. Qt event-loop exception reporting complements the assertion that the application success callback is not delivered. This restores coverage of the separate mutation-worker path identified during the migration review.
|
||||
|
||||
## Evidence inspected
|
||||
|
||||
- `build/release-ui-destruction-20261019.xml`: 1 failed test and 1 teardown error. The failure contains deleted QLabel access from `succeeded` and deleted QPushButton access from `finished`; the teardown error is separately identifiable as use of the deleted fixture window.
|
||||
- `build/release-ui-lifecycle-final-20261019.xml`: 54 tests, 0 failures, 0 errors, 0 skipped. Includes both `test_destroyed_window_cannot_receive_late_worker_ui_callbacks[False]` and `[True]`.
|
||||
|
||||
These are existing test artifacts inspected read-only, not tests rerun by this reviewer. No live CAD behavior was exercised.
|
||||
@@ -35,4 +35,12 @@
|
||||
|
||||
## 验收进度
|
||||
|
||||
源码修复与相关回归已完成;冻结包、多工程实机、升级及性能结果将在完成后填写。此处尚不宣称正式发布就绪。
|
||||
源码修复与相关回归已完成。最终构建检查 692 passed;UI 生命周期相关 54 passed;队列与恢复相关 122 passed(千步性能单独执行)。这些检查范围存在重叠,不合并计数。
|
||||
|
||||
冻结候选 e2f76c3 的 BOM 实际操作已通过:两工程导出原 11 列模板,错误清单报告通过 2 / 失败 1,修正后报告通过 2 / 失败 0;确认保存后只有 RV05 启用,RV11 保留。两工程原生 CLI 采集与私有桌面清理有独立记录。真实 1.1.1 数据升级保留 2 个任务、1 条规则,未选封装迁移为空,原数据库哈希不变。
|
||||
|
||||
首次冻结替换在 DxDataBook 读取目标行时超时,两份副本均关闭未保存,未提交原生替换。后续只读 MTA/STA 探针未发现 UIA 异常,原生列表计数确为 0。检查发现验收夹具仍引用不存在的 S:\\mentor_lib.lmc,属于副本准备漏重绑定;不能据此认定冻结 UIA 接口失效。保留首次失败及诊断证据,另建 v2 副本并复制独立中央库后重验。STA 诊断脚本还出现大输出阻塞管道而超时,最终 Job 与桌面已释放;此记录不计为产品验收通过。
|
||||
|
||||
验收工具同步补齐:BOM 检查所有 CLI 尝试的资源清理,不能被后续成功记录掩盖;执行阶段读取本次新队列检查点,遇 failed/blocked/skipped 立即失败,不能只等待可能保留 RUNNING 的任务状态。相关反例先失败、修复后 10 passed;未修改产品任务状态语义。
|
||||
|
||||
独立千步模拟为 40.90267 秒,未通过小于 30 秒的原门槛,尚未放宽阈值。冻结多工程替换、保存重开和后续独立核验仍待完成,此处不宣称正式发布就绪。
|
||||
@@ -0,0 +1,89 @@
|
||||
"""A successful inventory retry must not hide leaked resources from an earlier attempt."""
|
||||
import copy
|
||||
import importlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def native_bom_evidence(tmp_path,monkeypatch):
|
||||
monkeypatch.syspath_prepend(str(Path(__file__).resolve().parents[2]/'tools'))
|
||||
verifier=importlib.import_module('accept_packaged_ui')
|
||||
projects=[tmp_path/'A.prj',tmp_path/'B.prj']
|
||||
(tmp_path/'inputs.json').write_text(json.dumps({'projects':[str(p) for p in projects]}))
|
||||
(tmp_path/'desktop-observation-bom.json').write_text(json.dumps(dict(
|
||||
sessions={},observer_errors=[],cad_exit_confirmed={},desktop_absent={},
|
||||
owned_cad_became_foreground=False,owned_cad_on_input_desktop=False,
|
||||
input_desktop_before='Default',input_desktop_after='Default',samples=2,file_read_samples=2)))
|
||||
rows=[]
|
||||
for i,project in enumerate(projects):
|
||||
row=dict(backend='native_cli',project=str(project),state='ready',
|
||||
workspace=str(tmp_path/f'released-{i}'),source_hashes_unchanged=True,
|
||||
cleanup=dict(desktop_handle_closed=True,desktop_confirmation={'released':True},errors=[],
|
||||
processes=[dict(job_active_processes=0,exit_code=0,process_handle_closed=True,
|
||||
job_handle_closed=True,unconfirmed_descendant_handles=0,errors=[])]))
|
||||
path=tmp_path/f'data/tasks/{i}/quick-run-history/native-inventory-ok/native-inventory.json'
|
||||
path.parent.mkdir(parents=True);path.write_text(json.dumps(row));rows.append(row)
|
||||
return verifier,tmp_path,rows
|
||||
|
||||
|
||||
def test_bom_resource_verifier_accepts_cli_only_reads_without_cad(native_bom_evidence):
|
||||
verifier,root,_=native_bom_evidence
|
||||
assert verifier.verify_bom_resources(root)=={'cad_sessions':0,'ready_native_cli_reads':2}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('fault',['uncertain','fallback_active_job','fallback_retained_workspace'])
|
||||
def test_bom_resource_verifier_rejects_bad_earlier_attempt_despite_clean_retries(native_bom_evidence,fault):
|
||||
verifier,root,rows=native_bom_evidence
|
||||
extra=copy.deepcopy(rows[0]);extra['state']='fallback'
|
||||
if fault=='uncertain':
|
||||
extra['state']='uncertain';extra['cleanup_error']='Job did not exit'
|
||||
elif fault=='fallback_active_job':
|
||||
extra['cleanup']['processes'][0]['job_active_processes']=1
|
||||
else:
|
||||
workspace=root/'retained-workspace';workspace.mkdir();extra['workspace']=str(workspace)
|
||||
path=root/'data/tasks/0/quick-run-history/native-inventory-earlier/native-inventory.json'
|
||||
path.parent.mkdir(parents=True);path.write_text(json.dumps(extra))
|
||||
with pytest.raises(AssertionError):verifier.verify_bom_resources(root)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('state',['failed','blocked'])
|
||||
def test_execution_wait_rejects_retryable_failure_even_when_task_status_remains_running(native_bom_evidence,state):
|
||||
verifier,root,_=native_bom_evidence
|
||||
directory=root/'data/task-queues';directory.mkdir()
|
||||
path=directory/'current.json'
|
||||
path.write_text(json.dumps({'task_ids':['a','b'],'entries':{
|
||||
'a':{'state':state,'message':'Native target query timed out'},
|
||||
'b':{'state':'pending','message':''}}}))
|
||||
with pytest.raises(AssertionError,match='do not auto-retry'):
|
||||
verifier.execution_complete(root,[{'task_id':'a','status':'running'},
|
||||
{'task_id':'b','status':'ready'}],set())
|
||||
|
||||
|
||||
def test_execution_wait_ignores_old_queue_failures(native_bom_evidence):
|
||||
verifier,root,_=native_bom_evidence
|
||||
directory=root/'data/task-queues';directory.mkdir()
|
||||
old=directory/'old.json';old.write_text(json.dumps({'task_ids':['a'],'entries':{'a':{'state':'failed'}}}))
|
||||
assert not verifier.execution_complete(root,[{'task_id':'a','status':'running'}],{old})
|
||||
|
||||
|
||||
def test_execution_wait_requires_current_queue_and_tasks_completed(native_bom_evidence):
|
||||
verifier,root,_=native_bom_evidence
|
||||
tasks=[{'task_id':'a','status':'completed'}]
|
||||
assert not verifier.execution_complete(root,tasks,set())
|
||||
directory=root/'data/task-queues';directory.mkdir()
|
||||
path=directory/'current.json'
|
||||
path.write_text(json.dumps({'task_ids':['a'],'entries':{'a':{'state':'running'}}}))
|
||||
assert not verifier.execution_complete(root,tasks,set())
|
||||
path.write_text(json.dumps({'task_ids':['a'],'entries':{'a':{'state':'completed'}}}))
|
||||
assert verifier.execution_complete(root,tasks,set())
|
||||
|
||||
|
||||
@pytest.mark.parametrize('entries',[{}, {'wrong-task':{'state':'completed'}}])
|
||||
def test_execution_wait_rejects_incomplete_checkpoint(native_bom_evidence,entries):
|
||||
verifier,root,_=native_bom_evidence
|
||||
directory=root/'data/task-queues';directory.mkdir()
|
||||
(directory/'current.json').write_text(json.dumps({'task_ids':['a'],'entries':entries}))
|
||||
with pytest.raises(AssertionError,match='Incomplete queue checkpoint'):
|
||||
verifier.execution_complete(root,[{'task_id':'a','status':'completed'}],set())
|
||||
@@ -82,10 +82,11 @@ def verify_disposable_projects(root):
|
||||
assert row['refdes'] == 'RV11' and row['old_value'] == '0R'
|
||||
|
||||
|
||||
def verify_observation(path):
|
||||
def verify_observation(path, *, require_sessions=True):
|
||||
observation = json.loads(path.read_text(encoding='utf-8'))
|
||||
assert not observation['observer_errors'], observation['observer_errors']
|
||||
assert observation['sessions']
|
||||
if require_sessions:
|
||||
assert observation['sessions']
|
||||
assert all(observation['cad_exit_confirmed'].values())
|
||||
assert all(observation['desktop_absent'].values())
|
||||
assert not observation['owned_cad_became_foreground']
|
||||
@@ -94,6 +95,47 @@ def verify_observation(path):
|
||||
assert observation['file_read_samples'] == observation['samples']
|
||||
|
||||
|
||||
def verify_bom_resources(root):
|
||||
path = root / 'desktop-observation-bom.json'
|
||||
verify_observation(path, require_sessions=False)
|
||||
observation = json.loads(path.read_text(encoding='utf-8'))
|
||||
records = [json.loads(path.read_text(encoding='utf-8')) for path in
|
||||
(root / 'data/tasks').glob('*/quick-run-history/native-inventory-*/native-inventory.json')]
|
||||
ready = [row for row in records if row['state'] == 'ready']
|
||||
for row in records:
|
||||
assert row['state'] in {'ready', 'fallback'} and not row.get('cleanup_error')
|
||||
assert row['backend'] == 'native_cli'
|
||||
if row['state'] == 'ready':
|
||||
assert row['source_hashes_unchanged']
|
||||
assert not Path(row['workspace']).exists()
|
||||
cleanup = row['cleanup']
|
||||
assert cleanup['desktop_handle_closed'] and cleanup['desktop_confirmation']['released']
|
||||
assert not cleanup['errors']
|
||||
if row['state'] == 'ready':
|
||||
assert cleanup['processes']
|
||||
for process in cleanup['processes']:
|
||||
assert process['job_active_processes'] == 0 and process['exit_code'] == 0
|
||||
assert process['process_handle_closed'] and process['job_handle_closed']
|
||||
assert not process['unconfirmed_descendant_handles'] and not process['errors']
|
||||
if not observation['sessions']:
|
||||
expected = {Path(p).resolve() for p in json.loads((root/'inputs.json').read_text(encoding='utf-8'))['projects']}
|
||||
assert {Path(row['project']).resolve() for row in ready} == expected
|
||||
return {'cad_sessions': len(observation['sessions']), 'ready_native_cli_reads': len(ready)}
|
||||
|
||||
|
||||
def verify_bom(driver, root, report):
|
||||
"""Read-only continuation after BOM assertions passed but old CAD-only verifier failed."""
|
||||
assert report['template_columns'] == 11 and report['search_preserves_tasks']
|
||||
assert len(report['imports']) == 2
|
||||
assert '通过 2 / 失败 1 / 未检查 0' in report['imports'][0]['title']
|
||||
assert '通过 2 / 失败 0 / 未检查 0' in report['imports'][1]['title']
|
||||
assert report['saved_targets'] == database(root, 'select * from target_plan')
|
||||
assert len(report['saved_targets']) == 4 and sum(row['enabled'] for row in report['saved_targets']) == 2
|
||||
report['bom_resources'] = verify_bom_resources(root)
|
||||
report['bom_passed'] = True
|
||||
report['bom_verifier_continuation'] = 'Native CLI inventory needs no CAD; validated existing CLI Job/desktop cleanup, without repeating import.'
|
||||
|
||||
|
||||
def verified_events(root):
|
||||
records = []
|
||||
for task in database(root, 'select task_id from tasks'):
|
||||
@@ -215,6 +257,27 @@ def bom(driver, root, report):
|
||||
report['search_preserves_tasks'] = True
|
||||
|
||||
|
||||
def execution_complete(root, states, previous_queues):
|
||||
"""Do not mistake a retryable task's RUNNING status for active CAD work."""
|
||||
if any(task['status'] == 'failed' for task in states):
|
||||
raise AssertionError(f'Native execution failed; do not auto-retry: {states}')
|
||||
queues = []
|
||||
for path in (root / 'data/task-queues').glob('*.json'):
|
||||
if path in previous_queues:
|
||||
continue
|
||||
queue = json.loads(path.read_text(encoding='utf-8'))
|
||||
if queue['task_ids'] != [task['task_id'] for task in states]:
|
||||
continue
|
||||
entries = queue['entries']
|
||||
assert set(entries) == set(queue['task_ids']), 'Incomplete queue checkpoint'
|
||||
if any(entry['state'] in {'failed', 'blocked', 'skipped'} for entry in entries.values()):
|
||||
raise AssertionError(f'Native execution failed; do not auto-retry: {entries}')
|
||||
queues.append(queue)
|
||||
return (bool(states) and len(queues) == 1
|
||||
and all(task['status'] == 'completed' for task in states)
|
||||
and all(entry['state'] == 'completed' for entry in queues[0]['entries'].values()))
|
||||
|
||||
|
||||
def execute(driver, root, report):
|
||||
verify_disposable_projects(root)
|
||||
tasks = database(root, 'select * from tasks')
|
||||
@@ -243,20 +306,19 @@ def execute(driver, root, report):
|
||||
except LookupError:
|
||||
pass
|
||||
assert yes is not None, 'Cannot identify native execution confirmation button'
|
||||
previous_queues = set((root / 'data/task-queues').glob('*.json'))
|
||||
started = time.monotonic()
|
||||
driver.click(yes)
|
||||
driver.record('13 后台按工程顺序执行;等待段已压缩', duration=2000)
|
||||
last_status = None
|
||||
def finished():
|
||||
nonlocal last_status
|
||||
states = database(root, 'select name,status,error_id from tasks order by group_position')
|
||||
states = database(root, 'select task_id,name,status,error_id from tasks order by group_position')
|
||||
if states != last_status:
|
||||
print(json.dumps(states, ensure_ascii=False), flush=True)
|
||||
driver.record('执行中:按工程顺序替换、保存并重新打开核验', duration=1000)
|
||||
last_status = states
|
||||
if any(t['status'] == 'failed' for t in states):
|
||||
raise AssertionError(f'Native execution failed; do not auto-retry: {states}')
|
||||
return all(t['status'] == 'completed' for t in states)
|
||||
return execution_complete(root, states, previous_queues)
|
||||
wait(finished, timeout=1800)
|
||||
wait(lambda: driver.find(automation_id='startNewRoundButton').is_enabled(), timeout=20)
|
||||
report['execution_seconds'] = time.monotonic() - started
|
||||
@@ -324,7 +386,7 @@ def new_round(driver, root, report):
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--root', type=Path, required=True)
|
||||
parser.add_argument('--stage', choices=('bom', 'execute', 'details', 'new_round'), required=True)
|
||||
parser.add_argument('--stage', choices=('bom', 'verify_bom', 'execute', 'details', 'new_round'), required=True)
|
||||
parser.add_argument('--run-native', action='store_true')
|
||||
args = parser.parse_args()
|
||||
if not args.run_native:
|
||||
@@ -342,7 +404,10 @@ def main():
|
||||
with PrivateDesktopObserver(root):
|
||||
globals()[args.stage](driver, root, report)
|
||||
(root / f'desktop-observation-{args.stage}.json').write_bytes((root / 'desktop-observation.json').read_bytes())
|
||||
verify_observation(root / f'desktop-observation-{args.stage}.json')
|
||||
if args.stage == 'bom':
|
||||
report['bom_resources'] = verify_bom_resources(root)
|
||||
else:
|
||||
verify_observation(root / f'desktop-observation-{args.stage}.json')
|
||||
else:
|
||||
globals()[args.stage](driver, root, report)
|
||||
report[args.stage + '_passed'] = True
|
||||
|
||||
@@ -15,9 +15,21 @@ from accept_packaged_ui import wait
|
||||
from packaged_window_driver import WindowDriver
|
||||
|
||||
|
||||
def read_tasks(path):
|
||||
with sqlite3.connect(path) as db:
|
||||
return db.execute('select task_id,name from tasks order by task_id').fetchall()
|
||||
|
||||
|
||||
def read_rules(path):
|
||||
with sqlite3.connect(path) as db:
|
||||
db.row_factory = sqlite3.Row
|
||||
return [dict(row) for row in db.execute('select * from rules order by rule_id')]
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--root', type=Path, required=True)
|
||||
parser.add_argument('--resume-created', action='store_true', help='Reuse already-created disposable legacy task/rule fixtures after a driver assertion failed')
|
||||
args = parser.parse_args()
|
||||
root = args.root.resolve(strict=True)
|
||||
repository = Path(__file__).resolve().parents[1]
|
||||
@@ -25,36 +37,53 @@ def main():
|
||||
release = json.loads((repository / 'docs/releases/v1.1.1-build.json').read_text(encoding='utf-8'))
|
||||
assert hashlib.sha256(legacy.read_bytes()).hexdigest() == release['artifacts']['exe_sha256']
|
||||
old_data, new_data = root / 'v111-created-data', root / 'v111-upgraded-copy'
|
||||
old_data.mkdir(exist_ok=False)
|
||||
projects = root / 'upgrade-fixture-projects'
|
||||
for name in ('Legacy-A', 'Legacy-B'):
|
||||
path = projects / name / 'board.prj'
|
||||
path.parent.mkdir(parents=True)
|
||||
path.write_text('KEY FrontEndSnapshot "DxD"\nKEY iCDBDir "database"\n', encoding='utf-8')
|
||||
env = dict(os.environ, TEMP=str(repository / 'build/test-temp-remediation'),
|
||||
TMP=str(repository / 'build/test-temp-remediation'), LOCALAPPDATA=str(root / 'profile'))
|
||||
for key in ('PYTHONPATH', 'PYTHONHOME', 'DX_TASK_CENTER_HOME', 'QT_QPA_PLATFORM'):
|
||||
env.pop(key, None)
|
||||
process = subprocess.Popen([str(legacy), '--data-root', str(old_data)], env=env,
|
||||
creationflags=subprocess.CREATE_NO_WINDOW)
|
||||
driver = WindowDriver(process.pid, root / 'upgrade-recording')
|
||||
window = driver.main()
|
||||
try:
|
||||
driver.click(driver.find(automation_id='newTaskButton'))
|
||||
dialog = wait(lambda: next((w for w in driver.windows() if w.window_text() == '从目录创建工程任务'), None), timeout=15)
|
||||
driver.type_text(driver.find(automation_id='taskDirectory', window=dialog), str(projects))
|
||||
driver.click(driver.find(automation_id='readTaskProjects', window=dialog))
|
||||
create = driver.find('创建任务', kind='Button', window=dialog)
|
||||
wait(create.is_enabled, timeout=20)
|
||||
driver.click(create)
|
||||
def read_tasks(path):
|
||||
with sqlite3.connect(path) as db:
|
||||
return db.execute('select task_id,name from tasks order by task_id').fetchall()
|
||||
original = wait(lambda: (rows if len(rows := read_tasks(old_data / 'task-center.db')) == 2 else None), timeout=20)
|
||||
time.sleep(.5)
|
||||
finally:
|
||||
win32gui.PostMessage(window.handle, win32con.WM_CLOSE, 0, 0)
|
||||
process.wait(timeout=30)
|
||||
if args.resume_created:
|
||||
assert old_data.is_dir() and not new_data.exists()
|
||||
original = read_tasks(old_data / 'task-center.db')
|
||||
old_rules = read_rules(old_data / 'task-center.db')
|
||||
assert len(original) == 2 and old_rules
|
||||
assert all(row['old_part_number'] == 'LEGACY_OLD' and row['new_part_number'] == 'LEGACY_NEW' for row in old_rules)
|
||||
else:
|
||||
old_data.mkdir(exist_ok=False)
|
||||
projects = root / 'upgrade-fixture-projects'
|
||||
for name in ('Legacy-A', 'Legacy-B'):
|
||||
path = projects / name / 'board.prj'
|
||||
path.parent.mkdir(parents=True)
|
||||
path.write_text('KEY FrontEndSnapshot "DxD"\nKEY iCDBDir "database"\n', encoding='utf-8')
|
||||
env = dict(os.environ, TEMP=str(repository / 'build/test-temp-remediation'),
|
||||
TMP=str(repository / 'build/test-temp-remediation'), LOCALAPPDATA=str(root / 'profile'))
|
||||
for key in ('PYTHONPATH', 'PYTHONHOME', 'DX_TASK_CENTER_HOME', 'QT_QPA_PLATFORM'):
|
||||
env.pop(key, None)
|
||||
process = subprocess.Popen([str(legacy), '--data-root', str(old_data)], env=env,
|
||||
creationflags=subprocess.CREATE_NO_WINDOW)
|
||||
driver = WindowDriver(process.pid, root / 'upgrade-recording')
|
||||
window = driver.main()
|
||||
try:
|
||||
driver.click(driver.find(automation_id='newTaskButton'))
|
||||
dialog = wait(lambda: next((w for w in driver.windows() if w.window_text() == '从目录创建工程任务'), None), timeout=15)
|
||||
driver.type_text(driver.find(automation_id='taskDirectory', window=dialog), str(projects))
|
||||
driver.click(driver.find(automation_id='readTaskProjects', window=dialog))
|
||||
create = driver.find('创建任务', kind='Button', window=dialog)
|
||||
wait(create.is_enabled, timeout=20)
|
||||
driver.click(create)
|
||||
original = wait(lambda: (rows if len(rows := read_tasks(old_data / 'task-center.db')) == 2 else None), timeout=20)
|
||||
add_rule = wait(lambda: (button if (button := driver.find(automation_id='addMappingButton')).is_enabled() else None), timeout=20)
|
||||
driver.click(add_rule)
|
||||
rule_dialog = wait(lambda: next((w for w in driver.windows() if w.window_text() == '替换规则'), None), timeout=15)
|
||||
fields = sorted(rule_dialog.descendants(control_type='Edit'), key=lambda field: field.rectangle().top)
|
||||
assert len(fields) >= 2
|
||||
driver.type_text(fields[0], 'LEGACY_OLD')
|
||||
driver.type_text(fields[1], 'LEGACY_NEW')
|
||||
driver.click(driver.find('确定', kind='Button', window=rule_dialog))
|
||||
old_rules = wait(lambda: (rows if len(rows := read_rules(old_data / 'task-center.db')) >= 1 else None), timeout=20)
|
||||
assert all(row['old_part_number'] == 'LEGACY_OLD' and row['new_part_number'] == 'LEGACY_NEW' for row in old_rules)
|
||||
finally:
|
||||
win32gui.PostMessage(window.handle, win32con.WM_CLOSE, 0, 0)
|
||||
process.wait(timeout=30)
|
||||
before = hashlib.sha256((old_data / 'task-center.db').read_bytes()).hexdigest()
|
||||
new_data.mkdir()
|
||||
with sqlite3.connect((old_data / 'task-center.db').as_uri() + '?mode=ro', uri=True) as src, sqlite3.connect(new_data / 'task-center.db') as dst:
|
||||
@@ -66,8 +95,12 @@ def main():
|
||||
report = dict(legacy_version='1.1.1', task_count=len(original), candidate_exit_code=result.returncode,
|
||||
task_identities_preserved=read_tasks(new_data / 'task-center.db') == original,
|
||||
legacy_source_unchanged=hashlib.sha256((old_data / 'task-center.db').read_bytes()).hexdigest() == before,
|
||||
fixture_is_metadata_only=True, cad_launched=False)
|
||||
assert result.returncode == 0 and report['task_identities_preserved'] and report['legacy_source_unchanged'], report
|
||||
fixture_is_metadata_only=True, cad_launched=False,
|
||||
rules_preserved=all(all(row[key] == before_value for key, before_value in old.items())
|
||||
for old, row in zip(old_rules, read_rules(new_data / 'task-center.db'), strict=True)),
|
||||
unselected_cells_migrated=all(row['target_cell'] == '' for row in read_rules(new_data / 'task-center.db')),
|
||||
rule_count=len(old_rules))
|
||||
assert result.returncode == 0 and report['task_identities_preserved'] and report['legacy_source_unchanged'] and report['rules_preserved'] and report['unselected_cells_migrated'], report
|
||||
(root / 'v111-upgrade-report.json').write_text(json.dumps(report, ensure_ascii=False, indent=2), encoding='utf-8')
|
||||
print(json.dumps(report, ensure_ascii=False, indent=2))
|
||||
|
||||
|
||||
Reference in new issue
Block a user