First pass: the rules. A path no rule matches is decided after the * snapshot (te_classify_unmatched). Returns whether the snapshot is needed: * a run-all rule decides everything without it. */
| 233 | * snapshot (te_classify_unmatched). Returns whether the snapshot is needed: |
| 234 | * a run-all rule decides everything without it. */ |
| 235 | static bool te_classify_rules(te_ctx_t *c, bool *need_snapshot, bool **unmatched) { |
| 236 | size_t count = 0; |
| 237 | const cbm_change_file_t *files = cbm_changes_files(c->changes, &count); |
| 238 | int rule_count = 0; |
| 239 | const cbm_test_rule_t *rules = cbm_test_policy_rules(c->policy, &rule_count); |
| 240 | *unmatched = cbm_arena_calloc(&c->arena, count + 1); |
| 241 | if (!*unmatched) { |
| 242 | return te_oom(c); |
| 243 | } |
| 244 | bool run_all = false; |
| 245 | c->activation_complete = true; |
| 246 | for (size_t i = 0; i < count; i++) { |
| 247 | const char *path = (const char *)files[i].path; |
| 248 | const cbm_test_rule_t *rule = NULL; |
| 249 | if (!cbm_test_policy_match_path(c->policy, path, &rule)) { |
| 250 | c->activation_complete = false; |
| 251 | if (!te_fallback(c, CBM_TEST_RESULT_FALLBACK_POLICY_EVALUATION_FAILED, path)) { |
| 252 | return false; |
| 253 | } |
| 254 | continue; |
| 255 | } |
| 256 | if (!rule) { |
| 257 | (*unmatched)[i] = true; |
| 258 | continue; |
| 259 | } |
| 260 | int index = (int)(rule - rules); |
| 261 | if (!te_match(c, index)) { |
| 262 | return false; |
| 263 | } |
| 264 | run_all = run_all || rule->action == CBM_TEST_RULE_RUN_ALL; |
| 265 | if (rule->action == CBM_TEST_RULE_REFERENCING_TESTS && !te_fixture_path(c, path, index)) { |
| 266 | return false; |
| 267 | } |
| 268 | } |
| 269 | *need_snapshot = !run_all && c->fallback_count == 0; |
| 270 | return true; |
| 271 | } |
| 272 | |
| 273 | static bool te_in_ledger(te_ctx_t *c, const char *path) { |
| 274 | const cbm_pinned_tree_view_t *view = cbm_pinned_tree_view(c->tree); |
no test coverage detected