-- Shared full-pipeline battery (dimensions 7-8) -------------------------- * * Indexes the single-file fixture through the production pipeline and asserts * callable-sourcing (no Module-sourced in-body CALLS) and no dangling CALLS * edges. Returns 0 on PASS, 1 on FAIL. Dimension 7 is RED for most systems * languages on current code -- that is the intended signal. */
| 171 | * languages on current code -- that is the intended signal. |
| 172 | */ |
| 173 | static int pipeline_battery(const char *lang_tag, const char *filename, |
| 174 | const char *src) { |
| 175 | const char *RED = tf_red(); |
| 176 | const char *RST = tf_reset(); |
| 177 | |
| 178 | RFile files[1]; |
| 179 | files[0].name = filename; |
| 180 | files[0].content = src; |
| 181 | |
| 182 | RProj lp; |
| 183 | cbm_store_t *store = rh_index_files(&lp, files, 1); |
| 184 | if (!store) { |
| 185 | printf(" %sFAIL%s [%s] pipeline: rh_index_files returned NULL\n", |
| 186 | RED, RST, lang_tag); |
| 187 | return 1; |
| 188 | } |
| 189 | |
| 190 | int fails = 0; |
| 191 | |
| 192 | /* 7. callable-sourcing -- mod must be 0; we also require >=1 callable-sourced |
| 193 | * edge so a fixture that produced zero CALLS edges cannot vacuously pass. */ |
| 194 | int module_sourced = 0; |
| 195 | int callable_sourced = 0; |
| 196 | inv_count_calls_by_source(store, lp.project, &module_sourced, |
| 197 | &callable_sourced); |
| 198 | if (module_sourced != 0) { |
| 199 | printf(" %sFAIL%s [%s] callable-sourcing: %d in-body CALLS sourced at " |
| 200 | "Module (callable=%d) -- known enclosing-func gap\n", |
| 201 | RED, RST, lang_tag, module_sourced, callable_sourced); |
| 202 | fails++; |
| 203 | } else if (callable_sourced < 1) { |
| 204 | printf(" %sFAIL%s [%s] callable-sourcing: 0 CALLS edges (fixture " |
| 205 | "produced no in-body call edge to attribute)\n", |
| 206 | RED, RST, lang_tag); |
| 207 | fails++; |
| 208 | } |
| 209 | |
| 210 | /* 8. no-dangling -- every CALLS edge endpoint must resolve. */ |
| 211 | int dangling = inv_count_dangling_edges(store, lp.project, "CALLS"); |
| 212 | if (dangling != 0) { |
| 213 | printf(" %sFAIL%s [%s] no-dangling: %d dangling CALLS endpoint(s)\n", |
| 214 | RED, RST, lang_tag, dangling); |
| 215 | fails++; |
| 216 | } |
| 217 | |
| 218 | rh_cleanup(&lp, store); |
| 219 | return fails ? 1 : 0; |
| 220 | } |
| 221 | |
| 222 | /* -- Zig -------------------------------------------------------------------- |
| 223 | * Idiomatic: @import builtin, a top-level struct, two free `fn`s with the callee |
no test coverage detected