X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fdepends_exist.c;h=f4d1e964634c8210cbf8fb6893ef5f4a4b2403ef;hb=1eadb3a01e2a538567da824ba323dce9ecb78595;hp=76750fb1236f7bab79e7ff2a73412aa74185d919;hpb=453fdc02ce54ff965f9971a3bfd0e1a79b6c98f9;p=ccan diff --git a/tools/ccanlint/tests/depends_exist.c b/tools/ccanlint/tests/depends_exist.c index 76750fb1..f4d1e964 100644 --- a/tools/ccanlint/tests/depends_exist.c +++ b/tools/ccanlint/tests/depends_exist.c @@ -1,7 +1,7 @@ #include #include -#include #include +#include #include #include #include @@ -19,7 +19,7 @@ static bool have_dep(struct manifest *m, const char *dep) struct manifest *i; list_for_each(&m->deps, i, list) - if (streq(i->basename, dep + strlen("ccan/"))) + if (streq(i->modname, dep + strlen("ccan/"))) return true; return false; @@ -31,14 +31,12 @@ static bool add_dep(struct manifest *m, { struct stat st; struct manifest *subm; - char *dir = talloc_asprintf(m, "%s/%s", ccan_dir, dep); + char *dir = path_join(m, ccan_dir, dep); /* FIXME: get_manifest has a tendency to exit. */ if (stat(dir, &st) != 0) { - score->error - = talloc_asprintf(m, - "Could not stat dependency %s: %s", - dir, strerror(errno)); + score->error = tal_fmt(m, "Could not stat dependency %s: %s", + dir, strerror(errno)); return false; } subm = get_manifest(m, dir); @@ -59,9 +57,16 @@ static void check_depends_exist(struct manifest *m, deps = get_deps(m, m->dir, "depends", true, get_or_compile_info); + if (!deps) { + score->error = tal_fmt(m, "Could not extract dependencies"); + return; + } + for (i = 0; deps[i]; i++) { - if (!strstarts(deps[i], "ccan/")) + if (!strstarts(deps[i], "ccan/")) { + non_ccan_deps = true; continue; + } if (!add_dep(m, &m->deps, deps[i], score)) return; @@ -80,7 +85,7 @@ static void check_test_depends_exist(struct manifest *m, bool needs_tap; /* We may need libtap for testing, unless we're "tap" */ - if (streq(m->basename, "tap")) { + if (streq(m->modname, "tap")) { needs_tap = false; } else if (list_empty(&m->run_tests) && list_empty(&m->api_tests)) { needs_tap = false; @@ -98,8 +103,11 @@ static void check_test_depends_exist(struct manifest *m, if (!strstarts(deps[i], "ccan/")) continue; - /* Don't add dependency twice: we can only be on one list! */ + /* Don't add dependency twice: we can only be on one list! + * Also, it's possible to have circular test depends, so drop + * self-refs. */ if (!have_dep(m, deps[i]) + && !streq(deps[i] + strlen("ccan/"), m->modname) && !add_dep(m, &m->test_deps, deps[i], score)) return;