C platform variants (foo_win.c / foo_posix.c, src/unix/ vs src/win/): every * definition keeps its own node under its path-derived QN, the QN its file * and name compute (findability: a lookup by that QN finds it); it calls what * its own body calls; all of them carry the platform-neutral QN * ` . .pick` as variant_key, which relates them, and no * `variants` list; a caller in
| 460 | * `<project>.<neutral>.pick` as variant_key, which relates them, and no |
| 461 | * `variants` list; a caller in a shared file binds to one of them. */ |
| 462 | static int cv_platform_check(const char *lang, const cv_file_t *files, int count, |
| 463 | const cv_platform_t *variants, int variant_count, |
| 464 | const char *neutral) { |
| 465 | cv_proj_t p; |
| 466 | if (!cv_index(&p, files, count)) { |
| 467 | fprintf(stderr, " [%s] fixture could not be indexed\n", lang); |
| 468 | cv_cleanup(&p); |
| 469 | return 0; |
| 470 | } |
| 471 | CBMArena arena; |
| 472 | cbm_arena_init(&arena); |
| 473 | char want_key[512]; |
| 474 | snprintf(want_key, sizeof(want_key), "%s.%s.pick", p.project, neutral); |
| 475 | int ok = 1; |
| 476 | int nodes = cv_count(&p, |
| 477 | "SELECT COUNT(DISTINCT qualified_name) FROM nodes WHERE project=?1 " |
| 478 | "AND name='pick' AND label='Function'", |
| 479 | NULL, NULL); |
| 480 | if (nodes != variant_count) { |
| 481 | fprintf(stderr, " [%s] pick nodes=%d, want %d\n", lang, nodes, variant_count); |
| 482 | ok = 0; |
| 483 | } |
| 484 | const char *calls = "SELECT COUNT(*) FROM edges e JOIN nodes s ON s.id=e.source_id " |
| 485 | "JOIN nodes t ON t.id=e.target_id WHERE e.project=?1 AND " |
| 486 | "e.type='CALLS' AND s.qualified_name=?2 AND t.name=?3"; |
| 487 | for (int i = 0; i < variant_count; i++) { |
| 488 | const cv_platform_t *v = &variants[i]; |
| 489 | const char *want_qn = cbm_fqn_compute(&arena, p.project, v->file, "pick"); |
| 490 | char qn[512]; |
| 491 | char key[512]; |
| 492 | bool found = cv_text(&p, |
| 493 | "SELECT qualified_name FROM nodes WHERE project=?1 AND name='pick' " |
| 494 | "AND label='Function' AND file_path=?2", |
| 495 | v->file, NULL, qn, sizeof(qn)); |
| 496 | bool keyed = found && cv_text(&p, |
| 497 | "SELECT json_extract(properties,'$.variant_key') FROM nodes " |
| 498 | "WHERE project=?1 AND qualified_name=?2", |
| 499 | qn, NULL, key, sizeof(key)); |
| 500 | int own = found ? cv_count(&p, calls, qn, v->callee) : -1; |
| 501 | int other = found ? cv_count(&p, calls, qn, v->other_callee) : -1; |
| 502 | if (!found || !want_qn || strcmp(qn, want_qn) != 0 || !keyed || |
| 503 | strcmp(key, want_key) != 0 || own != 1 || other != 0) { |
| 504 | fprintf(stderr, " [%s] %s: qn=%s (want %s) variant_key=%s (want %s) ->%s=%d ->%s=%d\n", |
| 505 | lang, v->file, found ? qn : "-", want_qn ? want_qn : "?", keyed ? key : "-", |
| 506 | want_key, v->callee, own, v->other_callee, other); |
| 507 | ok = 0; |
| 508 | } |
| 509 | } |
| 510 | int listed = cv_count(&p, |
| 511 | "SELECT COUNT(*) FROM nodes WHERE project=?1 AND name='pick' " |
| 512 | "AND json_extract(properties,'$.variants') IS NOT NULL", |
| 513 | NULL, NULL); |
| 514 | int from_caller = cv_count(&p, |
| 515 | "SELECT COUNT(*) FROM edges e JOIN nodes s ON s.id=e.source_id " |
| 516 | "JOIN nodes t ON t.id=e.target_id WHERE e.project=?1 AND " |
| 517 | "e.type='CALLS' AND s.name='caller' AND t.name='pick'", |
| 518 | NULL, NULL); |
| 519 | if (listed != 0 || from_caller < 1) { |
no test coverage detected