* Run one table entry; returns 0 on pass, 1 on failure. * Prints a diagnostic line on failure so failures are self-describing. */
| 132 | * Prints a diagnostic line on failure so failures are self-describing. |
| 133 | */ |
| 134 | static int run_import_case(const import_case_t *tc) { |
| 135 | CBMFileResult *r = do_extract(tc->src, tc->lang, tc->path); |
| 136 | if (!r) { |
| 137 | printf(" FAIL [%s]: cbm_extract_file returned NULL\n", tc->label); |
| 138 | return 1; |
| 139 | } |
| 140 | if (r->has_error) { |
| 141 | printf(" FAIL [%s]: extractor reported error\n", tc->label); |
| 142 | cbm_free_result(r); |
| 143 | return 1; |
| 144 | } |
| 145 | int fail = 0; |
| 146 | if (r->imports.count < tc->min_count) { |
| 147 | printf(" FAIL [%s]: imports.count=%d want>=%d\n", |
| 148 | tc->label, r->imports.count, tc->min_count); |
| 149 | fail = 1; |
| 150 | } |
| 151 | for (int e = 0; tc->expected[e] != NULL; e++) { |
| 152 | if (!imp_has(r, tc->expected[e])) { |
| 153 | printf(" FAIL [%s]: no import with module_path containing \"%s\" " |
| 154 | "(count=%d)\n", |
| 155 | tc->label, tc->expected[e], r->imports.count); |
| 156 | fail = 1; |
| 157 | } |
| 158 | } |
| 159 | cbm_free_result(r); |
| 160 | return fail; |
| 161 | } |
| 162 | |
| 163 | /* Run an array of cases; accumulate failures and return total. */ |
| 164 | static int run_cases(const import_case_t *cases, int n) { |
no test coverage detected