X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fdepends_accurate.c;h=986fb3bcc398df429e3b09d05cd081dc22e9d039;hp=943fa350e09b3a8d6bc8ffc10c990f3e12e4a8d7;hb=87c679ff36d7b198862cd2652a384d90f89f3b2b;hpb=51a56b52627e635566253a3fae081c3f466b6bb6 diff --git a/tools/ccanlint/tests/depends_accurate.c b/tools/ccanlint/tests/depends_accurate.c index 943fa350..986fb3bc 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,19 +16,6 @@ #include #include -static char *strip_spaces(const void *ctx, char *line) -{ - 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) { struct manifest *i; @@ -44,7 +32,6 @@ static bool has_dep(struct manifest *m, const char *depname) } static void check_depends_accurate(struct manifest *m, - bool keep, unsigned int *timeleft, struct score *score) { struct list_head *list; @@ -58,38 +45,41 @@ static void check_depends_accurate(struct manifest *m, list_for_each(list, f, list) { unsigned int i; char **lines = get_ccan_file_lines(f); + struct line_info *li = get_ccan_line_info(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]); + + /* FIXME: we can't be sure about + * conditional includes, so don't + * complain. */ + if (!li[i].cond) { + score_file_error(score, f, i+1, + "%s not listed in _info", + mod); + } } } } if (!score->error) { - score->pass = true; score->score = score->total; + score->pass = true; } } 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);