X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fdepends_exist.c;h=f4d1e964634c8210cbf8fb6893ef5f4a4b2403ef;hb=1eadb3a01e2a538567da824ba323dce9ecb78595;hp=3d50a063a243c857bd79179c21dae0eba118955d;hpb=10e5e329a1a8804ff6461e1724071364cf6be572;p=ccan diff --git a/tools/ccanlint/tests/depends_exist.c b/tools/ccanlint/tests/depends_exist.c index 3d50a063..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 @@ -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; @@ -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;