The regions fixture plus: a docstring + entry flag on alpha_one, a test * node TESTS-ing alpha_one, SIMILAR_TO across the communities, File nodes * with a FILE_CHANGES_WITH edge, and one missed-coverage shadow file. */
| 1022 | * node TESTS-ing alpha_one, SIMILAR_TO across the communities, File nodes |
| 1023 | * with a FILE_CHANGES_WITH edge, and one missed-coverage shadow file. */ |
| 1024 | static cbm_store_t *atlas_fixture(int64_t *alpha_one_id_out) { |
| 1025 | cbm_store_t *store = regions_fixture(); |
| 1026 | if (!store) |
| 1027 | return NULL; |
| 1028 | /* Find alpha_one / alpha_two / beta_two ids by qualified name. */ |
| 1029 | int64_t ids[3] = {-1, -1, -1}; |
| 1030 | static const char *qns[3] = {"regions-test::alpha_one", "regions-test::alpha_two", |
| 1031 | "regions-test::beta_two"}; |
| 1032 | for (int i = 0; i < 3; i++) { |
| 1033 | cbm_search_params_t params; |
| 1034 | memset(¶ms, 0, sizeof(params)); |
| 1035 | params.project = "regions-test"; |
| 1036 | params.qn_pattern = qns[i]; |
| 1037 | params.limit = 1; |
| 1038 | params.min_degree = -1; |
| 1039 | params.max_degree = -1; |
| 1040 | cbm_search_output_t out; |
| 1041 | memset(&out, 0, sizeof(out)); |
| 1042 | if (cbm_store_search(store, ¶ms, &out) == CBM_STORE_OK && out.count == 1) |
| 1043 | ids[i] = out.results[0].node.id; |
| 1044 | cbm_store_search_free(&out); |
| 1045 | } |
| 1046 | if (ids[0] < 0 || ids[1] < 0 || ids[2] < 0) { |
| 1047 | cbm_store_close(store); |
| 1048 | return NULL; |
| 1049 | } |
| 1050 | /* Re-upsert alpha_one with docstring + entry flag. */ |
| 1051 | cbm_node_t node; |
| 1052 | memset(&node, 0, sizeof(node)); |
| 1053 | node.project = "regions-test"; |
| 1054 | node.label = "Function"; |
| 1055 | node.name = "alpha_one"; |
| 1056 | node.qualified_name = "regions-test::alpha_one"; |
| 1057 | node.file_path = "src/alpha/a1.c"; |
| 1058 | node.start_line = 1; |
| 1059 | node.end_line = 5; |
| 1060 | node.properties_json = "{\"docstring\":\"Entry of alpha.\",\"is_entry_point\":true}"; |
| 1061 | int64_t alpha_one_new = cbm_store_upsert_node(store, &node); |
| 1062 | if (alpha_one_new > 0) |
| 1063 | ids[0] = alpha_one_new; |
| 1064 | if (alpha_one_id_out) |
| 1065 | *alpha_one_id_out = ids[0]; |
| 1066 | |
| 1067 | /* A test node exercising alpha_one. */ |
| 1068 | memset(&node, 0, sizeof(node)); |
| 1069 | node.project = "regions-test"; |
| 1070 | node.label = "Function"; |
| 1071 | node.name = "test_alpha_one"; |
| 1072 | node.qualified_name = "regions-test::test_alpha_one"; |
| 1073 | node.file_path = "tests/test_alpha.c"; |
| 1074 | node.start_line = 1; |
| 1075 | node.end_line = 9; |
| 1076 | int64_t test_id = cbm_store_upsert_node(store, &node); |
| 1077 | |
| 1078 | /* File nodes for co-change. */ |
| 1079 | int64_t file_ids[2]; |
| 1080 | static const char *files[2] = {"src/alpha/a1.c", "src/beta/b1.c"}; |
| 1081 | for (int i = 0; i < 2; i++) { |
no test coverage detected