82def parse_argv(argv: list[str]) -> tuple[StandInConfig |
None, list[dict]]:
83 """Parse *argv* against the stand-in grammar.
85 Returns ``(config, [])`` on success or ``(None, [error])`` with a
86 single fatal configuration error (first error wins; nothing runs).
89 _dbg(
"OC_TESTING", func, f
"argv={argv}", 3)
93 "UNSUPPORTED_ARGUMENT",
94 "a literal '--' (pytest passthrough) is outside the grammar; "
95 "the surface accepts no pytest passthrough (ADR-T-16)",
102 name, eq, inline_value = token.partition(
"=")
103 if name
in _BARE_FLAGS:
106 "UNSUPPORTED_ARGUMENT",
107 f
"flag {name} takes no value (got {token!r})",
109 value: str |
None =
None
110 elif name
in _VALUE_FLAGS:
114 if i + 1 >= len(argv):
116 "UNSUPPORTED_ARGUMENT",
117 f
"flag {name} requires a value",
123 "UNSUPPORTED_ARGUMENT",
124 f
"unrecognized argument {token!r}: the stand-in accepts "
125 "only the section-20.1 grammar",
128 if name ==
"--workspace":
131 "--workspace is rejected with exit code 4 until workspace "
132 "mode exists (section 20.1); use --package oc_chat",
134 if name ==
"--ndjson":
137 "the ndjson flag belongs to the full grammar; the stand-in "
138 "implements no ndjson sink (section 20.3) and rejects it",
140 if name ==
"--dry-run":
142 elif name ==
"--json":
144 elif name ==
"--package":
146 elif name ==
"--profile":
147 if value
not in _PROFILES:
150 f
"--profile {value!r} is not one of strict, smoke, full",
152 cfg.profile = str(value)
153 cfg.profile_explicit =
True
154 elif name ==
"--seed":
156 cfg.seed = int(str(value), 10)
159 "9004", f
"--seed {value!r} is not an integer",
161 elif name ==
"--workers":
166 count = int(str(value), 10)
172 f
"--workers {value!r} is neither a positive integer "
176 elif name ==
"--marker":
177 cfg.marker = str(value)
178 elif name ==
"--nodeid":
179 cfg.nodeids.append(str(value))
180 elif name ==
"--per-test-timeout":
182 seconds = int(str(value), 10)
188 f
"--per-test-timeout {value!r} is not a positive "
189 "integer number of seconds",
191 cfg.per_test_timeout = seconds
192 elif name ==
"--output-tests-limit":
194 limit = int(str(value), 10)
200 f
"--output-tests-limit {value!r} is not a positive "
203 cfg.output_tests_limit = limit
206 _dbg(
"OC_TESTING", func, f
"parsed profile={cfg.profile} "
207 f
"workers={cfg.workers} nodeids={len(cfg.nodeids)}", 3)