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

Function run_case

tests/test_coverage_children.py:389–445  ·  view source on GitHub ↗
(root, definition, runner, tool, reducer)

Source from the content-addressed store, hash-verified

387
388
389def run_case(root, definition, runner, tool, reducer):
390 name, suite, tests, ids = definition
391 case = root / name
392 case.mkdir(mode=0o700)
393 coverage = case / "coverage"
394 coverage.mkdir(mode=0o700)
395 suite_dir = coverage / suite
396 result = {"case": name, "suite": suite, "tests": tests, "controls_passed": False}
397 environment = os.environ.copy()
398 environment["LLVM_PROFILE_FILE"] = "/dev/null"
399 environment["CBM_TEST_COVERAGE_DIR"] = str(coverage)
400 environment["CBM_TEST_ONLY"] = ",".join(suite + ":" + test for test in tests)
401 environment.pop("CBM_TEST_ONLY_FILE", None)
402 try:
403 record = run_process(case, "runner", [runner, suite], environment)
404 result["runner"] = record
405 require_process(record)
406 stdout, stderr = read_log(case, record, "stdout"), read_log(case, record, "stderr")
407 validate_test_output(stdout, tests)
408 events = parse_events(stderr, ids)
409 final = validate_events(name, events)
410 result["events"] = events
411 witnesses, obstacles = {}, set()
412 stem = "_setup.child" if name.startswith("setup_") else tests[0]
413 suffixes = {"lower": "lower", "upper": "upper", "normal_ok": "normal",
414 "failed_exec": "failed_exec", "setup_ok": "setup"}
415 for child_id, event in final.items():
416 raw = suite_dir / (stem + "." + str(event["pid"]) + ".profraw")
417 marker = raw.with_suffix(".forked")
418 present = marker.exists()
419 if present != bool(event["marker"]) or (present and not stat.S_ISREG(marker.lstat().st_mode)):
420 raise Infrastructure("recorded final marker differs from completed filesystem")
421 obstructed = name == "explicit_write_failure" or child_id == "normal_bad"
422 if obstructed:
423 obstacles.add(os.path.normpath(str(raw)))
424 if os.path.lexists(str(raw)):
425 raise Infrastructure("owned empty obstruction was not removed after reap")
426 elif child_id == "setup_killed":
427 if os.path.lexists(str(raw)):
428 raise Infrastructure("deliberately killed held child unexpectedly wrote a profile")
429 elif child_id in suffixes:
430 witnesses[raw.name] = COUNT_PREFIX + suffixes[child_id]
431 validate_native_errors(stderr, obstacles)
432 for test in tests:
433 if not regular_nonempty(suite_dir / (test + ".parent.profraw")):
434 raise Infrastructure("passing selected test lacks its genuine parent profile")
435 result["profiles"] = profile_controls(case, suite_dir, tool, environment, witnesses)
436 result["rows"] = reduce_actual(case, suite, suite_dir, tool, reducer, record, environment)
437 result["feature_problems"] = features(name, tests, events, final, result["rows"])
438 if name in ("explicit_success", "setup_success") and result["feature_problems"]:
439 raise Infrastructure("positive retirement/reducer control failed")
440 result["controls_passed"] = True
441 except (Infrastructure, OSError, ValueError, KeyboardInterrupt) as exc:
442 result["infrastructure_error"] = type(exc).__name__ + ": " + str(exc)
443 finally:
444 save(case / "result.json", result)
445 return result
446

Callers 1

mainFunction · 0.70

Calls 15

strFunction · 0.85
require_processFunction · 0.85
read_logFunction · 0.85
validate_test_outputFunction · 0.85
parse_eventsFunction · 0.85
validate_eventsFunction · 0.85
setFunction · 0.85
validate_native_errorsFunction · 0.85
profile_controlsFunction · 0.85
reduce_actualFunction · 0.85
featuresFunction · 0.85
run_processFunction · 0.70

Tested by

no test coverage detected