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

Function source_table

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

{profile name: (source file, function name)} for every function compiled into the runner, from its coverage mapping. `profile` is any raw profile of that runner: llvm-cov wants one, its counts are not used.

(llvm_cov, profdata_tool, runner, profile, root, work)

Source from the content-addressed store, hash-verified

83
84
85def source_table(llvm_cov, profdata_tool, runner, profile, root, work):
86 """{profile name: (source file, function name)} for every function compiled
87 into the runner, from its coverage mapping. `profile` is any raw profile of
88 that runner: llvm-cov wants one, its counts are not used."""
89 indexed = os.path.join(work, "table.profdata")
90 merged = subprocess.run([profdata_tool, "merge", "-sparse", "-o", indexed, profile],
91 capture_output=True, text=True)
92 if merged.returncode != 0:
93 fail(f"llvm-profdata merge failed: {merged.stderr.strip()[-300:]}")
94 exported = subprocess.run([llvm_cov, "export", "-format=text", "-skip-expansions",
95 "-skip-branches", f"-instr-profile={indexed}", runner],
96 capture_output=True, text=True)
97 os.remove(indexed)
98 if exported.returncode != 0:
99 fail(f"llvm-cov export failed: {exported.stderr.strip()[-300:]}")
100 base = os.path.realpath(root) + os.sep
101 table = {}
102 for record in json.loads(exported.stdout)["data"][0]["functions"]:
103 files = record.get("filenames") or []
104 if not files:
105 continue
106 path = os.path.realpath(files[0])
107 if path.startswith(base):
108 path = path[len(base):]
109 table[record["name"]] = (path.replace(os.sep, "/"), record["name"].rpartition(":")[2])
110 return table
111
112
113class Functions:

Callers 1

mainFunction · 0.85

Calls 4

removeMethod · 0.80
failFunction · 0.70
getMethod · 0.65
runMethod · 0.45

Tested by

no test coverage detected