Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

doc-links(cs): test the project-file scan's allocation failure too (S17)

Martin Vogel91aa8e241a6f
diff --git a/internal/cbm/doclink.h b/internal/cbm/doclink.h
index fe6b461f1..bb3ffa46f 100644
--- a/internal/cbm/doclink.h
+++ b/internal/cbm/doclink.h
@@ -149,7 +149,8 @@ enum {
CBM_DOCLINK_ALLOC_TEXT,
CBM_DOCLINK_ALLOC_VALUE,
CBM_DOCLINK_ALLOC_TOKENS,
- CBM_DOCLINK_ALLOC_SCOPE, /* the C# scope scan, as if its builder ran out */
+ CBM_DOCLINK_ALLOC_SCOPE, /* the C# scope scan, as if its builder ran out */
+ CBM_DOCLINK_ALLOC_PROJECT, /* the project-file scan, likewise */
CBM_DOCLINK_ALLOC_KINDS,
};
void cbm_doclink_test_fail_alloc_after(int kind, int nth);
diff --git a/internal/cbm/doclink_cs.c b/internal/cbm/doclink_cs.c
index 5996b0003..23db08f5a 100644
--- a/internal/cbm/doclink_cs.c
+++ b/internal/cbm/doclink_cs.c
@@ -3756,6 +3756,11 @@ const char *cbm_doclink_cs_project_scan_scope(CBMExtractCtx *ctx) {
} else if (!is_project) {
return NULL;
}
+#if defined(CBM_ENABLE_TEST_SEAMS) && CBM_ENABLE_TEST_SEAMS
+ if (cbm_doclink_test_fail_alloc(CBM_DOCLINK_ALLOC_PROJECT)) {
+ p.out.failed = true;
+ }
+#endif
if (p.out.failed || p.value.failed || !p.out.buf) {
if (ctx->result) {
ctx->result->doc_links.failed = true; /* memory ran out, see above */
diff --git a/tests/test_doc_mentions.c b/tests/test_doc_mentions.c
index e5fb2024a..aec90228f 100644
--- a/tests/test_doc_mentions.c
+++ b/tests/test_doc_mentions.c
@@ -9652,6 +9652,8 @@ static int dm_alloc_failure_errors(int point) {
if (!cbm_mkdtemp(tmp)) {
return -1;
}
+ th_write_file(TH_PATH(tmp, "src/App.csproj"),
+ "<Project Sdk=\"Microsoft.NET.Sdk\"></Project>\n");
th_write_file(TH_PATH(tmp, "src/A.cs"), "namespace N\n{\n public class Target { }\n}\n");
th_write_file(TH_PATH(tmp, "src/B.cs"), "namespace N\n"
"{\n"
@@ -9895,7 +9897,8 @@ TEST(doc_mentions_alloc_failure_status) {
} points[] = {
{CBM_DOCLINK_ALLOC_SPAN, "doc span"}, {CBM_DOCLINK_ALLOC_TEXT, "doc text"},
{CBM_DOCLINK_ALLOC_VALUE, "value"}, {CBM_DOCLINK_ALLOC_TOKENS, "token"},
- {CBM_DOCLINK_ALLOC_SCOPE, "scope scan"}, {DM_FAIL_EDGE, "MENTIONS edge"},
+ {CBM_DOCLINK_ALLOC_SCOPE, "scope scan"}, {CBM_DOCLINK_ALLOC_PROJECT, "project scan"},
+ {DM_FAIL_EDGE, "MENTIONS edge"},
};
int baseline = dm_alloc_failure_errors(-1);
bool ok = baseline == 0;