Skip to content

Commit 0545400

Browse files
committed
Fix incremental test data: inject in setup, use unique names in modify test
Inject incr_test_injected/helper in suite setup so tool tests work with CBM_SKIP_PERF=1. Use different function names in incr_modify_file to avoid duplicate injection. Update baseline counts after injection. Lower graph thresholds for sparse checkout on CI.
1 parent f9106c8 commit 0545400

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

tests/test_incremental.c

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,13 @@ TEST(incr_full_index) {
284284
g_full_imports = get_edge_count_by_type("IMPORTS");
285285
g_full_index_ms = ms;
286286

287-
/* FastAPI: ~1100 .py files → expect substantial graph */
288-
ASSERT_GT(g_full_nodes, 5000);
289-
ASSERT_GT(g_full_edges, 1000);
290-
ASSERT_GT(g_full_calls, 500);
291-
ASSERT_GT(g_full_imports, 100);
287+
/* FastAPI: expect substantial graph.
288+
* CI uses sparse checkout (~7K files), local has full repo (~18K files).
289+
* Thresholds set for sparse checkout (smaller graph). */
290+
ASSERT_GT(g_full_nodes, 2000);
291+
ASSERT_GT(g_full_edges, 500);
292+
ASSERT_GT(g_full_calls, 200);
293+
ASSERT_GT(g_full_imports, 50);
292294

293295
/* Performance: full index — warn if slow, don't block */
294296
if ((int)ms > 30000) {
@@ -378,11 +380,11 @@ TEST(incr_modify_file) {
378380
snprintf(path, sizeof(path), "%s/fastapi/applications.py", g_repodir);
379381
FILE *f = fopen(path, "a");
380382
ASSERT(f != NULL);
381-
fprintf(f, "\n\ndef incr_test_injected(x: int) -> int:\n"
382-
" return x * 42\n"
383+
fprintf(f, "\n\ndef incr_modify_extra_a(x: int) -> int:\n"
384+
" return x + 1\n"
383385
"\n"
384-
"def incr_test_helper(y: str) -> str:\n"
385-
" return y.upper()\n");
386+
"def incr_modify_extra_b(y: str) -> str:\n"
387+
" return y.strip()\n");
386388
fclose(f);
387389

388390
double ms = 0;
@@ -392,8 +394,8 @@ TEST(incr_modify_file) {
392394
ASSERT(strstr(resp, "indexed") != NULL);
393395
free(resp);
394396

395-
ASSERT(has_function("incr_test_injected"));
396-
ASSERT(has_function("incr_test_helper"));
397+
ASSERT(has_function("incr_modify_extra_a"));
398+
ASSERT(has_function("incr_modify_extra_b"));
397399
ASSERT_GT(get_node_count(), nodes_before);
398400

399401
/* Single-file incremental should be faster than full */
@@ -2780,6 +2782,28 @@ SUITE(incremental) {
27802782
RUN_TEST(incr_full_has_functions);
27812783
RUN_TEST(incr_full_edge_types);
27822784

2785+
/* Inject test functions so tool tests (trace_path etc.) always have data,
2786+
* even when perf phases are skipped on CI. Update baseline counts. */
2787+
{
2788+
char path[512];
2789+
snprintf(path, sizeof(path), "%s/fastapi/applications.py", g_repodir);
2790+
FILE *f = fopen(path, "a");
2791+
if (f) {
2792+
fprintf(f, "\n\ndef incr_test_injected(x: int) -> int:\n"
2793+
" return x * 42\n"
2794+
"\n"
2795+
"def incr_test_helper(y: str) -> str:\n"
2796+
" return y.upper()\n");
2797+
fclose(f);
2798+
}
2799+
char *resp = index_repo();
2800+
free(resp);
2801+
g_full_nodes = get_node_count();
2802+
g_full_edges = get_edge_count();
2803+
g_full_calls = get_edge_count_by_type("CALLS");
2804+
g_full_imports = get_edge_count_by_type("IMPORTS");
2805+
}
2806+
27832807
if (!skip_perf) {
27842808
/* Phase 2: Noop */
27852809
RUN_TEST(incr_noop_reindex);

0 commit comments

Comments
 (0)