MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / classify

Function classify

tests/test_coverage_flush.py:215–265  ·  view source on GitHub ↗
(case, mode, process, obstacle)

Source from the content-addressed store, hash-verified

213
214
215def classify(case, mode, process, obstacle):
216 answer = {"classification": "infrastructure_error", "reasons": [], "observed_test": None}
217 if process["failure"]:
218 answer["reasons"].append(process["failure"])
219 return answer
220 rc = process["returncode"]
221 if rc is None or rc < 0 or rc > 255:
222 answer["reasons"].append("child did not exit normally")
223 return answer
224 stdout = (case / process["stdout"]).read_text(encoding="utf-8", errors="replace")
225 stderr = (case / process["stderr"]).read_text(encoding="utf-8", errors="replace")
226 observed = test_output(stdout)
227 answer["observed_test"] = observed
228 if any(text in stderr for text in BAD_SETUP):
229 answer["reasons"].append("initialization or selection failed")
230 return answer
231 if observed["started"] > 1 or any(row != (TEST, "PASS") for row in observed["rows"]):
232 answer["reasons"].append("unexpected test execution or body failure")
233 return answer
234 if mode != "begin" and not expected_test_once(observed):
235 answer["reasons"].append("selected test did not run exactly once and pass")
236 return answer
237 if mode == "success":
238 if rc or len(observed["summaries"]) != 1 or observed["summaries"][0][:3] != [1, 0, 0]:
239 answer["reasons"].append("positive runner control failed")
240 elif "LLVM Profile Error:" in stderr or "coverage profile" in stderr.lower():
241 answer["reasons"].append("positive control reported a coverage error")
242 else:
243 answer["classification"] = "pass"
244 return answer
245 try:
246 is_directory = stat.S_ISDIR(obstacle.lstat().st_mode)
247 except OSError:
248 is_directory = False
249 if not is_directory:
250 answer["reasons"].append("owned obstacle is no longer a directory")
251 return answer
252 known_error, evidence = write_error_evidence(stderr, obstacle)
253 answer["llvm_write_error_lines"] = evidence
254 if not known_error:
255 answer["classification"] = "unknown_error_precondition"
256 answer["reasons"].append("intended LLVM target-path write failure was not recognized")
257 return answer
258 if rc == 0:
259 answer["classification"] = "regression_failure"
260 answer["reasons"].append("coverage write failed but runner silently exited 0")
261 elif not any(line.startswith("coverage profile write failed:") for line in stderr.splitlines()):
262 answer["reasons"].append("nonzero exit lacks the runner-owned coverage failure diagnostic")
263 else:
264 answer["classification"] = "pass"
265 return answer
266
267
268def run_case(root, mode, runner, tool):

Callers 1

run_caseFunction · 0.70

Calls 3

test_outputFunction · 0.85
expected_test_onceFunction · 0.85
write_error_evidenceFunction · 0.85

Tested by

no test coverage detected