* worker.rs (1271 lines, 1120 of them tests) is 149 lines; the supervisor tests are worker/tests.rs (shared fixtures) and
worker/tests/{deadlines,handshake,generation,restart,lifecycle,reasoning}.rs. The test names are unchanged; their path
gains the topic module (worker::tests::restart::..., see scripts/dev/test-outcomes.py compare: 23 MOVED, outcomes equal).
* vision.rs 402 -> 120 lines (tests are vision/tests.rs, same test ids); prometheus.rs 441 -> 50 (the series table is
prometheus/series.rs); service_install.rs 436 -> 30 (the unix half is service_install/unix.rs and unix/tests.rs, same ids).
* config: Config::load_with_path (430 lines in one function) hands its limits, engine-worker and MCP sections to
config/methods/load_sections.rs; the same checks run in the same order with the same messages.
* mcp, request_log, vision, worker, config: impl_*/note_*/check_* file names are now hub.rs, server.rs, stdio_transport.rs,
http_transport.rs, parse_config.rs, obs_handle.rs, engine_counters.rs, encoder.rs, cleanup.rs, generation_result.rs, ...
Public paths are unchanged (the modules re-export with glob as before).
Architecture gate: five oversize entries leave the baseline (worker.rs, vision.rs, prometheus.rs, service_install.rs,
config impl_config_2_2.rs); no number rose.
93 lines
4.4 KiB
Python
93 lines
4.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Per-test outcomes from a `cargo test` log, and a comparison of two logs (STRA-338 gateway track).
|
|
|
|
test-outcomes.py extract LOG print "<binary> :: <test> :: <outcome>" lines, sorted
|
|
test-outcomes.py compare BEFORE AFTER list tests whose outcome changed, tests only in one log, and the totals
|
|
|
|
A "binary" is the `Running ...` / `Doc-tests ...` header the test came from. Pure stdlib.
|
|
"""
|
|
import re
|
|
import sys
|
|
|
|
|
|
def extract(path):
|
|
outcomes = {}
|
|
binary = "?"
|
|
unresolved = []
|
|
with open(path, encoding="utf-8", errors="replace") as log:
|
|
for line in log:
|
|
line = line.rstrip("\n")
|
|
running = re.match(r"\s*Running (?:unittests )?(.+?)(?: \((.*)\))?$", line)
|
|
if running:
|
|
source = running.group(1).replace(chr(92), "/")
|
|
artifact = (running.group(2) or "").replace(chr(92), "/").split("/")[-1]
|
|
artifact = re.sub(r"(-[0-9a-f]{16})?(\.exe)?$", "", artifact)
|
|
binary = f"{artifact} [{source}]"
|
|
continue
|
|
doc = re.match(r"\s*Doc-tests (.+)", line)
|
|
if doc:
|
|
binary = "doc:" + doc.group(1)
|
|
continue
|
|
result = re.search(r"(?:^|\s)test (\S+) \.\.\. (ok|FAILED|ignored)", line)
|
|
if result:
|
|
outcomes[(binary, result.group(1))] = result.group(2)
|
|
continue
|
|
# A test that prints (an engine's stderr, a log line) puts its verdict somewhere else in the stream.
|
|
# The name is kept as unresolved and settled by the binary's `test result:` summary line.
|
|
started = re.match(r"test (\S+) \.\.\. ", line)
|
|
if started:
|
|
unresolved.append(started.group(1))
|
|
continue
|
|
summary = re.match(r"test result: (ok|FAILED)\. (\d+) passed; (\d+) failed", line)
|
|
if summary:
|
|
for name in unresolved:
|
|
verdict = "ok" if summary.group(3) == "0" else "UNRESOLVED"
|
|
outcomes[(binary, name)] = verdict
|
|
unresolved = []
|
|
return outcomes
|
|
|
|
|
|
def main(argv):
|
|
if len(argv) == 2 and argv[0] == "extract":
|
|
for (binary, name), outcome in sorted(extract(argv[1]).items()):
|
|
print(f"{binary} :: {name} :: {outcome}")
|
|
return 0
|
|
if len(argv) == 3 and argv[0] == "compare":
|
|
before, after = extract(argv[1]), extract(argv[2])
|
|
changed = [(k, before[k], after[k]) for k in before if k in after and before[k] != after[k]]
|
|
only_before = sorted(set(before) - set(after))
|
|
only_after = sorted(set(after) - set(before))
|
|
# A test moved into a child module keeps its function name: pair such tests by (binary, last segment) when the
|
|
# pairing is unique on both sides, and compare their outcomes.
|
|
moved = []
|
|
for key in list(only_before):
|
|
tail = key[1].split("::")[-1]
|
|
old_same = [k for k in only_before if k[0] == key[0] and k[1].split("::")[-1] == tail]
|
|
new_same = [k for k in only_after if k[0] == key[0] and k[1].split("::")[-1] == tail]
|
|
if len(old_same) == 1 and len(new_same) == 1:
|
|
moved.append((key, new_same[0]))
|
|
only_before.remove(key)
|
|
only_after.remove(new_same[0])
|
|
for old_key, new_key in moved:
|
|
if before[old_key] != after[new_key]:
|
|
changed.append((old_key, before[old_key], after[new_key]))
|
|
else:
|
|
print(f"MOVED {old_key[0]} :: {old_key[1]} -> {new_key[1]} ({after[new_key]})")
|
|
for key, was, now in changed:
|
|
print(f"CHANGED {key[0]} :: {key[1]}: {was} -> {now}")
|
|
for key in only_before:
|
|
print(f"MISSING {key[0]} :: {key[1]} (was {before[key]})")
|
|
for key in only_after:
|
|
print(f"NEW {key[0]} :: {key[1]} ({after[key]})")
|
|
count = lambda d, o: sum(1 for v in d.values() if v == o)
|
|
print(f"before: {count(before, 'ok')} ok, {count(before, 'FAILED')} failed, {count(before, 'ignored')} ignored")
|
|
print(f"after: {count(after, 'ok')} ok, {count(after, 'FAILED')} failed, {count(after, 'ignored')} ignored")
|
|
print(f"changed={len(changed)} missing={len(only_before)} new={len(only_after)}")
|
|
return 1 if changed or only_before or any(after[k] == "FAILED" for k in only_after) else 0
|
|
print(__doc__)
|
|
return 2
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main(sys.argv[1:]))
|