Files
codebase-memory-mcp/tests/test_main.c
T
Andrew Hundt a775040358 fix(mcp,store,pagerank,pipeline): 18 bugs fixed, DF-1 degree precompute, pass_normalize, 11 TDD tests
Phases 1-8 from comprehensive plan (notes/2026-03-26-0013-plan-*.md):

Phase 1 — Input validation (F1,F4,F6,F7,F9,F10,F15):
  mcp.c: empty label→NULL, limit≤0→default, sort_by/mode enum validation,
  regex pre-validation via cbm_regcomp, depth clamp, direction validation

Phase 2 — B7 Cypher param fix + CQ-2 project expansion:
  mcp.c:handle_query_graph reads "cypher" first with "query" fallback,
  uses resolve_project_store for "self"/"dep"/path shortcuts

Phase 3 — DRY resolve_project_store in 5 handlers:
  handle_get_graph_schema, handle_index_status, handle_get_architecture,
  handle_get_code_snippet, handle_index_dependencies

Phase 4 — DF-1 degree precompute (100× faster queries):
  store.c: node_degree table DDL, search SELECT uses LEFT JOIN with
  HC-6 fallback to edge COUNT, cbm_store_node_degree reads precomputed
  table, arch_hotspots uses nd.calls_in, arch_boundaries adds behavioral types
  pagerank.c: is_calls field, degree accumulation during edge iteration,
  node_degree batch INSERT after LinkRank, OOM-safe allocations

Phase 5 — B2/B5 name-based caller fallback:
  pass_calls.c: 3-step resolution (exact QN → shared helper → Module)
  graph_buffer.c: cbm_gbuf_resolve_by_name_in_file DRY helper (HC-1)

Phase 6 — B17/B13 class-method edge repair:
  NEW pass_normalize.c: enforces I2 (Method→Class) and I3 (Field→Class)
  invariants via QN prefix + name+label+file fallback. O(M+F) runtime.
  pipeline.c: normalize pass before dump. Makefile.cbm updated.

Phase 7 — CBMLangSpec section_node_types field:
  lang_specs.h: added section_node_types (17th field)
  lang_specs.c: all 64 language specs updated with NULL initializer

Phase 8 — IX-1..3 indexing pathway fixes:
  mcp.c: autoindex_failed + just_autoindexed flags in server struct,
  REQUIRE_STORE captures pipeline return code, build_resource_status
  shows "indexing" state + failure detail + action_required hints

Additional fixes:
  G1: summary mode adds results=[] + results_suppressed=true
  CQ-3: Cypher + filter params produces warning

Tests: 2238 pass (11 new in test_input_validation.c covering F1,F6,F9,
F10,F15 edge cases, G1, CQ-3, IX-2). Updated test_store_nodes.c for
total degree. Updated test_token_reduction.c for G1 results key.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-03-26 01:59:37 -04:00

158 lines
3.7 KiB
C

/*
* test_main.c — Test runner entry point for pure C rewrite.
*
* Includes all test suites and runs them sequentially.
*/
/* Global test counters (declared extern in test_framework.h) */
int tf_pass_count = 0;
int tf_fail_count = 0;
int tf_skip_count = 0;
#include "test_framework.h"
/* Forward declarations of suite functions */
extern void suite_arena(void);
extern void suite_hash_table(void);
extern void suite_dyn_array(void);
extern void suite_str_intern(void);
extern void suite_log(void);
extern void suite_str_util(void);
extern void suite_platform(void);
extern void suite_extraction(void);
extern void suite_ac(void);
extern void suite_store_nodes(void);
extern void suite_store_edges(void);
extern void suite_store_search(void);
extern void suite_cypher(void);
extern void suite_mcp(void);
extern void suite_language(void);
extern void suite_gitignore(void);
extern void suite_discover(void);
extern void suite_graph_buffer(void);
extern void suite_registry(void);
extern void suite_pipeline(void);
extern void suite_watcher(void);
extern void suite_lz4(void);
extern void suite_sqlite_writer(void);
extern void suite_go_lsp(void);
extern void suite_c_lsp(void);
extern void suite_store_arch(void);
extern void suite_httplink(void);
extern void suite_traces(void);
extern void suite_configlink(void);
extern void suite_infrascan(void);
extern void suite_cli(void);
extern void suite_system_info(void);
extern void suite_worker_pool(void);
extern void suite_parallel(void);
extern void suite_mem(void);
extern void suite_ui(void);
extern void suite_token_reduction(void);
extern void suite_depindex(void);
extern void suite_pagerank(void);
extern void suite_tool_consolidation(void);
extern void suite_input_validation(void);
extern void suite_integration(void);
int main(void) {
printf("\n codebase-memory-mcp C test suite\n");
/* Foundation */
RUN_SUITE(arena);
RUN_SUITE(hash_table);
RUN_SUITE(dyn_array);
RUN_SUITE(str_intern);
RUN_SUITE(log);
RUN_SUITE(str_util);
RUN_SUITE(platform);
/* Existing C code regression tests */
RUN_SUITE(ac);
RUN_SUITE(extraction);
/* Store (M5) */
RUN_SUITE(store_nodes);
RUN_SUITE(store_edges);
RUN_SUITE(store_search);
/* Cypher (M6) */
RUN_SUITE(cypher);
/* MCP Server (M9) */
RUN_SUITE(mcp);
/* Discover (M2) */
RUN_SUITE(language);
RUN_SUITE(gitignore);
RUN_SUITE(discover);
/* Graph Buffer (M7) */
RUN_SUITE(graph_buffer);
/* Pipeline (M8) */
RUN_SUITE(registry);
RUN_SUITE(pipeline);
/* Watcher (M10) */
RUN_SUITE(watcher);
/* LZ4 + SQLite writer */
RUN_SUITE(lz4);
RUN_SUITE(sqlite_writer);
/* LSP resolvers */
RUN_SUITE(go_lsp);
RUN_SUITE(c_lsp);
/* Architecture + ADR + Louvain */
RUN_SUITE(store_arch);
/* HTTP link */
RUN_SUITE(httplink);
/* Traces helpers */
RUN_SUITE(traces);
/* Config link */
RUN_SUITE(configlink);
/* Infrastructure scanning */
RUN_SUITE(infrascan);
/* CLI (install, update, config) */
RUN_SUITE(cli);
/* System info + worker pool (parallelism) */
RUN_SUITE(system_info);
RUN_SUITE(worker_pool);
/* Parallel pipeline */
RUN_SUITE(parallel);
/* mem + arena + slab integration */
RUN_SUITE(mem);
/* UI (config, embedded assets, layout) */
RUN_SUITE(ui);
/* Token reduction */
RUN_SUITE(token_reduction);
/* Dependency indexing */
RUN_SUITE(depindex);
/* PageRank (node + edge ranking) */
RUN_SUITE(pagerank);
/* Tool consolidation (Phase 9) */
RUN_SUITE(tool_consolidation);
/* Input validation (fuzz-derived) */
RUN_SUITE(input_validation);
/* Integration (end-to-end) */
RUN_SUITE(integration);
TEST_SUMMARY();
}