Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b7h4ZNF4BDUpJk3Zou
34 lines
2.1 KiB
Python
34 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Reduce a Maven run to the lines that carry evidence: test results, assertion messages, pact verification
|
|
output. Removes launcher noise, Spring Boot banners and startup logs, WireMock request dumps and stack frames.
|
|
Usage: clean.py ROOT < raw > clean"""
|
|
import re, sys
|
|
|
|
root = sys.argv[1]
|
|
drop = re.compile(r"""^(
|
|
Picked\ up|WARNING:|OpenJDK\ 64-Bit|Mockito\ is\ currently|\[INFO\]\ (---|Scanning|Replacing|The\ original|Building|\ \ from|Deleting|Recompiling|Compiling|
|
|
skip|Will\ use|Directory\ with|Test\ Source|Using\ \[|Creating\ new|Generated|Converting|\ \ \ \ \ Spring|Stub\ Server|Files\ matching|
|
|
Total\ time|Finished|Results|Using\ auto|\ T\ E\ S\ T\ S|-----|Generating|Installing|Building\ jar|Copying|Nothing|Download)|
|
|
\d{4}-\d\d-\d\dT|\d\d:\d\d:\d\d\.\d+\ \[main\]|\s+at\ |\s+\.\.\.\ \d+\ more|
|
|
\s*\.\ \ \ ____|\s*/\\\\|\s*\(\ \(|\s*\\\\/|\s*'\ \ \||\s*=====|\ ::\ Spring\ Boot|
|
|
\s*Please\ note:|\s*and\ operating|\s*variable\ to|\[ERROR\]\s*$|\[INFO\]\s*$|\[ERROR\]\ (For\ more|Re-run|To\ see|Failed\ to\ execute|->\ \[Help|\[Help|See\ |Please\ read)|
|
|
Nov\ \d+,|org\.junit\.jupiter\.engine|OpenJDK|Found\ multiple|You\ may\ wish|\s+(jar:file|Content-Type|Host:|Content-Length|Connection|User-Agent)
|
|
)""", re.X)
|
|
|
|
out, skip_block = [], False
|
|
for line in sys.stdin:
|
|
line = line.rstrip("\n")
|
|
line = line.replace(root, "<repo>/contracts").replace("/root/.m2", "~/.m2")
|
|
line = re.sub(r"Time elapsed: [0-9.]+ s", "Time elapsed: N s", line)
|
|
# WireMock request/response dumps print between "127.0.0.1 - <verb>" / "Request received:" and the next test line
|
|
if re.match(r"^(127\.0\.0\.1 - |Request received:|Matched response definition:|Response:|-{10,}$)", line):
|
|
skip_block = True
|
|
if line.startswith("[INFO] Running") or line.startswith("[INFO] Tests run") or line.startswith("[ERROR] Tests run") or line.startswith("[INFO] BUILD") or line.startswith("[ERROR] Failures") or line.startswith("[ERROR] Errors"):
|
|
skip_block = False
|
|
if skip_block or drop.match(line):
|
|
continue
|
|
out.append(line)
|
|
text = "\n".join(out)
|
|
text = re.sub(r"\n{3,}", "\n\n", text).strip("\n")
|
|
print(text)
|