X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fdepends_accurate.c;h=e13eb1168bcb28568ee6e0aea349d49e021885df;hp=3ba19f60a3240e0385dd720b509887bd4e4b493e;hb=9aa2e32a540e26d68be9b4c1dbca6a42ef0787c1;hpb=7a163ea2dcafc056fdafc8c71ef011e2bfdbeb65 diff --git a/tools/ccanlint/tests/depends_accurate.c b/tools/ccanlint/tests/depends_accurate.c index 3ba19f60..e13eb116 100644 --- a/tools/ccanlint/tests/depends_accurate.c +++ b/tools/ccanlint/tests/depends_accurate.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -15,32 +16,16 @@ #include #include -static char *strip_spaces(const void *ctx, char *line) +static bool has_dep(struct manifest *m, const char *depname) { - char *p = talloc_strdup(ctx, line); - unsigned int i, j; - - for (i = 0, j = 0; p[i]; i++) { - if (!isspace(p[i])) - p[j++] = p[i]; - } - p[j] = '\0'; - return p; -} - -static bool has_dep(struct manifest *m, const char *depname, bool tap_ok) -{ - struct ccan_file *f; - - if (tap_ok && streq(depname, "ccan/tap")) - return true; + struct manifest *i; /* We can include ourselves, of course. */ - if (streq(depname + strlen("ccan/"), m->basename)) + if (streq(depname, m->basename)) return true; - list_for_each(&m->dep_dirs, f, list) { - if (streq(f->name, depname)) + list_for_each(&m->deps, i, list) { + if (streq(i->basename, depname)) return true; } return false; @@ -52,51 +37,44 @@ static void check_depends_accurate(struct manifest *m, { struct list_head *list; + /* FIXME: This isn't reliable enough with #ifdefs, so we don't fail. */ + score->pass = true; + foreach_ptr(list, &m->c_files, &m->h_files, &m->run_tests, &m->api_tests, &m->compile_ok_tests, &m->compile_fail_tests, &m->other_test_c_files) { struct ccan_file *f; - bool tap_ok; - - /* Including ccan/tap is fine for tests. */ - tap_ok = (list != &m->c_files && list != &m->h_files); list_for_each(list, f, list) { unsigned int i; char **lines = get_ccan_file_lines(f); for (i = 0; lines[i]; i++) { - char *p; - if (lines[i][strspn(lines[i], " \t")] != '#') - continue; - p = strip_spaces(f, lines[i]); - if (!strstarts(p, "#includeerror = "Includes a ccan module" - " not listed in _info"; - score_file_error(score, f, i+1, lines[i]); + score_file_error(score, f, i+1, + "%s not listed in _info", + mod); } } } if (!score->error) { - score->pass = true; score->score = score->total; } } struct ccanlint depends_accurate = { - .key = "depends-accurate", - .name = "Module's CCAN dependencies are the only ccan files #included", + .key = "depends_accurate", + .name = "Module's CCAN dependencies are the only CCAN files #included", .check = check_depends_accurate, + .needs = "depends_exist" }; -REGISTER_TEST(depends_accurate, &depends_exist, NULL); +REGISTER_TEST(depends_accurate);