forge
Explore
Log in

Don't you dare go Hollow

edith_codecs

Clone
★ 0

0 watching0 forksRust370.3 MiB9b67700Tahinli3 days ago4021 commits

killed.py23 lines, 1.0 KiBHistoryRawDownload
1# Usage: killed.py <mutants.out dir> ; prints JSON {mutant_name: {"outcome": ..., "fails": [tests]}}
2# Reads mutants.out/outcomes.json (cargo-mutants) and mutants.out/log/*.log (nextest FAIL lines).
3import json, os, re, sys
4d = sys.argv[1]
5res = {}
6oc = json.load(open(os.path.join(d, 'outcomes.json')))
7for o in oc.get('outcomes', []):
8 s = o.get('scenario')
9 if not isinstance(s, dict) or 'Mutant' not in s:
10 continue
11 name = s['Mutant'].get('name')
12 res[name] = {'outcome': o.get('summary'), 'fails': []}
13fail_re = re.compile(r'FAIL \[[^\]]*\]\s+(\S+)\s+(\S+)')
14logdir = os.path.join(d, 'log')
15for f in os.listdir(logdir) if os.path.isdir(logdir) else []:
16 txt = open(os.path.join(logdir, f), errors='replace').read()
17 fails = set(m.group(2) for m in fail_re.finditer(txt))
18 # mutant name is recorded in the log's first line
19 first = txt.split('\n', 1)[0]
20 for name in res:
21 if name in first or name.replace(' ', '') in first.replace(' ', ''):
22 res[name]['fails'] = sorted(fails)
23print(json.dumps(res, indent=1))