Skip to content

Commit 91aa8e2

Browse files
committed
doc-links(cs): test the project-file scan's allocation failure too (S17)
The review names two scans whose failure returned no scope: the C# scope scan and the project-file scan. Both record the failure on the file's doc links since e775dcd9, but only the C# scan had a failure seam. The project-file scan gets one (CBM_DOCLINK_ALLOC_PROJECT), and the status test gets a seventh point: a project file whose scan ran out of memory fails the layer (one error row), like the other six. Test: alloc_failure_status (its repository now has a project file). Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent e3c1ea3 commit 91aa8e2

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

‎internal/cbm/doclink.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ enum {
149149
CBM_DOCLINK_ALLOC_TEXT,
150150
CBM_DOCLINK_ALLOC_VALUE,
151151
CBM_DOCLINK_ALLOC_TOKENS,
152-
CBM_DOCLINK_ALLOC_SCOPE, /* the C# scope scan, as if its builder ran out */
152+
CBM_DOCLINK_ALLOC_SCOPE, /* the C# scope scan, as if its builder ran out */
153+
CBM_DOCLINK_ALLOC_PROJECT, /* the project-file scan, likewise */
153154
CBM_DOCLINK_ALLOC_KINDS,
154155
};
155156
void cbm_doclink_test_fail_alloc_after(int kind, int nth);

‎internal/cbm/doclink_cs.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3756,6 +3756,11 @@ const char *cbm_doclink_cs_project_scan_scope(CBMExtractCtx *ctx) {
37563756
} else if (!is_project) {
37573757
return NULL;
37583758
}
3759+
#if defined(CBM_ENABLE_TEST_SEAMS) && CBM_ENABLE_TEST_SEAMS
3760+
if (cbm_doclink_test_fail_alloc(CBM_DOCLINK_ALLOC_PROJECT)) {
3761+
p.out.failed = true;
3762+
}
3763+
#endif
37593764
if (p.out.failed || p.value.failed || !p.out.buf) {
37603765
if (ctx->result) {
37613766
ctx->result->doc_links.failed = true; /* memory ran out, see above */

‎tests/test_doc_mentions.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9652,6 +9652,8 @@ static int dm_alloc_failure_errors(int point) {
96529652
if (!cbm_mkdtemp(tmp)) {
96539653
return -1;
96549654
}
9655+
th_write_file(TH_PATH(tmp, "src/App.csproj"),
9656+
"<Project Sdk=\"Microsoft.NET.Sdk\"></Project>\n");
96559657
th_write_file(TH_PATH(tmp, "src/A.cs"), "namespace N\n{\n public class Target { }\n}\n");
96569658
th_write_file(TH_PATH(tmp, "src/B.cs"), "namespace N\n"
96579659
"{\n"
@@ -9895,7 +9897,8 @@ TEST(doc_mentions_alloc_failure_status) {
98959897
} points[] = {
98969898
{CBM_DOCLINK_ALLOC_SPAN, "doc span"}, {CBM_DOCLINK_ALLOC_TEXT, "doc text"},
98979899
{CBM_DOCLINK_ALLOC_VALUE, "value"}, {CBM_DOCLINK_ALLOC_TOKENS, "token"},
9898-
{CBM_DOCLINK_ALLOC_SCOPE, "scope scan"}, {DM_FAIL_EDGE, "MENTIONS edge"},
9900+
{CBM_DOCLINK_ALLOC_SCOPE, "scope scan"}, {CBM_DOCLINK_ALLOC_PROJECT, "project scan"},
9901+
{DM_FAIL_EDGE, "MENTIONS edge"},
98999902
};
99009903
int baseline = dm_alloc_failure_errors(-1);
99019904
bool ok = baseline == 0;

0 commit comments

Comments
 (0)