Sources: pairs of (path, text). Model: the test sources among them. */
| 36 | |
| 37 | /* Sources: pairs of (path, text). Model: the test sources among them. */ |
| 38 | static bool tsd_open(tsd_fixture_t *f, const char *const *files, int count) { |
| 39 | memset(f, 0, sizeof(*f)); |
| 40 | f->store = cbm_store_open_memory(); |
| 41 | if (!f->store || cbm_store_upsert_project(f->store, "p", "/tmp/p") != CBM_STORE_OK) { |
| 42 | return false; |
| 43 | } |
| 44 | f->graph = cbm_ti_graph_new(f->store, "p"); |
| 45 | f->source = cbm_ti_source_new(); |
| 46 | f->model = cbm_test_model_new(cbm_test_conventions_cbm()); |
| 47 | if (!f->graph || !f->source || !f->model) { |
| 48 | return false; |
| 49 | } |
| 50 | for (int i = 0; i < count; i += 2) { |
| 51 | size_t len = strlen(files[i + 1]); |
| 52 | if (!cbm_ti_source_add(f->source, files[i], files[i + 1], len)) { |
| 53 | return false; |
| 54 | } |
| 55 | if (strncmp(files[i], "tests/", 6) == 0 && |
| 56 | !cbm_test_model_add_source(f->model, files[i], files[i + 1], len)) { |
| 57 | return false; |
| 58 | } |
| 59 | } |
| 60 | return cbm_ti_source_finish(f->source) && cbm_test_model_finish(f->model); |
| 61 | } |
| 62 | |
| 63 | static void tsd_close(tsd_fixture_t *f) { |
| 64 | cbm_test_model_free(f->model); |
no test coverage detected