# -*- coding: utf-8 -*- """票 11 回归:三模块 surefire 报告逐类计数(陷阱 17 判定法:时间戳 + 计数)。""" import glob, os, re, datetime mods = ['crm-rule', 'crm-customer', 'crm-opportunity'] grand = [0, 0, 0] for m in mods: files = glob.glob(rf'D:/code/crm-backend-matt/{m}/target/surefire-reports/*.txt') t = f = e = 0 newest = 0 n = 0 for fp in files: txt = open(fp, encoding='utf-8', errors='replace').read() mo = re.search(r'Tests run: (\d+), Failures: (\d+), Errors: (\d+)', txt) if mo: t += int(mo.group(1)) f += int(mo.group(2)) e += int(mo.group(3)) newest = max(newest, os.path.getmtime(fp)) n += 1 ts = datetime.datetime.fromtimestamp(newest).strftime('%H:%M:%S') if newest else 'N/A' print(f'{m}: files={n} tests={t} failures={f} errors={e} newest={ts}') grand[0] += t grand[1] += f grand[2] += e print(f'TOTAL: {grand[0]}/{grand[1]}/{grand[2]}')