"""回归汇总 + BOM 扫描(无敏感信息;在 repo 根目录执行)。 用法:python .scratch/customer-module/tools/regress_check.py 依赖:三模块已跑过 mvn test(surefire-reports 就位)。 """ import re import glob # 1) BOM scan: all crm-* module java sources bom_files = [] total = 0 for p in glob.glob('crm-*/src/**/*.java', recursive=True): total += 1 with open(p, 'rb') as fh: if fh.read(3) == b'\xef\xbb\xbf': bom_files.append(p) print(f'BOM-SCAN: scanned={total} bom_hits={len(bom_files)}') for b in bom_files[:20]: print(' BOM:', b) # 2) surefire aggregate for the 3 regression modules t = f = e = n = 0 for mod in ('crm-rule', 'crm-customer', 'crm-opportunity'): files = glob.glob(f'{mod}/target/surefire-reports/*.txt') for p in files: s = open(p, encoding='utf-8', errors='ignore').read() m = re.search(r'Tests run: (\d+), Failures: (\d+), Errors: (\d+)', s) if m: t += int(m.group(1)); f += int(m.group(2)); e += int(m.group(3)); n += 1 print(f'SUREFIRE modules=3 classes={n} Tests={t} Failures={f} Errors={e}')