| 103 | } |
| 104 | |
| 105 | static bool td_record(cbm_test_declarations_t *declarations, yyjson_val *record, |
| 106 | cbm_test_declaration_t *item) { |
| 107 | bool valid = true; |
| 108 | yyjson_val *language = td_field(record, "language", &valid); |
| 109 | yyjson_val *role = td_field(record, "role", &valid); |
| 110 | yyjson_val *define_macro = td_field(record, "define_macro", &valid); |
| 111 | yyjson_val *name_args = td_field(record, "name_args", &valid); |
| 112 | yyjson_val *runner_id = td_field(record, "runner_id", &valid); |
| 113 | yyjson_val *macro = td_field(record, "macro", &valid); |
| 114 | yyjson_val *test_arg = td_field(record, "test_arg", &valid); |
| 115 | yyjson_val *suite_arg = td_field(record, "suite_arg", &valid); |
| 116 | yyjson_val *perf_macro = td_field(record, "perf_macro", &valid); |
| 117 | const char *role_text = td_string(role, NULL); |
| 118 | if (!valid || !role_text || !td_copy_string(declarations, language, false, &item->language)) |
| 119 | return false; |
| 120 | item->test_arg = -1; |
| 121 | item->suite_arg = -1; |
| 122 | if (strcmp(role_text, "case") == 0 || strcmp(role_text, "suite") == 0) { |
| 123 | bool is_case = strcmp(role_text, "case") == 0; |
| 124 | item->role = is_case ? CBM_TEST_DECL_CASE : CBM_TEST_DECL_SUITE; |
| 125 | if (macro || test_arg || suite_arg || perf_macro || (!is_case && runner_id)) |
| 126 | return false; |
| 127 | return td_copy_string(declarations, define_macro, true, &item->define_macro) && |
| 128 | td_name_args(declarations, name_args, item) && |
| 129 | (!runner_id || td_copy_string(declarations, runner_id, false, &item->runner_id)); |
| 130 | } |
| 131 | if (strcmp(role_text, "registration") == 0) { |
| 132 | item->role = CBM_TEST_DECL_REGISTRATION; |
| 133 | if (define_macro || name_args || runner_id || suite_arg || perf_macro) |
| 134 | return false; |
| 135 | return td_copy_string(declarations, macro, true, &item->macro) && |
| 136 | td_argument(test_arg, &item->test_arg); |
| 137 | } |
| 138 | if (strcmp(role_text, "suite_registration") == 0) { |
| 139 | item->role = CBM_TEST_DECL_SUITE_REGISTRATION; |
| 140 | if (define_macro || name_args || runner_id || test_arg) |
| 141 | return false; |
| 142 | return td_copy_string(declarations, macro, true, &item->macro) && |
| 143 | td_argument(suite_arg, &item->suite_arg) && |
| 144 | (!perf_macro || td_copy_string(declarations, perf_macro, true, &item->perf_macro)); |
| 145 | } |
| 146 | return false; |
| 147 | } |
| 148 | |
| 149 | static bool td_conventions(cbm_test_declarations_t *declarations, yyjson_val *value) { |
| 150 | if (!yyjson_is_arr(value)) |
no test coverage detected