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

Function reduce_suite

scripts/test-impact/coverage-map.py:144–203  ·  view source on GitHub ↗

Turn one suite's raw profiles into {test: (status, reason, names)}.

(suite, suite_dir, profdata, suite_ok)

Source from the content-addressed store, hash-verified

142
143
144def reduce_suite(suite, suite_dir, profdata, suite_ok):
145 """Turn one suite's raw profiles into {test: (status, reason, names)}."""
146 tests = {}
147 markers = {}
148 setup = set()
149 setup_unreadable = False
150 setup_markers = []
151 entries = sorted(os.listdir(suite_dir)) if os.path.isdir(suite_dir) else []
152 for entry in entries:
153 path = os.path.join(suite_dir, entry)
154 marker = MARKER.match(entry)
155 if marker:
156 if marker.group("stem") == "_setup.child":
157 setup_markers.append(marker.group("pid"))
158 else:
159 markers.setdefault(marker.group("stem"), []).append(marker.group("pid"))
160 continue
161 if SETUP.match(entry):
162 names = executed_functions(profdata, path)
163 if names is None:
164 setup_unreadable = True
165 else:
166 setup |= names
167 continue
168 profile = PROFILE.match(entry)
169 if not profile:
170 continue
171 test = tests.setdefault(profile.group("stem"),
172 {"names": set(), "parent": False, "unreadable": []})
173 names = executed_functions(profdata, path)
174 if names is None:
175 test["unreadable"].append(entry)
176 continue
177 test["names"] |= names
178 test["parent"] = test["parent"] or profile.group("who") == "parent"
179
180 result = {}
181 for stem, pids in markers.items():
182 tests.setdefault(stem, {"names": set(), "parent": False, "unreadable": []})
183 for stem, test in sorted(tests.items()):
184 reasons = []
185 if stem in markers:
186 reasons.append("unaccounted forked child: " + ",".join(sorted(markers[stem])))
187 if test["unreadable"]:
188 reasons.append("unreadable profile: " + ",".join(sorted(test["unreadable"])))
189 if not test["parent"]:
190 reasons.append("no parent profile")
191 if not suite_ok:
192 reasons.append("suite did not exit 0")
193 result[stem] = ("incomplete" if reasons else "complete", "; ".join(reasons), test["names"])
194 setup_reasons = []
195 if setup_markers:
196 setup_reasons.append("unaccounted forked child: " + ",".join(sorted(setup_markers)))
197 if setup_unreadable:
198 setup_reasons.append("unreadable setup profile")
199 if not suite_ok:
200 setup_reasons.append("suite did not exit 0")
201 result[SETUP_TEST] = ("incomplete" if setup_reasons else "complete",

Callers 1

mainFunction · 0.85

Calls 2

setFunction · 0.85
executed_functionsFunction · 0.85

Tested by

no test coverage detected