61def main(argv: list[str] |
None =
None) -> int:
62 """Run the stand-in CLI; return the §4 exit code."""
64 args = list(sys.argv[1:])
if argv
is None else list(argv)
65 result = run_standin(args)
66 report = result.report
67 _dbg(
"OC_TESTING", func,
68 f
"status={report.get('status')} exit={result.exit_code}", 2)
72 document = json.dumps(report, indent=2)
73 except (TypeError, ValueError)
as exc:
75 f
"report serialisation failed: {exc}"[:2000]
78 _FATAL_ENVELOPE_PREFIX + message + _FATAL_ENVELOPE_SUFFIX
82 sys.stdout.write(document +
"\n")
83 if report.get(
"status") ==
"configuration_error":
85 "oc_chat.testing: configuration error (exit 4); see the "
86 "report's errors[] for the catalog code\n"
88 return result.exit_code
90 if result.captured_output:
91 sys.stdout.write(result.captured_output)
92 summary = report.get(
"summary", {})
94 f
"oc_chat.testing stand-in: status={report.get('status')} "
95 f
"exit={result.exit_code} collected={summary.get('collected', 0)} "
96 f
"passed={summary.get('passed', 0)} "
97 f
"failed={summary.get('failed', 0)} "
98 f
"skipped={summary.get('skipped', 0)} "
99 f
"timeout={summary.get('timeout', 0)} "
100 f
"violations={len(report.get('contract_violations', []))}\n"
102 for entry
in report.get(
"errors", []):
104 f
" [{entry['severity']}] {entry['code']}: {entry['message']}\n"
106 return result.exit_code