@@ -13983,7 +13983,7 @@ enum { PY_REEXPORT_N_EXCLUDED = sizeof(py_reexport_excluded) / sizeof(py_reexpor
1398313983
1398413984/* Index the fixture; lsp[c] = call c's edge has an lsp_* strategy; excluded[e]
1398513985 * = excluded call e reached its target by the LSP anyway. */
13986- static int py_reexport_run(bool parallel, bool *lsp, bool *excluded) {
13986+ static int py_reexport_run(bool parallel, bool incremental, bool *lsp, bool *excluded) {
1398713987 char tmp[256];
1398813988 snprintf(tmp, sizeof(tmp), "/tmp/cbm_py_reexport_XXXXXX");
1398913989 if (!cbm_mkdtemp(tmp)) {
@@ -14087,6 +14087,16 @@ static int py_reexport_run(bool parallel, bool *lsp, bool *excluded) {
1408714087 snprintf(db_path, sizeof(db_path), "%s/py_reexport.db", tmp);
1408814088 cbm_pipeline_t *p = cbm_pipeline_new(tmp, db_path, CBM_MODE_FULL);
1408914089 int run_rc = p ? cbm_pipeline_run(p) : -1;
14090+ if (incremental && run_rc == 0) {
14091+ /* Touch only the caller: re-indexed alone, it must still find the
14092+ * re-exports of the unchanged packages. */
14093+ cbm_pipeline_free(p);
14094+ char main_path[512];
14095+ snprintf(main_path, sizeof(main_path), "%s/app/main.py", tmp);
14096+ th_append_file(main_path, "\n# edited: the second run re-indexes the caller\n");
14097+ p = cbm_pipeline_new(tmp, db_path, CBM_MODE_FULL);
14098+ run_rc = p ? cbm_pipeline_run(p) : -1;
14099+ }
1409014100 const char *project = p ? cbm_pipeline_project_name(p) : NULL;
1409114101 cbm_store_t *s = project ? cbm_store_open_path(db_path) : NULL;
1409214102 if (!s && run_rc == 0) {
@@ -14133,25 +14143,28 @@ static int py_reexport_run(bool parallel, bool *lsp, bool *excluded) {
1413314143}
1413414144
1413514145/* Sequential driver (few files, one worker) and parallel driver (fillers +
14136- * four workers). */
14146+ * four workers), each as a full index and as an incremental re-index that
14147+ * touched only the caller. */
1413714148TEST(pipeline_python_package_reexports_resolve_by_lsp) {
14138- for (int mode = 0; mode < 2; mode++) {
14149+ static const char *const mode_names[] = {"sequential", "parallel", "sequential incremental",
14150+ "parallel incremental"};
14151+ for (int mode = 0; mode < 4; mode++) {
1413914152 bool lsp[PY_REEXPORT_N_CALLS];
1414014153 bool excluded[PY_REEXPORT_N_EXCLUDED];
1414114154 memset(lsp, 0, sizeof(lsp));
1414214155 memset(excluded, 1, sizeof(excluded));
14143- ASSERT_EQ(py_reexport_run(mode == 1 , lsp, excluded), 0);
14156+ ASSERT_EQ(py_reexport_run(( mode & 1) != 0, mode >= 2 , lsp, excluded), 0);
1414414157 for (int c = 0; c < PY_REEXPORT_N_CALLS; c++) {
1414514158 if (!lsp[c]) {
1414614159 fprintf(stderr, " re-export call %s (%s) did not resolve by the LSP\n",
14147- py_reexport_calls[c][0], mode ? "parallel" : "sequential" );
14160+ py_reexport_calls[c][0], mode_names[ mode] );
1414814161 }
1414914162 ASSERT_TRUE(lsp[c]); /* RED for every re-export shape; controls stay green */
1415014163 }
1415114164 for (int e = 0; e < PY_REEXPORT_N_EXCLUDED; e++) {
1415214165 if (excluded[e]) {
1415314166 fprintf(stderr, " excluded call %s (%s) resolved by the LSP anyway\n",
14154- py_reexport_excluded[e][0], mode ? "parallel" : "sequential" );
14167+ py_reexport_excluded[e][0], mode_names[ mode] );
1415514168 }
1415614169 ASSERT_FALSE(excluded[e]); /* __all__, `_`, shadow, barrier */
1415714170 }
0 commit comments