X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fdepends_accurate.c;h=26943faa628a6e98fa93ab5badb9e7c67d511c20;hb=d872b7f22bc98092cad2aa4a456973bdbdb2c8fb;hp=e2e8e8712a61876ecd74a77cc107165ce0578bf2;hpb=dc8042b42500f79f613b1197df6cdf739615a89f;p=ccan diff --git a/tools/ccanlint/tests/depends_accurate.c b/tools/ccanlint/tests/depends_accurate.c index e2e8e871..26943faa 100644 --- a/tools/ccanlint/tests/depends_accurate.c +++ b/tools/ccanlint/tests/depends_accurate.c @@ -21,8 +21,13 @@ static bool has_dep(struct manifest *m, char **deps, bool *used, unsigned int i; /* We can include ourselves, of course. */ - if (streq(depname + strlen("ccan/"), m->modname)) - return true; + if (strstarts(depname + strlen("ccan/"), m->modname)) { + const char *p = depname + strlen("ccan/") + strlen(m->modname); + /* And our own tests! */ + if (streq(p, "/test") || streq(p, "")) + return true; + /* But not any submodules; they need an explicit dep */ + } for (i = 0; deps[i]; i++) { if (streq(deps[i], depname)) { @@ -47,16 +52,15 @@ static bool check_dep_includes(struct manifest *m, char *mod; if (!tal_strreg(f, lines[i], "^[ \t]*#[ \t]*include[ \t]*[<\"]" - "(ccan/+.+)/+[^/]+\\.h", &mod)) + "(ccan/+.+)/+[^/]+\\.[ch][\">]", &mod)) continue; if (has_dep(m, deps, used, mod)) continue; - /* FIXME: we can't be sure about - * conditional includes, so don't - * complain. */ - if (!li[i].cond) { + /* FIXME: we can't be sure about conditional includes, + * so don't complain (handle common case of idempotent wrap) */ + if (!li[i].cond || li[i].cond == f->idempotent_cond) { score_file_error(score, f, i+1, "%s not listed in _info", mod); ok = false; @@ -66,7 +70,8 @@ static bool check_dep_includes(struct manifest *m, } static void check_depends_accurate(struct manifest *m, - unsigned int *timeleft, struct score *score) + unsigned int *timeleft UNNEEDED, + struct score *score) { struct list_head *list; unsigned int i, core_deps, test_deps; @@ -98,14 +103,14 @@ static void check_depends_accurate(struct manifest *m, } for (i = 0; i < core_deps; i++) { - if (!used[i]) + if (!used[i] && strstarts(deps[i], "ccan/")) score_file_error(score, m->info_file, 0, "%s is an unused dependency", deps[i]); } /* Now remove NUL and append test dependencies to deps. */ - deps = tal_dup(m, char *, take(deps), core_deps, test_deps + 2); + deps = tal_dup_arr(m, char *, take(deps), core_deps, test_deps + 2); memcpy(deps + core_deps, tdeps, sizeof(tdeps[0]) * test_deps); /* ccan/tap is given a free pass. */ deps[core_deps + test_deps] = (char *)"ccan/tap"; @@ -138,7 +143,7 @@ struct ccanlint depends_accurate = { .key = "depends_accurate", .name = "Module's CCAN dependencies are the only CCAN files #included", .check = check_depends_accurate, - .needs = "depends_exist test_depends_exist" + .needs = "depends_exist info_compiles test_depends_exist headers_idempotent" }; REGISTER_TEST(depends_accurate);