from pathlib import Path from unittest import mock import json import pytest from tools import fw_cli @pytest.mark.parametrize('target,unit_code,rtl_code,expected',[ ('6400',0,0,0),('6400',0,7,7),('all',5,0,5),('all',0,7,7)]) def test_current_regression_routes_and_retains_failures(tmp_path,target,unit_code,rtl_code,expected): calls=[] def process(command,**kwargs): calls.append(command) xml=Path(next(x.split('=',1)[1] for x in command if x.startswith('--junitxml='))) xml.write_text(f'') fake=mock.Mock();fake.wait.return_value=unit_code;return fake with mock.patch.object(fw_cli.sys,'platform','linux'),mock.patch.object(fw_cli,'_generate_one'),\ mock.patch.object(fw_cli,'source_identity',return_value={'source_kind':'fixture'}),\ mock.patch.object(fw_cli.subprocess,'Popen',side_effect=process),\ mock.patch.object(fw_cli,'cmd_diagnose',return_value=rtl_code) as rtl: assert fw_cli.main(['test',target,'--run-root',str(tmp_path/'run')])==expected assert '-m' in calls[0] and 'pytest' in calls[0] assert not any('run_6400_v1.py' in x or 'run_verification_matrix.py' in x for x in calls[0]) assert rtl.call_args.args[0].target==('all' if target=='all' else '6400-front-rear') report=json.loads((tmp_path/'run/RESULT.json').read_text()) assert report['status']==('PASS' if expected==0 else 'FAIL') assert report['complete'] is True