1 #include <tools/ccanlint/ccanlint.h>
2 #include <tools/tools.h>
3 #include <ccan/talloc/talloc.h>
4 #include <ccan/str/str.h>
17 static bool add_dep(struct manifest *m, const char *dep, struct score *score)
20 struct manifest *subm;
21 char *dir = talloc_asprintf(m, "%s/%s", ccan_dir, dep);
23 /* FIXME: get_manifest has a tendency to exit. */
24 if (stat(dir, &st) != 0) {
27 "Could not stat dependency %s: %s",
28 dir, strerror(errno));
31 subm = get_manifest(m, dir);
32 list_add_tail(&m->deps, &subm->list);
36 /* FIXME: check this is still true once we reduce features. */
37 static void check_depends_exist(struct manifest *m,
38 unsigned int *timeleft, struct score *score)
42 char *updir = talloc_strdup(m, m->dir);
45 if (strrchr(updir, '/'))
46 *strrchr(updir, '/') = '\0';
48 /* We may need libtap for testing, unless we're "tap" */
49 if (streq(m->basename, "tap")) {
51 } else if (list_empty(&m->run_tests) && list_empty(&m->api_tests)) {
58 deps = get_safe_ccan_deps(m, m->dir, true);
60 deps = get_deps(m, m->dir, true, get_or_compile_info);
62 for (i = 0; deps[i]; i++) {
63 if (!strstarts(deps[i], "ccan/"))
66 if (!add_dep(m, deps[i], score))
69 if (streq(deps[i], "ccan/tap")) {
74 if (needs_tap && !add_dep(m, "ccan/tap", score)) {
79 score->score = score->total;
82 struct ccanlint depends_exist = {
83 .key = "depends_exist",
84 .name = "Module's CCAN dependencies can be found",
86 .check = check_depends_exist,
87 .needs = "info_exists"
90 REGISTER_TEST(depends_exist);