# -*- coding: utf-8 -*- """票 06:驱动 t06-test.cmd(Python subprocess 模式,规避 shell 摇摆)。""" import io, subprocess, sys sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') p = subprocess.run(['cmd', '/c', r'e:\code\crm-backend-matt\.scratch\opportunity-bugfix\t06-test.cmd'], capture_output=True, text=True, errors='replace', timeout=1500) out = (p.stdout or '') + (p.stderr or '') # 摘取结果行 for line in out.splitlines(): if any(k in line for k in ('Tests run:', 'BUILD SUCCESS', 'BUILD FAILURE', 'EXIT=', 'ERROR', 'STEP')): print(line) print('---- tail ----') print('\n'.join(out.splitlines()[-12:]))