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

Function pipeline_lsp_failure_case

tests/test_pipeline.c:12175–12258  ·  view source on GitHub ↗

Real cross-file memo failure, after successful extraction. The failure * must reach the public per-file error list on both production drivers. */

Source from the content-addressed store, hash-verified

12173/* Real cross-file memo failure, after successful extraction. The failure
12174 * must reach the public per-file error list on both production drivers. */
12175static int pipeline_lsp_failure_case(bool parallel, const char *stage, bool python, bool depth) {
12176 const char *src = "struct S { int m() { return 1; } };\n"
12177 "void run() { S s; s.m(); }\n";
12178 if (python)
12179 src = "class S:\n def m(self):\n return 1\ndef run():\n s = S()\n s.m()\n";
12180 const char *filename = python ? "memo.py" : "memo.cpp";
12181 const char *extra_name = NULL;
12182 const char *extra_src = NULL;
12183 /* The cross stage needs a call the per-file LSP cannot resolve: the parallel
12184 * driver skips the cross walk for a file whose sites are all resolved. */
12185 if (strcmp(stage, "cross") == 0) {
12186 src = python ? "from memo_def import S\ndef run():\n s = S()\n s.m()\n"
12187 : "void run() { S s; s.m(); }\n";
12188 extra_name = python ? "memo_def.py" : "memo_def.cpp";
12189 extra_src = python ? "class S:\n def m(self):\n return 1\n"
12190 : "struct S { int m() { return 1; } };\n";
12191 }
12192 if (setup_usages_repo(filename, src, extra_name, extra_src) != 0)
12193 FAIL("failed to create memo fixture");
12194 char path[512];
12195 if (parallel) {
12196 for (int i = 0; i < 51; i++) {
12197 snprintf(path, sizeof(path), "%s/memo_pad_%02d.%s", g_usages_tmpdir, i,
12198 python ? "py" : "cpp");
12199 if (th_write_file(path, python ? "# inert parallel routing fixture\n"
12200 : "// inert parallel routing fixture\n") != 0) {
12201 teardown_usages_repo();
12202 FAIL("failed to create parallel routing fixture");
12203 }
12204 }
12205 }
12206 const char *keys[] = {
12207 "CBM_WORKERS", "CBM_INDEX_SINGLE_THREAD",
12208 depth ? (python ? "CBM_TEST_PY_LSP_DEPTH_FAIL_STAGE" : "CBM_TEST_C_LSP_DEPTH_FAIL_STAGE")
12209 : (python ? "CBM_TEST_PY_LSP_MEMO_FAIL_STAGE" : "CBM_TEST_C_LSP_MEMO_FAIL_STAGE")};
12210 char *saved[3] = {0};
12211 bool env_saved = true;
12212 for (int i = 0; i < 3; i++) {
12213 const char *old = getenv(keys[i]);
12214 saved[i] = old ? strdup(old) : NULL;
12215 env_saved = env_saved && (!old || saved[i]);
12216 }
12217 if (!env_saved) {
12218 for (int i = 0; i < 3; i++)
12219 free(saved[i]);
12220 teardown_usages_repo();
12221 FAIL("failed to save memo fixture environment");
12222 }
12223 int set_rc = cbm_setenv(keys[0], parallel ? "4" : "1", 1);
12224 set_rc |= parallel ? cbm_unsetenv(keys[1]) : cbm_setenv(keys[1], "1", 1);
12225 set_rc |= cbm_setenv(keys[2], stage, 1);
12226 snprintf(path, sizeof(path), "%s/memo.db", g_usages_tmpdir);
12227 cbm_pipeline_t *p = set_rc == 0 ? cbm_pipeline_new(g_usages_tmpdir, path, CBM_MODE_FULL) : NULL;
12228 int run_rc = p ? cbm_pipeline_run(p) : -1;
12229 cbm_file_error_t *errors = NULL;
12230 int error_count = 0;
12231 cbm_pipeline_get_file_errors(p, &errors, &error_count);
12232 int memo_errors = 0;

Callers 1

test_pipeline.cFile · 0.85

Calls 9

setup_usages_repoFunction · 0.85
th_write_fileFunction · 0.85
teardown_usages_repoFunction · 0.85
cbm_setenvFunction · 0.85
cbm_unsetenvFunction · 0.85
cbm_pipeline_newFunction · 0.85
cbm_pipeline_runFunction · 0.85
cbm_pipeline_freeFunction · 0.85

Tested by

no test coverage detected