| 1 |
#!/usr/bin/env python3 |
| 2 |
""" |
| 3 |
Given a log from running tests using pytest -n 2 (or more) see which tests actually |
| 4 |
never completed |
| 5 |
""" |
| 6 |
|
| 7 |
import re |
| 8 |
import sys |
| 9 |
from pathlib import Path |
| 10 |
|
| 11 |
logfile = Path(sys.argv[-1]) |
| 12 |
print(f"Working on {logfile}") |
| 13 |
|
| 14 |
lines = logfile.read_text().splitlines() |
| 15 |
lines = [l.strip() for l in lines] |
| 16 |
test_line = re.compile('datalad/.*tests/') |
| 17 |
|
| 18 |
test_regex = r'\s+(\.\./)?(?P<test>[a-z].*tests/test_\S+)' |
| 19 |
tests_started = set() |
| 20 |
for l in lines: |
| 21 |
# Lines might differ between CI backends - some times prepended with extra time stamp |
| 22 |
if res := re.match('(\[[0-9]{2}:[0-9]{2}:[0-9]{2}\])?' + test_regex, l): |
| 23 |
tests_started.add(res.groupdict()['test']) |
| 24 |
tests_completed = set() |
| 25 |
for l in lines: |
| 26 |
if res := re.match('(\[[0-9]{2}:[0-9]{2}:[0-9]{2}\])?\s+\[gw[0-9]+\].*' + test_regex, l): |
| 27 |
tests_completed.add(res.groupdict()['test']) |
| 28 |
tests_didnot_complete = tests_started - tests_completed |
| 29 |
|
| 30 |
# print(tests_completed) |
| 31 |
print(f"{len(lines)} lines: {len(tests_started)} started, {len(tests_completed)} completed") |
| 32 |
if tests_didnot_complete: |
| 33 |
print("Never completed:") |
| 34 |
for t in sorted(tests_didnot_complete): |
| 35 |
print(t) |