| 17491 | " return f\n" |
| 17492 | |
| 17493 | static bool dc_walk_fixture_open(dc_walk_fixture_t *fx) { |
| 17494 | memset(fx, 0, sizeof(*fx)); |
| 17495 | snprintf(fx->repo, sizeof(fx->repo), "%s/cbm-detect-walk-XXXXXX", cbm_tmpdir()); |
| 17496 | if (!cbm_mkdtemp(fx->repo)) { |
| 17497 | return false; |
| 17498 | } |
| 17499 | char src[600]; |
| 17500 | snprintf(src, sizeof(src), "%s/mod.py", fx->repo); |
| 17501 | if (th_write_file(src, DC_WALK_SRC_HEAD " x = 1\n" DC_WALK_SRC_TAIL) != 0) { |
| 17502 | return false; |
| 17503 | } |
| 17504 | /* Same git invocation rules as the #1363 fixture above. */ |
| 17505 | char cmd[1200]; |
| 17506 | const char *steps[] = {"init -q", "add -A", "commit -q -m init"}; |
| 17507 | for (size_t s = 0; s < sizeof(steps) / sizeof(steps[0]); s++) { |
| 17508 | snprintf(cmd, sizeof(cmd), |
| 17509 | "git -C \"%s\" -c user.name=t -c user.email=t@t.io -c init.defaultBranch=main " |
| 17510 | "-c commit.gpgsign=false %s", |
| 17511 | fx->repo, steps[s]); |
| 17512 | if (system(cmd) != 0) { |
| 17513 | return false; |
| 17514 | } |
| 17515 | } |
| 17516 | fx->srv = cbm_mcp_server_new(NULL); |
| 17517 | if (!fx->srv) { |
| 17518 | return false; |
| 17519 | } |
| 17520 | char idx_args[700]; |
| 17521 | snprintf(idx_args, sizeof(idx_args), "{\"repo_path\":\"%s\",\"mode\":\"full\"}", fx->repo); |
| 17522 | char *idx_resp = cbm_mcp_handle_tool(fx->srv, "index_repository", idx_args); |
| 17523 | free(idx_resp); |
| 17524 | /* The change: one line inside leaf(), line count unchanged. */ |
| 17525 | if (th_write_file(src, DC_WALK_SRC_HEAD " x = 11\n" DC_WALK_SRC_TAIL) != 0) { |
| 17526 | return false; |
| 17527 | } |
| 17528 | fx->project = cbm_project_name_from_path(fx->repo); |
| 17529 | return fx->project != NULL; |
| 17530 | } |
| 17531 | |
| 17532 | static void dc_walk_fixture_close(dc_walk_fixture_t *fx) { |
| 17533 | free(fx->project); |
no test coverage detected