MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / cbm_test_select

Function cbm_test_select

src/mcp/test_impact_select.c:117–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117cbm_test_selection_t *cbm_test_select(const cbm_test_selection_input_t *input) {
118 CBMArena arena;
119 cbm_arena_init(&arena);
120 cbm_test_selection_t *result = cbm_arena_calloc(&arena, sizeof(*result));
121 if (!result) {
122 cbm_arena_destroy(&arena);
123 return NULL;
124 }
125 result->arena = arena;
126 if (!input || input->reach_count < 0 || input->changed_function_count < 0 ||
127 input->suite_trigger_count < 0 || (input->suite_trigger_count && !input->suite_triggers) ||
128 (input->reach_count && !input->reach) ||
129 (input->changed_function_count && !input->changed_function_ids))
130 return sl_full(result, CBM_TEST_SELECT_INVALID_INPUT);
131 if (!input->diff_complete)
132 return sl_full(result, CBM_TEST_SELECT_DIFF_INCOMPLETE);
133 /* Empty is asserted from the complete diff, not inferred from the number
134 * of graph seeds or coverage IDs that happened to resolve. */
135 if (!input->has_changes)
136 return result;
137 unsigned incomplete = 0;
138 if (!input->inventory_complete || !cbm_test_model_narrowable(input->model))
139 incomplete |= CBM_TEST_SELECT_INVENTORY_UNKNOWN;
140 if (!input->static_complete)
141 incomplete |= CBM_TEST_SELECT_STATIC_INCOMPLETE;
142 bool coverage_ok = input->coverage_admitted && input->coverage;
143 if (coverage_ok && !input->coverage_changes_complete)
144 incomplete |= CBM_TEST_SELECT_CHANGE_IDENTITY_UNKNOWN;
145 if (incomplete)
146 return sl_full(result, incomplete);
147 if (coverage_ok) {
148 int functions = cbm_coverage_map_id_count(input->coverage);
149 for (int i = 0; i < input->changed_function_count; i++) {
150 if (input->changed_function_ids[i] < 0 || input->changed_function_ids[i] >= functions)
151 return sl_full(result, CBM_TEST_SELECT_INVALID_INPUT);
152 }
153 }
154
155 int runner_count, definition_count, registration_count, case_count;
156 const cbm_test_runner_suite_t *runners =
157 cbm_test_model_runner_suites(input->model, &runner_count);
158 const cbm_test_suite_t *definitions = cbm_test_model_suites(input->model, &definition_count);
159 const cbm_test_registration_t *registrations =
160 cbm_test_model_registrations(input->model, &registration_count);
161 const cbm_test_case_t *cases = cbm_test_model_cases(input->model, &case_count);
162 if (!runner_count)
163 return sl_full(result, CBM_TEST_SELECT_INVENTORY_UNKNOWN);
164 result->suites = sl_array(result, runner_count, sizeof(*result->suites));
165 result->cases = sl_array(result, registration_count, sizeof(*result->cases));
166 int *definition_counts = sl_array(result, runner_count, sizeof(*definition_counts));
167 int *registration_counts = sl_array(result, runner_count, sizeof(*registration_counts));
168 sl_reach_t *reach = sl_array(result, input->reach_count, sizeof(*reach));
169 const cbm_test_case_t **case_order = sl_array(result, case_count, sizeof(*case_order));
170 const cbm_test_registration_t **order = sl_array(result, registration_count, sizeof(*order));
171 if (!result->suites || !definition_counts || !registration_counts ||
172 (registration_count && (!result->cases || !order)) || (input->reach_count && !reach) ||
173 (case_count && !case_order))
174 goto exhausted;

Callers 4

te_selectFunction · 0.85
ovp_selectFunction · 0.85
test_test_impact.cFile · 0.85
rf_selectionFunction · 0.85

Calls 15

cbm_arena_callocFunction · 0.85
sl_fullFunction · 0.85
cbm_test_model_suitesFunction · 0.85
cbm_test_model_casesFunction · 0.85
sl_arrayFunction · 0.85
sl_wholeFunction · 0.85

Tested by

no test coverage detected