fix: address independent verification review findings
Core regression / Python core, intervention UI and release configuration (push) Successful in 12m44s
Core regression / JavaScript syntax (push) Successful in 10s
Core regression / Python core, intervention UI and release configuration (pull_request) Failing after 24m33s
Core regression / JavaScript syntax (pull_request) Successful in 10s
Core regression / Python core, intervention UI and release configuration (push) Successful in 12m44s
Core regression / JavaScript syntax (push) Successful in 10s
Core regression / Python core, intervention UI and release configuration (pull_request) Failing after 24m33s
Core regression / JavaScript syntax (pull_request) Successful in 10s
This commit is contained in:
1 parent
7597e98eef
commit
b2a84404d8
18 files changed
+514
-97
No files matched your search
@@ -192,10 +192,11 @@ def test_legacy_rule_retry_cannot_create_a_replacement_before_baseline(rule_run)
|
||||
assert receipt['execution_status'] == 'completed' and receipt['acceptance']['status'] == 'unavailable'
|
||||
|
||||
|
||||
def test_retry_receipt_refresh_preserves_other_task_without_dispatch(tmp_path, monkeypatch):
|
||||
def test_retry_receipt_refresh_preserves_other_task_without_dispatch(tmp_path, monkeypatch, request):
|
||||
from types import SimpleNamespace as NS
|
||||
from dx_productivity.dsh.execution_runs import execute_incident_retry
|
||||
from dx_productivity.dsh.execution_runs import _finish_execution_run, execute_incident_retry
|
||||
from dx_productivity.trial_task_center import netlist_verification, task_queue
|
||||
from dx_productivity.trial_task_center.verification.service import VerificationService
|
||||
selected, other, run_id = 'a' * 32, 'b' * 32, 'c' * 32
|
||||
hashes = {selected: 'd' * 64, other: 'e' * 64}
|
||||
monkeypatch.setattr(task_queue, '_plan_hash', lambda child, key: hashes[key])
|
||||
@@ -206,22 +207,32 @@ def test_retry_receipt_refresh_preserves_other_task_without_dispatch(tmp_path, m
|
||||
def execute(key, **options):
|
||||
dispatch.append(key)
|
||||
return NS(paused=False)
|
||||
service = NS(for_project_task=lambda key: service, task_context=context, execute_quick_run_queue=execute)
|
||||
store = TaskStore(tmp_path / 'tasks.db')
|
||||
request.addfinalizer(store.close)
|
||||
verification_service = VerificationService(store, tmp_path)
|
||||
service = NS(for_project_task=lambda key: service, task_context=context, execute_quick_run_queue=execute,
|
||||
verification=verification_service)
|
||||
class Checks:
|
||||
def __init__(self, *args): self.tasks = {}
|
||||
def __enter__(self): return self
|
||||
def __exit__(self, *args): pass
|
||||
def before_task(self, child, key, *, existing_only): assert existing_only
|
||||
def after_task(self, key, **options): assert key == selected
|
||||
def finish(self): return {selected: {'status': 'verified', 'verified': True, 'report_path': 'new.json'}}
|
||||
def finish(self):
|
||||
return {selected: {'status': 'verified', 'verified': True, 'report_path': 'new.json',
|
||||
'execution': {'state': 'completed', 'saved_items': 1}}}
|
||||
monkeypatch.setattr(netlist_verification, 'NetlistVerification', Checks)
|
||||
journal = RunJournal(tmp_path)
|
||||
journal.begin(run_id, [selected, other], hashes)
|
||||
old_other = {'task_id': other, 'state': 'completed', 'message': 'original saved result'}
|
||||
old_report = {'status': 'verified', 'verified': True, 'report_path': 'original.json'}
|
||||
journal.finish(run_id, {'status': 'failed', 'entries': [
|
||||
{'task_id': selected, 'state': 'failed', 'message': 'safe failure'}, old_other],
|
||||
'netlist_verification': {other: old_report}})
|
||||
old_report = {'status': 'verified', 'verified': True, 'report_path': 'original.json',
|
||||
'execution': {'state': 'completed', 'saved_items': 1}}
|
||||
initial = task_queue.TaskQueueResult(run_id, (
|
||||
task_queue.TaskQueueEntry(selected, 'failed', 'safe failure'),
|
||||
task_queue.TaskQueueEntry(**old_other)), False, netlist_verification={other: old_report})
|
||||
_finish_execution_run(service, tmp_path, [selected, other], Event(), run_id, initial, baseline={})
|
||||
verification_task = verification_service.list_tasks()['tasks'][0]['task_id']
|
||||
assert verification_service.read_task(verification_task)['summary']['total'] == 1
|
||||
checkpoint = tmp_path / 'task-queues' / (run_id + '.json')
|
||||
checkpoint.parent.mkdir()
|
||||
checkpoint.write_text(json.dumps({'version': 1, 'phase': 'finished', 'task_ids': [selected, other],
|
||||
@@ -234,6 +245,7 @@ def test_retry_receipt_refresh_preserves_other_task_without_dispatch(tmp_path, m
|
||||
assert next(row for row in receipt['entries'] if row['task_id'] == other) == old_other
|
||||
assert receipt['netlist_verification'][other] == old_report
|
||||
assert json.loads(checkpoint.read_text())['entries'][other] == {'state': 'completed', 'message': 'original saved result'}
|
||||
assert {row['item_key'] for row in verification_service.read_task(verification_task)['items']} == {selected, other}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('scheduled', [False, True])
|
||||
|
||||
@@ -62,3 +62,20 @@ def test_engineering_pages_remain_bounded_and_keep_the_current_page(ui,qtbot):
|
||||
page.search.setText('Board000')
|
||||
qtbot.waitUntil(lambda:page.table.rowCount()==1)
|
||||
assert page.table.item(0,0).text()=='Board000'
|
||||
|
||||
|
||||
def test_older_verification_task_can_be_opened_after_paging(ui,qtbot):
|
||||
page=ui.window.verification_panel
|
||||
tasks=[page.service.create_task(f'任务 {n}',request_id=f'page-{n}')['task_id'] for n in range(51)]
|
||||
page.open_task(tasks[-1])
|
||||
qtbot.waitUntil(lambda:page.tasks.count()==50 and not page.controller.tasks_query.busy)
|
||||
page.next_tasks_button.click()
|
||||
qtbot.waitUntil(lambda:page.tasks.count()==1)
|
||||
assert page.tasks.item(0).data(Qt.ItemDataRole.UserRole)==tasks[0]
|
||||
page.tasks.setCurrentRow(0)
|
||||
qtbot.waitUntil(lambda:page.controller.task_id==tasks[0] and not page.controller.tasks_query.busy)
|
||||
page.refresh()
|
||||
qtbot.waitUntil(lambda:not page.controller.tasks_query.busy)
|
||||
assert page.tasks.currentItem().data(Qt.ItemDataRole.UserRole)==tasks[0]
|
||||
page.previous_tasks_button.click()
|
||||
qtbot.waitUntil(lambda:page.tasks.count()==50)
|
||||
@@ -108,3 +108,81 @@ def test_import_evidence_validation_does_not_hold_store_lock(service,tmp_path,mo
|
||||
try:assert created.wait(.5)
|
||||
finally:release.set();worker.join(5);creator.join(5)
|
||||
assert not errors
|
||||
|
||||
|
||||
@pytest.mark.parametrize('failure',['cancel','invalid_name','second_capture'])
|
||||
def test_unsuccessful_import_does_not_leave_unreferenced_captures(service,tmp_path,monkeypatch,failure):
|
||||
folders=[tmp_path/phase for phase in ('before','after')]
|
||||
for folder in folders:
|
||||
folder.mkdir()
|
||||
before,after=map(project_fixture,folders)
|
||||
task=service.create_task('导入',request_id='task')['task_id']
|
||||
stop=Event()
|
||||
from dx_productivity.trial_task_center import native_netlist
|
||||
capture=native_netlist.capture_project
|
||||
|
||||
def interrupt(project,destination):
|
||||
result=capture(project,destination)
|
||||
if failure=='cancel':
|
||||
stop.set()
|
||||
if failure=='second_capture' and project==after:
|
||||
raise OSError('after capture failed before publication')
|
||||
return result
|
||||
|
||||
monkeypatch.setattr(native_netlist,'capture_project',interrupt)
|
||||
if failure=='invalid_name':
|
||||
result=service.import_pair(task,before,after,request_id='pair',stop_event=stop,display_name='x'*257)
|
||||
assert result['rejected'] and not result['accepted']
|
||||
else:
|
||||
with pytest.raises(TaskCenterError if failure=='cancel' else OSError):
|
||||
service.import_pair(task,before,after,request_id='pair',stop_event=stop)
|
||||
assert service.read_task(task)['items']==[]
|
||||
assert not list(service.artifacts.root.glob('*'))
|
||||
|
||||
|
||||
@pytest.mark.parametrize('initial',['ready','missing_evidence','fallback'])
|
||||
def test_handoff_updates_same_project_and_never_replays_an_old_notification(service,tmp_path,initial):
|
||||
from dx_productivity.trial_task_center.native_netlist import capture_project, _hash
|
||||
evidence={}
|
||||
for phase in ('before','after','retry'):
|
||||
source=tmp_path/phase
|
||||
source.mkdir()
|
||||
project=project_fixture(source)
|
||||
if phase=='retry':
|
||||
(project.parent/'database/icdb.dat').write_bytes(b'after retry')
|
||||
capture=capture_project(project,service.data_root/phase/'capture')
|
||||
path=service.data_root/phase/'export.json'
|
||||
path.write_text(json.dumps({'capture':capture}),encoding='utf-8')
|
||||
evidence[phase]={'export_path':str(path),'export_sha256':_hash(path)}
|
||||
report={'project_path':'board.prj','execution':{'state':'completed','saved_items':1}}
|
||||
if initial=='ready':
|
||||
report.update(before=evidence['before'],after=evidence['after'],expected_changes={})
|
||||
first_receipt={'run_id':'run','netlist_verification':{'board':report}}
|
||||
if initial=='fallback':
|
||||
first_receipt={'run_id':'run','tasks':[{'task_id':'board','name':'Board task',
|
||||
'state':'completed','saved_items':1}]}
|
||||
first=service.receive_successful_results(first_receipt,submission_id='initial')
|
||||
item=first['accepted'][0]['item_id']
|
||||
retry_report=dict(report,before=evidence['before'],after=evidence['retry'],
|
||||
expected_changes={'u1':{'Value':'NEW'}},execution={'state':'completed','saved_items':2})
|
||||
retry_receipt=dict(first_receipt,netlist_verification={'board':retry_report})
|
||||
if initial=='ready':
|
||||
with service.repo.store.transaction():
|
||||
service.repo._remember('handoff','retry',retry_receipt,
|
||||
{'accepted':[],'rejected':[{'code':'verification_conflict'}]})
|
||||
second=service.receive_successful_results(retry_receipt,submission_id='retry')
|
||||
assert second['accepted']==[{'item_id':item,'input_version':2}]
|
||||
original=service.read_item(item,version=1)['payload']
|
||||
current=service.read_item(item)['payload']
|
||||
if initial=='ready':
|
||||
assert current['before_ref']==original['before_ref']
|
||||
assert current['after_ref']!=original['after_ref']
|
||||
assert current['input_state']=='ready'
|
||||
assert service.receive_successful_results(retry_receipt,submission_id='checkpoint')['duplicates']==second['accepted']
|
||||
service.receive_successful_results(first_receipt,submission_id='late-checkpoint')
|
||||
assert service.read_item(item)['versions']==[2,1]
|
||||
updated_report=dict(retry_report,expected_changes={'u1':{'Value':'NEWER'}})
|
||||
updated_receipt=dict(first_receipt,netlist_verification={'board':updated_report})
|
||||
third=service.receive_successful_results(updated_receipt,submission_id='latest')
|
||||
assert third['accepted']==[{'item_id':item,'input_version':3}]
|
||||
assert service.read_item(item)['payload']['before_ref']==current['before_ref']
|
||||
@@ -78,6 +78,15 @@ def test_missing_required_mapping_never_passes_and_duplicate_ref_is_unknown():
|
||||
assert evaluate(a,b)['verdict']=='INCOMPLETE'
|
||||
|
||||
|
||||
def test_empty_native_networks_cannot_prove_coverage():
|
||||
value=export()
|
||||
value['graph']['nets']=[]
|
||||
for component in value['graph']['components'].values():
|
||||
for pin in component['pins'].values():
|
||||
pin['nets']=[]
|
||||
assert evaluate(value,value)['verdict']=='INCOMPLETE'
|
||||
|
||||
|
||||
def test_missing_pin_number_cannot_prove_equal_and_error_beats_unknown():
|
||||
a=export();b=copy.deepcopy(a);b['graph']['components']['a']['pins']['loop']['number']=''
|
||||
assert evaluate(a,b)['verdict']=='INCOMPLETE'
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import time
|
||||
from threading import Event
|
||||
import pytest
|
||||
from dx_productivity.trial_task_center.errors import TaskCenterError
|
||||
from test_independent_verification_intake import service
|
||||
from test_independent_verification_runner import imported
|
||||
from test_native_cli_netlist import graph
|
||||
@@ -25,7 +27,13 @@ def test_start_idempotency_and_frozen_members_do_not_swallow_new_version(service
|
||||
payload=service.repo.revision(item,1)['payload']
|
||||
newer={k:v for k,v in payload.items() if k not in {'input_state','payload_digest'}};newer['input_version']=2
|
||||
service.publish_inputs(task,(newer,),submission_id='new')
|
||||
release.set();wait_idle(service)
|
||||
try:
|
||||
assert service.start(task,selection=((item,1),),request_id='same-member')==first
|
||||
with pytest.raises(TaskCenterError,match='当前校验'):
|
||||
service.rerun(item,2,request_id='start-new-version')
|
||||
finally:
|
||||
release.set()
|
||||
wait_idle(service)
|
||||
assert len(calls)==2 and service.read_item(item)['status']=='waiting'
|
||||
assert service.read_item(item,version=1)['status']=='consistent'
|
||||
|
||||
|
||||
@@ -30,6 +30,46 @@ def test_task_export_is_immutable_and_incomplete_items_are_explicit(service,tmp_
|
||||
assert (output/'index.html').is_file()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('change,label',[('rename','网名变化'),('add','器件新增'),('remove','器件删除')])
|
||||
def test_historical_pin_evidence_reports_the_detected_change(tmp_path,change,label):
|
||||
from dx_productivity.trial_task_center.verification.report import render_item_report
|
||||
from dx_productivity.trial_task_center.verification.evidence import build_evidence
|
||||
a,b=export(),export()
|
||||
if change=='rename':
|
||||
b['graph']['nets'][0]['name']='RENAMED'
|
||||
for uid,pin in [('a','loop'),('b','out')]:
|
||||
b['graph']['components'][uid]['pins'][pin]['nets']=['RENAMED']
|
||||
else:
|
||||
graph=(b if change=='add' else a)['graph']
|
||||
graph['components']['isolated']={'refdes':'R99','attributes':{'Part Number':'PART'},
|
||||
'pins':{'open':{'number':'1','nets':[]}}}
|
||||
result=evaluate(a,b)
|
||||
result['evidence']=build_evidence(a['graph'],b['graph'],result['issues'],binding={})
|
||||
path=render_item_report(result,tmp_path/'report.html')
|
||||
html=path.read_text(encoding='utf-8')
|
||||
assert result['verdict']=='DIFFERENT'
|
||||
assert f'<td>{label}</td>' in html and '#b83d4a' in html.split('<svg',1)[1]
|
||||
|
||||
|
||||
def test_report_filename_limit_does_not_depend_on_destination_name(tmp_path):
|
||||
from dx_productivity.trial_task_center.verification.report import render_item_report
|
||||
path=tmp_path/('r'*235+'.html')
|
||||
assert render_item_report({},path)==path
|
||||
assert path.read_text(encoding='utf-8').startswith('<!doctype html>')
|
||||
assert list(tmp_path.iterdir())==[path]
|
||||
|
||||
|
||||
def test_task_report_can_be_written_beyond_windows_legacy_path_limit(service,tmp_path):
|
||||
from dx_productivity.trial_task_center.path_access import internal_path
|
||||
task=service.create_task('报告',request_id='task')['task_id']
|
||||
destination=tmp_path
|
||||
while len(str(destination))<270:
|
||||
destination=destination/('report-folder-'+'a'*30)
|
||||
output=service.export_task(task,destination,request_id='export')
|
||||
assert internal_path(output/'index.html').is_file()
|
||||
assert service.export_task(task,destination,request_id='export')==output
|
||||
|
||||
|
||||
def test_corrupt_evidence_cannot_remain_green_or_export(service,tmp_path,monkeypatch):
|
||||
from test_native_cli_netlist import graph
|
||||
from dx_productivity.trial_task_center import netlist_verification
|
||||
|
||||
Reference in new issue
Block a user