Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
feat(cpp): test/benchmark/fuzz framework recognition, dynamic hints, end-to-end fixture (#285)
Raghav Chamadiyae5865f977392
diff --git a/docs/LANGUAGE_SUPPORT.md b/docs/LANGUAGE_SUPPORT.mdindex aea47ef69..fdde75132 100644--- a/docs/LANGUAGE_SUPPORT.md+++ b/docs/LANGUAGE_SUPPORT.md@@ -42,7 +42,7 @@ call resolution, named bindings, heritage extraction, and docstrings.| **Kotlin** | `.kt` `.kts` | `Main.kt` `Application.kt` | `import com.example.Foo` / `import com.example.*` sharing the JVM workspace index with Java (cross-language resolution, `.kt` under `src/main/java` recognised) || **Go** | `.go` | `main.go` `cmd/main.go` | `import "path"` with multi-module `go.mod` discovery (longest-prefix match); a package import fans out to **all** `.go` files in the package directory || **Rust** | `.rs` | `main.rs` `lib.rs` | `use crate::` / `use super::` / `use self::` with `Cargo.toml` |-| **C++** | `.cpp` `.cc` `.cxx` `.h` `.hpp` `.hxx` | `main.cpp` `main.cc` | `#include` with `compile_commands.json` resolution |+| **C++** | `.cpp` `.cc` `.cxx` `.h` `.hpp` `.hxx` | `main.cpp` `main.cc` `WinMain` `wWinMain` `LLVMFuzzerTestOneInput` `DllMain` | `#include` with `compile_commands.json` resolution + CMake / Bazel workspace public-header maps + per-target include-dir search + sibling-TU fan-out || **C#** | `.cs` | `Program.cs` `Startup.cs` | `using Acme.Domain` / `global using` / `using static` / `using Alias = X.Y.Z` with `.csproj` / `.sln` / `Directory.Build.props` resolution |All nine languages support:@@ -55,7 +55,7 @@ All nine languages support:- Per-language dynamic-hint extractors (Django/Pytest/Node/`importlib` string-import registries for Python+JS/TS; .NET DI/Activator/InternalsVisibleTo for C#; Spring `getBean`/`@Bean` factories for Java/Kotlin; Ruby `send`/`const_get`/`define_method`/`delegate`; PHP `call_user_func`/`ReflectionClass`/container `get`; Scala `Class.forName`/`given`/`implicit val`; Swift `NSClassFromString`/`Selector`/`#selector`/KVC; C function-pointer assignment + `dlopen`/`dlsym`; Luau `game:GetService`/`setmetatable __index`; Go `reflect.TypeOf`/`reflect.New`/`reflect.ValueOf`/`plugin.Open`/`plugin.Lookup`; Alpine.js `Alpine.data`/`store`/`magic`/`directive` registrations → handler files for JS)- For C# only: MSBuild project graph (`<ProjectReference>` / `<PackageReference>`), namespace → file mapping across projects, `global using` / `using static` / `using alias` propagation, ASP.NET HTTP and gRPC-dotnet contract extraction in workspace mode, cross-repo `<ProjectReference>` and internal-NuGet detection, host-builder extension method resolution (`app.MapCatalogApi()` / `services.AddCatalogServices()` on any C# repo, not just ASP.NET), `nameof(Type)` references resolved as dynamic uses, local `var x = new T()` property reads bound to the defining file, and CommunityToolkit MVVM source-generator synthesis (`[ObservableProperty]` fields → PascalCase property, `[RelayCommand]` methods → `<Name>Command`)- For Go only: a package-granular workspace index (`GoPackageIndex`) built as a warmup phase — a package import resolves to every file in the package directory, and package-qualified calls (`pkg.Func`) / same-package bare calls resolve across all of a package's files; type-reference resolution emits `type_use` edges for field / parameter / return / composite-literal types (unwrapping `*T` / `[]T` / `map[K]V` / `pkg.T` / generics); package-aware dead-code reachability (a file is reachable when its package is imported or is a `package main` entry); structural interface satisfaction — concrete types are matched to the interfaces their method set satisfies (embedded interfaces expanded) and emit `method_implements` edges so interfaces reached only through implementors are not flagged dead; and Go never-flag conventions (`*_test.go`, `cmd/**/main.go`, `doc.go`, `magefile.go`, generated `*.pb.go` / `*_string.go` / `zz_generated*` / `bindata.go`) plus `init` / `TestMain` / `Test*` / `Benchmark*` / `Example*` / `Fuzz*` entry handling-- For C/C++ only: visibility tracked from access specifiers (`public:` / `private:` / `protected:`), `static` file-scope storage class, and export attributes (`__declspec(dllexport)`, `__attribute__((visibility("default")))`, plus WebAssembly / emscripten / WASI markers `EMSCRIPTEN_KEEPALIVE` / `WASM_EXPORT` / `__attribute__((export_name(...)))` / `((used))` so functions exported across the JS↔WASM boundary are not flagged dead); type-reference resolution emits `type_use` edges for struct / typedef types used as field / parameter / return types across an `#include` (rescuing header structs that are never named in an import); COM / I-prefixed bases emit `implements` edges (rest are `extends`); Windows DLL entry points (`DllMain`, `DllGetClassObject`, `DllCanUnloadNow`, `DllRegisterServer`, `DllUnregisterServer`, `DllGetActivationFactory`) are never flagged as dead+- For C/C++ only: a unified `CppWorkspaceIndex` warmup parses CMake reactors (`add_subdirectory`, `add_executable` / `add_library`, `target_sources`, `target_include_directories`, `target_compile_definitions`, `target_link_libraries`, `option`/`if(...)` conditional sources, CMake File API `build/.cmake/api/v1/reply/` JSON), Bazel `BUILD` files (`cc_binary` / `cc_library` / `cc_test` / `cc_proto_library` / `cc_grpc_library` / `cc_fuzz_test`), and `compile_commands.json`; the index drives a six-step include resolver (compile_commands → workspace public-header map → per-target include-dirs → importer-relative → stdlib filter → stem fallback) and fans `#include` edges out to every sibling TU in the same target so internal headers are reachable without a direct importer; project-specific export macros (`LEVELDB_EXPORT` / `SEASTAR_API` / `*_EXPORT` / `*_API` / `*_PUBLIC`) are discovered from `target_compile_definitions` and `#define X __declspec(dllexport)` patterns and re-applied as visibility markers during the warmup, alongside the literal `__declspec(dllexport)` / `__attribute__((visibility("default")))` / `EMSCRIPTEN_KEEPALIVE` / `WASM_EXPORT` / `export_name` / `((used))` markers (so JS↔WASM exports and project-macro-exported public APIs are not flagged dead); type-reference resolution emits `type_use` edges for parameter / field / return / template-argument types (unwrapping `std::vector` / `std::optional` / `std::shared_ptr` / friends and stripping pointer / reference / array tails) and consults the workspace's same-target sibling set for unqualified resolution; static-initialiser registration macros (`PYBIND11_MODULE`, `BOOST_PYTHON_MODULE`, `REGISTER_OP`, `REGISTER_KERNEL_BUILDER`, `BOOST_CLASS_EXPORT`, `PLUGINLIB_EXPORT_CLASS`, `RCLCPP_COMPONENTS_REGISTER_NODE`, `Q_OBJECT` / `Q_GADGET` / `QML_ELEMENT`, gflags `DEFINE_*`, `ABSL_FLAG`, `__attribute__((constructor/used))`, `[[gnu::retain/used]]`, `JNI_OnLoad`, `NAPI_MODULE`) synthesize the symbols they emit at compile time and stamp their TU as an entry point so the file is not flagged unreachable; framework edges cover the C++ test, benchmark, and fuzzing ecosystem — **GoogleTest** (`TEST` / `TEST_F` / `TEST_P` / `TYPED_TEST` with `TEST_F(FixtureClass, …)` emitting a `type_use` edge to the fixture's defining header), **Catch2** (`TEST_CASE` / `TEST_CASE_METHOD` / `SCENARIO`), **Boost.Test** (`BOOST_AUTO_TEST_CASE` / `BOOST_FIXTURE_TEST_CASE(case, Fixture)` with fixture rescue), **doctest** (`DOCTEST_TEST_CASE`), **Google Benchmark** (`BENCHMARK` / `BENCHMARK_F` / `BENCHMARK_MAIN`), **libFuzzer** (`LLVMFuzzerTestOneInput` / `LLVMFuzzerInitialize`); C++ dynamic-hint extractor (function-pointer assignments, designated-initializer field tables, `dlopen` / `dlsym` / `LoadLibrary` / `GetProcAddress`, Qt old-style `connect(SIGNAL(sig()), SLOT(slot()))` and new-style `connect(&Sender::sig, &Recv::slot)`); C++ contract methods (constructor / destructor / operator overloads, conversion operators (`operator bool`, `operator T`), STL customisation points (`begin` / `end` / `cbegin` / `cend` / `rbegin` / `rend` / `size` / `empty` / `data` / `swap` / `hash_value` / `to_string`), coroutine machinery (`await_ready` / `await_suspend` / `await_resume` / `promise_type` / `initial_suspend` / `final_suspend` / `return_void` / `return_value` / `yield_value` / `unhandled_exception`), `std::format` / `std::error_code` customisation); directory-granular reachability with **header-reached-by-symbol-reference rescue**, `int main` / `WinMain` / `wWinMain` / `wmain` / `LLVMFuzzerTestOneInput` / `LLVMFuzzerInitialize` / `DllMain` binary-entry recognition, sibling-rescue (internal header reached via its `.cc` neighbour), same-directory main-carrier rescue (helper files alongside `main.cc` are not dead), and conditional-compile alternative pairing (`env_posix.cc` ↔ `env_windows.cc`, `crypto_openssl.cc` ↔ `crypto_gnutls.cc`); never-flag conventions for `apps/**`, `demos/**`, `examples/**`, `samples/**`, `benchmarks/**`, `bench/**`, `tools/**`, `tests/{perf,fuzz,unit,manual,integration}/**`, `*_test.{cc,cpp}` / `*_unittest.*` / `*_perf.*` / `*_benchmark.*` / `*_fuzz.*` suffix globs, skeleton convention headers (`port_example.h`, `*_example.{h,hpp,cc}`), build directory roots (`build/**`, `cmake-build-*/**`, `_deps/**`, `out/{build,Debug,Release}/**`), generated source patterns (`moc_*.{cpp,cc}`, `ui_*.h`, `qrc_*.{cpp,cc}`, `*.moc`, `*.pb.{cc,h}`, `*.pb-c.{c,h}`, `*.grpc.pb.{cc,h}`, `*.capnp.{c++,h}`, `*.flatbuffers.h`, `*_generated.h`, `*.tab.{c,h}`, `*.yy.c`, `*_lex.cc`, `*_wrap.{cxx,cpp}`, `*.cython.cpp`), vendor roots (`external/**`, `extern/**`, `contrib/**`, `submodules/**`, `vendor/**`, `third_party/**`, `deps/**`), precompiled-header conventions (`pch.{h,cc,cpp}`, `stdafx.*`, `PrecompiledHeader.{cc,cpp}`), and Windows COM / ATL DLL entry points (`DllMain`, `DllGetClassObject`, `DllCanUnloadNow`, `DllRegisterServer`, `DllUnregisterServer`, `DllGetActivationFactory`); a per-symbol-use dead-code check rescues headers whose declared types are referenced as parameter / field / return / template-argument / `extends` / `implements` even with no `#include` chain- For JavaScript only: esbuild/rollup bundle outputs (`*.bundle.js`), minified artifacts (`*.min.js`), LiveReload generated browser-global scripts (`livereload/gen/*`, `livereload.js`) and WASM JS glue (`*wasm_exec.js`) are never flagged as dead (build products / browser-loaded, never module-imported)- For TypeScript / JavaScript only: a workspace-granular index (`TsWorkspaceIndex`) built as a warmup phase that surfaces every file reachable through a `package.json` `exports` map (including `"./locales/*"`-style wildcards) as an entry point so downstream npm consumers don't read as unreachable; type-reference resolution emits `type_use` edges for parameter / field / return / generic-constraint / type-alias-RHS / heritage clauses (unwrapping `Promise<T>`, `T[]`, `Pick<T,K>`, union/intersection, conditional/mapped types) so interfaces consumed only as types are not flagged dead; same-file rescue exempts symbols whose only consumer is another declaration in the same module; convention never-flag globs for `*.test.*` / `*.spec.*` / `*.stories.*` / `*.bench.*` / `__tests__/**` / `__mocks__/**` / Next.js app-router files (`page.tsx`, `layout.tsx`, `route.ts`, `middleware.ts`, `instrumentation.ts`, route segment configs) / SvelteKit `+page` / `+layout` / `+server` / Remix `entry.client` / `entry.server` / `next-env.d.ts` / `*.gen.ts` / `generated/**`; experimental sub-package rescue marks every source file in directories named `bench` / `benchmarks` / `treeshake` / `examples` / `demos` / `samples` / `playground` / `scratch` / `scripts` as a live entry (these dirs invoke their files via runtime CLI arguments no static scan can follow); npm-script entry detection — parses every `package.json` `scripts.*` command for paths (`tsx X.ts` / `bun run X.mts` / `rollup -c X.js`), quoted glob arguments (prettier / eslint scopes), and bare directory tokens; MDX `import` scan + `vitest.config` `include` glob scan as belt-and-suspenders for entry surfaces the static parser can't see; framework edges for Next.js App Router (`app/**/{page,layout,route,middleware,…}`), Hono / Fastify / Koa / Elysia router DSLs (`.get('/x', handler)`), Remix / SvelteKit / Astro filesystem-convention routes, and tRPC procedure registries (`.query(handler)` / `.mutation(handler)`); JSX-namespace types declared inside a `namespace JSX` file are exempt from `unused_export` (consumed by tsc via `jsxImportSource`, never imported as values)- For XAML only: `<ResourceDictionary Source="..."/>` and `MergedDictionaries` entries resolve across `pack://application:,,,/`, `ms-appx:///`, repo-rooted and relative URIs, emitting xaml→xaml `dynamic_uses` edgesdiff --git a/packages/core/src/repowise/core/ingestion/dynamic_hints/cpp.py b/packages/core/src/repowise/core/ingestion/dynamic_hints/cpp.pynew file mode 100644index 000000000..a52db9bd2--- /dev/null+++ b/packages/core/src/repowise/core/ingestion/dynamic_hints/cpp.py@@ -0,0 +1,129 @@+"""Dynamic-hint extractor for C++ function pointers, dlopen/dlsym, and Qt+``QObject::connect`` signal/slot wiring.++Mirrors :mod:`.c` but on C++ extensions (``.cc``/``.cpp``/``.cxx``/``.hpp``/+``.hxx``) and adds the Qt connect-string idiom — ``QObject::connect(s,+SIGNAL(sig()), r, SLOT(slot()))`` — which wires a method into a runtime+dispatch table that the static call graph never sees.+"""++from __future__ import annotations++import re+from pathlib import Path++from .base import DynamicEdge, DynamicHintExtractor++_SKIP_DIRS = {+ "build", "out", "cmake-build-debug", "cmake-build-release",+ "node_modules", ".git", "third_party", "vendor", "_deps",+}++_CPP_EXTS: tuple[str, ...] = (".cc", ".cpp", ".cxx", ".c++", ".hpp", ".hxx", ".h")++# fp = some_function; (function-pointer wiring — RHS must be a known+# function name to count as a function-pointer assignment).+_FN_PTR_ASSIGN_RE = re.compile(r"\b(\w+)\s*=\s*([a-zA-Z_]\w*)\s*;")++# Designated-initializer style: ``.callback = my_callback,``+_DESIG_INIT_RE = re.compile(r"\.\s*\w+\s*=\s*&?\s*([a-zA-Z_]\w*)\s*[,}]")++_DLSYM_RE = re.compile(r"dlsym\s*\(\s*\w+\s*,\s*[\"']([A-Za-z_]\w*)[\"']")+_DLOPEN_RE = re.compile(r"dlopen\s*\(\s*[\"']([^\"']+)[\"']")+_GETPROCADDR_RE = re.compile(r"GetProcAddress\s*\(\s*\w+\s*,\s*[\"']([A-Za-z_]\w*)[\"']")++# Qt old-style string connect: ``QObject::connect(sender, SIGNAL(sig()), recv, SLOT(slot()))``+_QT_CONNECT_STR_RE = re.compile(+ r"\bconnect\s*\([^,]+,\s*SIGNAL\s*\(\s*([A-Za-z_]\w*)\s*\([^)]*\)\s*\)\s*,"+ r"\s*[^,]+,\s*SLOT\s*\(\s*([A-Za-z_]\w*)\s*\([^)]*\)\s*\)"+)+# Qt new-style member-pointer connect: ``connect(s, &Sender::sig, r, &Recv::slot)``+_QT_CONNECT_PTR_RE = re.compile(+ r"\bconnect\s*\([^,]+,\s*&\s*[\w:]+::([A-Za-z_]\w*)\s*,"+ r"\s*[^,]+,\s*&\s*[\w:]+::([A-Za-z_]\w*)"+)++# Function/method definitions — best-effort, intentionally loose.+# Matches a top-level function or out-of-class method definition with a+# body. We capture the bare identifier as the function name; methods+# defined as ``ReturnType Class::method(...) { ... }`` also match+# (capture is ``method``).+_FUNC_DEF_RE = re.compile(+ r"^\s*(?:[\w:<>,\s\*&]+?\s+)?(?:[\w]+::)?([a-zA-Z_]\w*)\s*\([^;{}]*\)\s*"+ r"(?:const\s+)?(?:noexcept\s*(?:\([^)]*\))?\s*)?(?:override\s+)?"+ r"(?:->\s*[\w:<>,\s\*&]+\s+)?\{",+ re.MULTILINE,+)+++class CppDynamicHints(DynamicHintExtractor):+ """Discover C++ function-pointer assignments, dlopen/dlsym, Qt connect."""++ name = "cpp"++ def extract(self, repo_root: Path) -> list[DynamicEdge]:+ edges: list[DynamicEdge] = []++ func_to_files: dict[str, list[str]] = {}+ sources: list[tuple[Path, str, str]] = []+ repo_root_resolved = repo_root.resolve()+ for ext in _CPP_EXTS:+ for src in self._rglob(repo_root, f"*{ext}"):+ try:+ rel_path = src.resolve().relative_to(repo_root_resolved)+ except ValueError:+ continue+ if any(part in _SKIP_DIRS for part in rel_path.parts):+ continue+ try:+ text = src.read_text(encoding="utf-8", errors="ignore")+ except OSError:+ continue+ rel = rel_path.as_posix()+ sources.append((src, text, rel))+ for match in _FUNC_DEF_RE.finditer(text):+ func_to_files.setdefault(match.group(1), []).append(rel)++ for _src, text, rel in sources:+ seen: set[tuple[str, str]] = set()++ def _emit(name: str, kind: str) -> None:+ for target in func_to_files.get(name, ()):+ key = (target, kind)+ if key in seen or target == rel:+ continue+ seen.add(key)+ edges.append(DynamicEdge(+ source=rel, target=target,+ edge_type="dynamic_uses",+ hint_source=f"{self.name}:{kind}",+ ))++ for m in _FN_PTR_ASSIGN_RE.finditer(text):+ _emit(m.group(2), "fn_ptr")++ for m in _DESIG_INIT_RE.finditer(text):+ _emit(m.group(1), "desig_init")++ for m in _DLSYM_RE.finditer(text):+ _emit(m.group(1), "dlsym")++ for m in _GETPROCADDR_RE.finditer(text):+ _emit(m.group(1), "getprocaddress")++ for m in _QT_CONNECT_STR_RE.finditer(text):+ _emit(m.group(1), "qt_signal")+ _emit(m.group(2), "qt_slot")+ for m in _QT_CONNECT_PTR_RE.finditer(text):+ _emit(m.group(1), "qt_signal")+ _emit(m.group(2), "qt_slot")++ for m in _DLOPEN_RE.finditer(text):+ edges.append(DynamicEdge(+ source=rel,+ target=f"external:dlopen:{m.group(1)}",+ edge_type="dynamic_imports",+ hint_source=f"{self.name}:dlopen",+ ))++ return edgesdiff --git a/packages/core/src/repowise/core/ingestion/dynamic_hints/registry.py b/packages/core/src/repowise/core/ingestion/dynamic_hints/registry.pyindex 9f34caf1e..d51d57f40 100644--- a/packages/core/src/repowise/core/ingestion/dynamic_hints/registry.py+++ b/packages/core/src/repowise/core/ingestion/dynamic_hints/registry.py@@ -23,6 +23,7 @@ import structlogfrom .alpine import AlpineDynamicHintsfrom .base import DynamicEdge, DynamicHintExtractorfrom .c import CDynamicHints+from .cpp import CppDynamicHintsfrom .django import DjangoDynamicHintsfrom .dotnet import DotNetDynamicHintsfrom .go import GoDynamicHints@@ -69,6 +70,7 @@ class HintRegistry:ScalaDynamicHints(),SwiftDynamicHints(),CDynamicHints(),+ CppDynamicHints(),LuauDynamicHints(),GoDynamicHints(),RustDynamicHints(),diff --git a/packages/core/src/repowise/core/ingestion/framework_edges/__init__.py b/packages/core/src/repowise/core/ingestion/framework_edges/__init__.pyindex b342fde81..0e3dd200f 100644--- a/packages/core/src/repowise/core/ingestion/framework_edges/__init__.py+++ b/packages/core/src/repowise/core/ingestion/framework_edges/__init__.py@@ -25,6 +25,7 @@ from . import (fastapi,flask,go,+ gtest,hono,jakarta,laravel,@@ -68,6 +69,7 @@ _HANDLERS: list[FrameworkHandler] = [*remix.HANDLERS,*trpc.HANDLERS,*go.HANDLERS,+ *gtest.HANDLERS,*rust.HANDLERS,*typo3.HANDLERS,]diff --git a/packages/core/src/repowise/core/ingestion/framework_edges/gtest.py b/packages/core/src/repowise/core/ingestion/framework_edges/gtest.pynew file mode 100644index 000000000..f5b87587b--- /dev/null+++ b/packages/core/src/repowise/core/ingestion/framework_edges/gtest.py@@ -0,0 +1,164 @@+"""GoogleTest / Catch2 / Boost.Test / doctest / Google Benchmark / libFuzzer.++C++ test- and benchmark-framework recognition. The graph never carries a+static caller edge from the runtime test runner to a ``TEST(Suite, Name)``+body, so without these edges the fixture classes referenced by ``TEST_F``+and ``TEST_CASE_METHOD`` (and Boost ``BOOST_FIXTURE_TEST_CASE``) read as+``unused_export``.++The handler emits two things:++* a framework edge from the test TU to the **fixture class's** defining+ file — so a public ``class BrewFixture : public ::testing::Test {…}``+ declared in one header and used as ``TEST_F(BrewFixture, …)`` from+ another TU stays reachable;+* an ``is_entry_point=True`` stamp on the test TU's file node (the warmup+ already marks ``LLVMFuzzerTestOneInput`` carriers and the registration-+ macro TUs, but ``TEST(…)``-only and ``BENCHMARK(…)``-only TUs are not in+ that token list — emitting the flag here keeps them out of+ ``unreachable_file``).+"""++from __future__ import annotations++import re+from typing import TYPE_CHECKING, Any++from ..resolvers import ResolverContext+from .base import (+ DetectionContext,+ FrameworkHandler,+ _add_edge_if_new,+ _build_class_to_file,+ read_text,+)++if TYPE_CHECKING:+ import networkx as nx+++_CPP_LANGS: tuple[str, ...] = ("cpp", "c")++# Tokens whose presence in any TU means a C++ test framework is in use.+# Cheap reject path before regex work.+_TEST_FRAMEWORK_TOKENS: tuple[str, ...] = (+ "gtest/gtest.h",+ "gmock/gmock.h",+ "catch2/catch",+ "catch.hpp",+ "doctest/doctest.h",+ "doctest.h",+ "boost/test/unit_test.hpp",+ "boost/test/included",+ "benchmark/benchmark.h",+ "TEST(",+ "TEST_F(",+ "TEST_P(",+ "TYPED_TEST(",+ "TEST_CASE(",+ "TEST_CASE_METHOD(",+ "SCENARIO(",+ "DOCTEST_TEST_CASE",+ "BOOST_AUTO_TEST_CASE",+ "BOOST_FIXTURE_TEST_CASE",+ "BENCHMARK(",+ "BENCHMARK_F(",+ "BENCHMARK_MAIN",+ "LLVMFuzzerTestOneInput",+)++# ``TEST_F(FixtureName, TestName)`` / ``TEST_P(FixtureName, …)`` /+# ``TYPED_TEST(FixtureName, …)`` — only the first identifier matters for+# fixture rescue.+_GTEST_FIXTURE_RE = re.compile(+ r"\b(?:TEST_F|TEST_P|TYPED_TEST|TYPED_TEST_P)\s*\(\s*([A-Z_]\w*)\s*,"+)++# Boost.Test: ``BOOST_FIXTURE_TEST_CASE(TestName, FixtureName)`` —+# fixture is the *second* arg.+_BOOST_FIXTURE_RE = re.compile(+ r"\bBOOST_FIXTURE_TEST_(?:CASE|SUITE)\s*\(\s*\w+\s*,\s*([A-Z_]\w*)"+)++# Catch2 / doctest: ``TEST_CASE_METHOD(FixtureName, "name")``.+_CATCH_FIXTURE_RE = re.compile(+ r"\bTEST_CASE_METHOD\s*\(\s*([A-Z_]\w*)\s*,"+)+++def _file_uses_test_framework(text: str) -> bool:+ return any(tok in text for tok in _TEST_FRAMEWORK_TOKENS)+++def _add_gtest_edges(+ graph: nx.DiGraph,+ parsed_files: dict[str, Any],+ path_set: set[str],+) -> int:+ """Emit fixture type_use edges + stamp test TUs as entry points."""+ count = 0+ class_to_file = _build_class_to_file(parsed_files, _CPP_LANGS)++ for path, parsed in parsed_files.items():+ if parsed.file_info.language not in _CPP_LANGS:+ continue+ text = read_text(parsed)+ if not text or not _file_uses_test_framework(text):+ continue++ # Mark the TU as an entry point — the test runner discovers TEST+ # bodies via static-init registration, so no static caller edge+ # exists.+ node = graph.nodes.get(path)+ if node is not None:+ node["is_entry_point"] = True++ seen: set[str] = set()+ for rx in (_GTEST_FIXTURE_RE, _BOOST_FIXTURE_RE, _CATCH_FIXTURE_RE):+ for m in rx.finditer(text):+ fixture = m.group(1)+ if fixture in seen:+ continue+ seen.add(fixture)+ target = class_to_file.get(fixture)+ if target and target != path and target in path_set:+ if _add_edge_if_new(graph, path, target):+ count += 1++ return count+++class _CppTestFrameworkHandler:+ def detect(self, dctx: DetectionContext) -> bool:+ for parsed in dctx.parsed_files.values():+ if parsed.file_info.language not in _CPP_LANGS:+ continue+ for imp in parsed.imports:+ mod = imp.module_path+ if (+ "gtest" in mod+ or "catch" in mod+ or "doctest" in mod+ or "boost/test" in mod+ or "benchmark/benchmark" in mod+ ):+ return True+ # No include detection — fall back to source-text token scan in+ # ``add_edges`` itself. Detect returns True if any cpp/c file+ # exists; the per-file cheap-reject still skips non-tests.+ return any(+ parsed.file_info.language in _CPP_LANGS+ for parsed in dctx.parsed_files.values()+ )++ def add_edges(+ self,+ graph: nx.DiGraph,+ parsed_files: dict[str, Any],+ ctx: ResolverContext,+ path_set: set[str],+ ) -> int:+ return _add_gtest_edges(graph, parsed_files, path_set)+++HANDLERS: list[FrameworkHandler] = [_CppTestFrameworkHandler()]diff --git a/tests/fixtures/cpp_sample/CMakeLists.txt b/tests/fixtures/cpp_sample/CMakeLists.txtnew file mode 100644index 000000000..03bc50a4f--- /dev/null+++ b/tests/fixtures/cpp_sample/CMakeLists.txt@@ -0,0 +1,7 @@+cmake_minimum_required(VERSION 3.20)+project(coffee_sample LANGUAGES CXX)+set(CMAKE_CXX_STANDARD 17)++add_subdirectory(libcoffee)+add_subdirectory(app)+add_subdirectory(tests)diff --git a/tests/fixtures/cpp_sample/app/CMakeLists.txt b/tests/fixtures/cpp_sample/app/CMakeLists.txtnew file mode 100644index 000000000..06f7be9a8--- /dev/null+++ b/tests/fixtures/cpp_sample/app/CMakeLists.txt@@ -0,0 +1,2 @@+add_executable(coffee_app main.cc)+target_link_libraries(coffee_app PRIVATE coffee)diff --git a/tests/fixtures/cpp_sample/app/main.cc b/tests/fixtures/cpp_sample/app/main.ccnew file mode 100644index 000000000..a4b40ee87--- /dev/null+++ b/tests/fixtures/cpp_sample/app/main.cc@@ -0,0 +1,10 @@+#include "coffee/brew.h"++int main(int argc, char** argv) {+ (void)argc;+ (void)argv;+ coffee::Brewer brewer;+ coffee::Beans beans{"ethiopia", 18};+ coffee::Cup cup = brewer.brew(beans);+ return cup.milliliters > 0 ? 0 : 1;+}diff --git a/tests/fixtures/cpp_sample/libcoffee/CMakeLists.txt b/tests/fixtures/cpp_sample/libcoffee/CMakeLists.txtnew file mode 100644index 000000000..f324ebc17--- /dev/null+++ b/tests/fixtures/cpp_sample/libcoffee/CMakeLists.txt@@ -0,0 +1,3 @@+add_library(coffee SHARED src/brew.cc)+target_include_directories(coffee PUBLIC include)+target_compile_definitions(coffee PRIVATE COFFEE_EXPORT_BUILD)diff --git a/tests/fixtures/cpp_sample/libcoffee/attic/legacy.h b/tests/fixtures/cpp_sample/libcoffee/attic/legacy.hnew file mode 100644index 000000000..cb545c7d2--- /dev/null+++ b/tests/fixtures/cpp_sample/libcoffee/attic/legacy.h@@ -0,0 +1,13 @@+#pragma once++// PLANTED DEAD: a header that no source file in this fixture includes,+// declaring a class no source file references. The dead-code analyzer+// MUST keep flagging this header as unreachable.+namespace coffee {++class LegacyAbandoned {+ public:+ int do_nothing();+};++} // namespace coffeediff --git a/tests/fixtures/cpp_sample/libcoffee/attic/legacy_unused.cc b/tests/fixtures/cpp_sample/libcoffee/attic/legacy_unused.ccnew file mode 100644index 000000000..b21059129--- /dev/null+++ b/tests/fixtures/cpp_sample/libcoffee/attic/legacy_unused.cc@@ -0,0 +1,16 @@+// PLANTED DEAD: defines a class referenced by nothing in this fixture.+// The dead-code analyzer MUST keep flagging GenuinelyDead and this file+// (no #include of legacy.h, no caller of run_unused).+namespace coffee {++class GenuinelyDead {+ public:+ int do_nothing() { return 0; }+};++int run_unused() {+ GenuinelyDead d;+ return d.do_nothing();+}++} // namespace coffeediff --git a/tests/fixtures/cpp_sample/libcoffee/include/coffee/brew.h b/tests/fixtures/cpp_sample/libcoffee/include/coffee/brew.hnew file mode 100644index 000000000..120abc0cd--- /dev/null+++ b/tests/fixtures/cpp_sample/libcoffee/include/coffee/brew.h@@ -0,0 +1,20 @@+#pragma once++#include "coffee/types.h"++#if defined(_WIN32) && defined(COFFEE_EXPORT_BUILD)+# define COFFEE_EXPORT __declspec(dllexport)+#else+# define COFFEE_EXPORT+#endif++namespace coffee {++class COFFEE_EXPORT Brewer {+ public:+ Brewer();+ ~Brewer();+ Cup brew(const Beans& beans);+};++} // namespace coffeediff --git a/tests/fixtures/cpp_sample/libcoffee/include/coffee/types.h b/tests/fixtures/cpp_sample/libcoffee/include/coffee/types.hnew file mode 100644index 000000000..384a3ecad--- /dev/null+++ b/tests/fixtures/cpp_sample/libcoffee/include/coffee/types.h@@ -0,0 +1,17 @@+#pragma once++#include <string>++namespace coffee {++struct Beans {+ std::string origin;+ int grams = 18;+};++struct Cup {+ int milliliters = 0;+ std::string flavor;+};++} // namespace coffeediff --git a/tests/fixtures/cpp_sample/libcoffee/src/brew.cc b/tests/fixtures/cpp_sample/libcoffee/src/brew.ccnew file mode 100644index 000000000..6133d88f6--- /dev/null+++ b/tests/fixtures/cpp_sample/libcoffee/src/brew.cc@@ -0,0 +1,15 @@+#include "coffee/brew.h"++namespace coffee {++Brewer::Brewer() = default;+Brewer::~Brewer() = default;++Cup Brewer::brew(const Beans& beans) {+ Cup cup;+ cup.milliliters = beans.grams * 10;+ cup.flavor = beans.origin + " roast";+ return cup;+}++} // namespace coffeediff --git a/tests/fixtures/cpp_sample/tests/CMakeLists.txt b/tests/fixtures/cpp_sample/tests/CMakeLists.txtnew file mode 100644index 000000000..75aef0214--- /dev/null+++ b/tests/fixtures/cpp_sample/tests/CMakeLists.txt@@ -0,0 +1,2 @@+add_executable(coffee_tests brew_test.cc)+target_link_libraries(coffee_tests PRIVATE coffee gtest gtest_main)diff --git a/tests/fixtures/cpp_sample/tests/brew_fixture.h b/tests/fixtures/cpp_sample/tests/brew_fixture.hnew file mode 100644index 000000000..95de1ea3c--- /dev/null+++ b/tests/fixtures/cpp_sample/tests/brew_fixture.h@@ -0,0 +1,10 @@+#pragma once++#include <gtest/gtest.h>++#include "coffee/brew.h"++class BrewFixture : public ::testing::Test {+ protected:+ coffee::Brewer brewer;+};diff --git a/tests/fixtures/cpp_sample/tests/brew_test.cc b/tests/fixtures/cpp_sample/tests/brew_test.ccnew file mode 100644index 000000000..8c11d0c16--- /dev/null+++ b/tests/fixtures/cpp_sample/tests/brew_test.cc@@ -0,0 +1,10 @@+#include <gtest/gtest.h>++#include "coffee/brew.h"+#include "brew_fixture.h"++TEST_F(BrewFixture, BrewsFromBeans) {+ coffee::Beans beans{"kenya", 20};+ coffee::Cup cup = brewer.brew(beans);+ EXPECT_EQ(cup.milliliters, 200);+}diff --git a/tests/integration/test_cpp_dead_code.py b/tests/integration/test_cpp_dead_code.pynew file mode 100644index 000000000..3e070ff56--- /dev/null+++ b/tests/integration/test_cpp_dead_code.py@@ -0,0 +1,141 @@+"""End-to-end C/C++ dead-code regression test for the cpp_sample fixture.++Runs the full FileTraverser -> ASTParser -> GraphBuilder -> DeadCodeAnalyzer+pipeline against tests/fixtures/cpp_sample, the small CMake-driven sample+exercising the Phase 1-4 C/C++ parity work:++- a public header (``coffee/brew.h``) with a project export macro+ (``COFFEE_EXPORT``) and matching implementation (``brew.cc``);+- an ``int main``-bearing app TU consuming the library;+- a GoogleTest TU exercising the framework_edges fixture rescue+ (``TEST_F(BrewFixture, ...)`` -> ``BrewFixture`` declared in a header+ consumed only by the test source);+- a planted-dead header (``legacy.h``) and a planted-dead source+ (``legacy_unused.cc``) that MUST stay flagged.++If a future change over-suppresses, the planted-dead assertions fail.+If a future change regresses to false positives, the live assertions+fail.+"""++from __future__ import annotations++from pathlib import Path++import pytest++from repowise.core.analysis.dead_code import DeadCodeAnalyzer, DeadCodeKind+from repowise.core.ingestion import ASTParser, FileTraverser, GraphBuilder+++CPP_SAMPLE = Path(__file__).parent.parent / "fixtures" / "cpp_sample"++[email protected](scope="module")+def cpp_report():+ traverser = FileTraverser(CPP_SAMPLE)+ parser = ASTParser()+ builder = GraphBuilder(repo_path=CPP_SAMPLE)++ for fi in traverser.traverse():+ source = Path(fi.abs_path).read_bytes()+ builder.add_file(parser.parse_file(fi, source))++ graph = builder.build()+ builder.add_framework_edges([])+ try:+ from repowise.core.ingestion.dynamic_hints import HintRegistry++ registry = HintRegistry()+ builder.add_dynamic_edges(registry.extract_all(CPP_SAMPLE))+ except Exception:+ pass++ analyzer = DeadCodeAnalyzer(graph, git_meta_map={})+ return analyzer.analyze({"min_confidence": 0.0})+++def _paths(report, kind) -> set[str]:+ return {f.file_path for f in report.findings if f.kind == kind}+++def _names(report, kind) -> set[str]:+ return {f.symbol_name for f in report.findings if f.kind == kind}+++class TestPlantedDeadStillFlagged:+ def test_legacy_header_is_unreachable(self, cpp_report) -> None:+ unreachable = _paths(cpp_report, DeadCodeKind.UNREACHABLE_FILE)+ assert any("legacy.h" in p for p in unreachable), (+ "libcoffee/include/coffee/legacy.h has no #include and no symbol "+ "reference — it MUST remain unreachable_file. If this fails, the "+ "analyzer is over-suppressing."+ )++ def test_legacy_unused_source_is_unreachable(self, cpp_report) -> None:+ unreachable = _paths(cpp_report, DeadCodeKind.UNREACHABLE_FILE)+ assert any("legacy_unused.cc" in p for p in unreachable), (+ "legacy_unused.cc has no caller and is not the only source in "+ "its directory's main-bearing siblings — it MUST remain flagged."+ )++ def test_genuinely_dead_class_is_flagged(self, cpp_report) -> None:+ all_dead_names = (+ _names(cpp_report, DeadCodeKind.UNUSED_EXPORT)+ | _names(cpp_report, DeadCodeKind.UNUSED_INTERNAL)+ | _names(cpp_report, DeadCodeKind.UNREACHABLE_FILE)+ )+ # Either the class itself flags as unused_export/internal, or its+ # carrier file flags as unreachable_file (already asserted above).+ # We assert at least one carries through.+ carrier_unreachable = any(+ "legacy_unused.cc" in p+ for p in _paths(cpp_report, DeadCodeKind.UNREACHABLE_FILE)+ )+ assert "GenuinelyDead" in all_dead_names or carrier_unreachable+++class TestLivePathNotFlagged:+ def test_public_header_reachable(self, cpp_report) -> None:+ unreachable = _paths(cpp_report, DeadCodeKind.UNREACHABLE_FILE)+ assert not any("coffee/brew.h" in p for p in unreachable), (+ "brew.h is included by main.cc and brew.cc — must be reachable"+ )++ def test_types_header_reachable(self, cpp_report) -> None:+ unreachable = _paths(cpp_report, DeadCodeKind.UNREACHABLE_FILE)+ assert not any("coffee/types.h" in p for p in unreachable), (+ "types.h is included by brew.h — must be reachable transitively"+ )++ def test_main_carrier_reachable(self, cpp_report) -> None:+ unreachable = _paths(cpp_report, DeadCodeKind.UNREACHABLE_FILE)+ assert not any(p.endswith("app/main.cc") for p in unreachable), (+ "main.cc is the binary entry — must be rescued by main-carrier rule"+ )++ def test_implementation_file_reachable(self, cpp_report) -> None:+ unreachable = _paths(cpp_report, DeadCodeKind.UNREACHABLE_FILE)+ assert not any("libcoffee/src/brew.cc" in p for p in unreachable), (+ "brew.cc implements brew.h — must be reachable"+ )++ def test_brewer_class_not_unused_export(self, cpp_report) -> None:+ exports = _names(cpp_report, DeadCodeKind.UNUSED_EXPORT)+ assert "Brewer" not in exports, (+ "coffee::Brewer is exported via COFFEE_EXPORT and used by main.cc "+ "— must not be flagged unused_export"+ )++ def test_gtest_fixture_class_not_unused(self, cpp_report) -> None:+ exports = _names(cpp_report, DeadCodeKind.UNUSED_EXPORT)+ assert "BrewFixture" not in exports, (+ "BrewFixture is referenced via TEST_F(BrewFixture, ...) — the "+ "GoogleTest framework_edges handler must emit a type_use rescue"+ )++ def test_test_tu_marked_entry(self, cpp_report) -> None:+ # tests/ tree is also never-flag by the Phase 3 globs, so absence+ # from unreachable_file is the assertion that matters.+ unreachable = _paths(cpp_report, DeadCodeKind.UNREACHABLE_FILE)+ assert not any("brew_test.cc" in p for p in unreachable)diff --git a/tests/unit/ingestion/test_cpp_dynamic_hints.py b/tests/unit/ingestion/test_cpp_dynamic_hints.pynew file mode 100644index 000000000..a9346a7be--- /dev/null+++ b/tests/unit/ingestion/test_cpp_dynamic_hints.py@@ -0,0 +1,84 @@+"""Unit tests for the C++ dynamic-hints extractor."""++from __future__ import annotations++from pathlib import Path++from repowise.core.ingestion.dynamic_hints.cpp import CppDynamicHints+++def _extract(repo: Path):+ return CppDynamicHints().extract(repo)+++class TestFunctionPointerAssign:+ def test_fn_ptr_emits_dynamic_uses(self, tmp_path: Path) -> None:+ (tmp_path / "impl.cpp").write_text(+ "void on_tick() {}\n"+ "void register_cb() { auto cb = on_tick; (void)cb; }\n"+ )+ edges = _extract(tmp_path)+ # The self-reference is filtered (target == rel), so an intra-file+ # assignment may emit nothing; assert it didn't crash.+ assert all(e.source != e.target for e in edges)++ def test_fn_ptr_cross_file(self, tmp_path: Path) -> None:+ (tmp_path / "src.cpp").write_text("void on_tick() {}\n")+ (tmp_path / "reg.cpp").write_text(+ "extern void on_tick();\n"+ "void register_cb() { auto cb = on_tick; (void)cb; }\n"+ )+ edges = _extract(tmp_path)+ assert any(+ e.source == "reg.cpp" and e.target == "src.cpp" and "fn_ptr" in e.hint_source+ for e in edges+ )+++class TestDlopenDlsym:+ def test_dlopen_emits_dynamic_import(self, tmp_path: Path) -> None:+ (tmp_path / "loader.cpp").write_text(+ '#include <dlfcn.h>\n'+ 'void load() { void* h = dlopen("./libplug.so", 0); (void)h; }\n'+ )+ edges = _extract(tmp_path)+ assert any(+ e.edge_type == "dynamic_imports" and e.target == "external:dlopen:./libplug.so"+ for e in edges+ )++ def test_dlsym_links_named_function(self, tmp_path: Path) -> None:+ (tmp_path / "plug.cpp").write_text("void do_thing() {}\n")+ (tmp_path / "host.cpp").write_text(+ '#include <dlfcn.h>\n'+ 'void run(void* h) { auto p = dlsym(h, "do_thing"); (void)p; }\n'+ )+ edges = _extract(tmp_path)+ assert any(+ e.source == "host.cpp" and e.target == "plug.cpp" and "dlsym" in e.hint_source+ for e in edges+ )+++class TestQtConnect:+ def test_qt_member_pointer_connect(self, tmp_path: Path) -> None:+ (tmp_path / "sender.cpp").write_text(+ "void on_clicked() {}\n"+ )+ (tmp_path / "wire.cpp").write_text(+ "void wire() { connect(s, &Sender::on_clicked, r, &Recv::do_thing); }\n"+ )+ (tmp_path / "recv.cpp").write_text("void do_thing() {}\n")+ edges = _extract(tmp_path)+ assert any(e.source == "wire.cpp" and e.target == "sender.cpp" for e in edges)+ assert any(e.source == "wire.cpp" and e.target == "recv.cpp" for e in edges)+++class TestSkipDirs:+ def test_build_dir_skipped(self, tmp_path: Path) -> None:+ (tmp_path / "build").mkdir()+ (tmp_path / "build" / "x.cpp").write_text(+ 'void load() { dlopen("ignored.so", 0); }\n'+ )+ edges = _extract(tmp_path)+ assert not any("ignored.so" in e.target for e in edges)diff --git a/tests/unit/ingestion/test_cpp_framework_edges.py b/tests/unit/ingestion/test_cpp_framework_edges.pynew file mode 100644index 000000000..0281c1bcf--- /dev/null+++ b/tests/unit/ingestion/test_cpp_framework_edges.py@@ -0,0 +1,176 @@+"""Unit tests for the GoogleTest / Catch2 / Boost.Test / doctest / Google+Benchmark / libFuzzer framework_edges handler."""++from __future__ import annotations++from datetime import datetime+from pathlib import Path++import networkx as nx++from repowise.core.ingestion.framework_edges import add_framework_edges+from repowise.core.ingestion.models import FileInfo, ParsedFile+from repowise.core.ingestion.parser import ASTParser+from repowise.core.ingestion.resolvers.context import ResolverContext+++def _file_info(rel: str, abs_path: str, language: str) -> FileInfo:+ return FileInfo(+ path=rel,+ abs_path=abs_path,+ language=language,+ size_bytes=100,+ git_hash="",+ last_modified=datetime.now(),+ is_test=False,+ is_config=False,+ is_api_contract=False,+ is_entry_point=False,+ )+++def _build_parsed(repo: Path) -> dict[str, ParsedFile]:+ parser = ASTParser()+ out: dict[str, ParsedFile] = {}+ for src in list(repo.rglob("*.cc")) + list(repo.rglob("*.cpp")) + list(repo.rglob("*.h")) + list(repo.rglob("*.hpp")):+ rel = src.resolve().relative_to(repo.resolve()).as_posix()+ fi = _file_info(rel, str(src.resolve()), "cpp")+ out[rel] = parser.parse_file(fi, src.read_bytes())+ return out+++def _ctx(repo: Path, parsed: dict[str, ParsedFile]) -> ResolverContext:+ path_set = set(parsed.keys())+ stem_map: dict[str, list[str]] = {}+ for p in path_set:+ stem = Path(p).stem.lower()+ stem_map.setdefault(stem, []).append(p)+ return ResolverContext(+ path_set=path_set, stem_map=stem_map, graph=nx.DiGraph(), repo_path=repo+ )+++def _graph_with_nodes(parsed: dict[str, ParsedFile]) -> nx.DiGraph:+ g = nx.DiGraph()+ for p in parsed:+ g.add_node(p)+ return g+++class TestGoogleTestFixtureEdges:+ def test_test_f_emits_fixture_edge(self, tmp_path: Path) -> None:+ (tmp_path / "fixture.h").write_text(+ "#pragma once\n"+ "#include <gtest/gtest.h>\n"+ "class BrewFixture : public ::testing::Test {};\n"+ )+ (tmp_path / "brew_test.cc").write_text(+ "#include <gtest/gtest.h>\n"+ '#include "fixture.h"\n'+ "TEST_F(BrewFixture, BrewsCoffee) { EXPECT_TRUE(true); }\n"+ )+ parsed = _build_parsed(tmp_path)+ graph = _graph_with_nodes(parsed)+ ctx = _ctx(tmp_path, parsed)+ add_framework_edges(graph, parsed, ctx, tech_stack=["gtest"])+ assert graph.has_edge("brew_test.cc", "fixture.h")+ assert graph.nodes["brew_test.cc"].get("is_entry_point") is True++ def test_typed_test_fixture_edge(self, tmp_path: Path) -> None:+ (tmp_path / "ty_fix.h").write_text(+ "#pragma once\n#include <gtest/gtest.h>\n"+ "template <class T> class MyTyped : public ::testing::Test {};\n"+ )+ (tmp_path / "typed_test.cc").write_text(+ "#include <gtest/gtest.h>\n"+ '#include "ty_fix.h"\n'+ "TYPED_TEST(MyTyped, RunsIt) {}\n"+ )+ parsed = _build_parsed(tmp_path)+ graph = _graph_with_nodes(parsed)+ ctx = _ctx(tmp_path, parsed)+ add_framework_edges(graph, parsed, ctx, tech_stack=["gtest"])+ assert graph.has_edge("typed_test.cc", "ty_fix.h")++ def test_plain_test_marks_entry_no_fixture_edge(self, tmp_path: Path) -> None:+ (tmp_path / "plain_test.cc").write_text(+ "#include <gtest/gtest.h>\n"+ "TEST(Suite, ExampleCase) { EXPECT_EQ(1, 1); }\n"+ )+ parsed = _build_parsed(tmp_path)+ graph = _graph_with_nodes(parsed)+ ctx = _ctx(tmp_path, parsed)+ add_framework_edges(graph, parsed, ctx, tech_stack=["gtest"])+ assert graph.nodes["plain_test.cc"].get("is_entry_point") is True+++class TestBoostAndCatch2Fixtures:+ def test_boost_fixture_test_case(self, tmp_path: Path) -> None:+ (tmp_path / "btx.h").write_text(+ "#pragma once\n#include <boost/test/unit_test.hpp>\n"+ "struct DbFixture { int x = 0; };\n"+ )+ (tmp_path / "bt_test.cc").write_text(+ "#include <boost/test/unit_test.hpp>\n"+ '#include "btx.h"\n'+ "BOOST_FIXTURE_TEST_CASE(MyCase, DbFixture) { BOOST_CHECK(x == 0); }\n"+ )+ parsed = _build_parsed(tmp_path)+ graph = _graph_with_nodes(parsed)+ ctx = _ctx(tmp_path, parsed)+ add_framework_edges(graph, parsed, ctx, tech_stack=["boost"])+ assert graph.has_edge("bt_test.cc", "btx.h")++ def test_catch2_test_case_method(self, tmp_path: Path) -> None:+ (tmp_path / "cfix.h").write_text(+ "#pragma once\n#include <catch2/catch_test_macros.hpp>\n"+ "class Cooked { public: int y = 0; };\n"+ )+ (tmp_path / "c_test.cc").write_text(+ "#include <catch2/catch_test_macros.hpp>\n"+ '#include "cfix.h"\n'+ 'TEST_CASE_METHOD(Cooked, "warms up") { REQUIRE(y == 0); }\n'+ )+ parsed = _build_parsed(tmp_path)+ graph = _graph_with_nodes(parsed)+ ctx = _ctx(tmp_path, parsed)+ add_framework_edges(graph, parsed, ctx, tech_stack=["catch2"])+ assert graph.has_edge("c_test.cc", "cfix.h")+++class TestBenchmarkAndFuzzer:+ def test_benchmark_main_marks_entry(self, tmp_path: Path) -> None:+ (tmp_path / "bench.cc").write_text(+ "#include <benchmark/benchmark.h>\n"+ "static void BM_X(benchmark::State& s) { for (auto _ : s); }\n"+ "BENCHMARK(BM_X);\n"+ "BENCHMARK_MAIN();\n"+ )+ parsed = _build_parsed(tmp_path)+ graph = _graph_with_nodes(parsed)+ ctx = _ctx(tmp_path, parsed)+ add_framework_edges(graph, parsed, ctx, tech_stack=["benchmark"])+ assert graph.nodes["bench.cc"].get("is_entry_point") is True++ def test_libfuzzer_entry(self, tmp_path: Path) -> None:+ (tmp_path / "fuzz.cc").write_text(+ "#include <cstdint>\n"+ 'extern "C" int LLVMFuzzerTestOneInput(const uint8_t* d, size_t s) { return 0; }\n'+ )+ parsed = _build_parsed(tmp_path)+ graph = _graph_with_nodes(parsed)+ ctx = _ctx(tmp_path, parsed)+ add_framework_edges(graph, parsed, ctx)+ assert graph.nodes["fuzz.cc"].get("is_entry_point") is True+++class TestNonTestFilesUnaffected:+ def test_plain_cpp_not_marked(self, tmp_path: Path) -> None:+ (tmp_path / "lib.cc").write_text(+ "int add(int a, int b) { return a + b; }\n"+ )+ parsed = _build_parsed(tmp_path)+ graph = _graph_with_nodes(parsed)+ ctx = _ctx(tmp_path, parsed)+ add_framework_edges(graph, parsed, ctx)+ assert graph.nodes["lib.cc"].get("is_entry_point") is None