X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fdepends_accurate.c;h=3ba19f60a3240e0385dd720b509887bd4e4b493e;hp=78dad0b13a9c904cacf661a44658948e84ddfc83;hb=8566131a68d4e0e5e10a5179bd50e18106ac646d;hpb=9c41898c663ff54037aceb07104a3024bde70257 diff --git a/tools/ccanlint/tests/depends_accurate.c b/tools/ccanlint/tests/depends_accurate.c index 78dad0b1..3ba19f60 100644 --- a/tools/ccanlint/tests/depends_accurate.c +++ b/tools/ccanlint/tests/depends_accurate.c @@ -46,12 +46,11 @@ static bool has_dep(struct manifest *m, const char *depname, bool tap_ok) return false; } -static void *check_depends_accurate(struct manifest *m, - bool keep, - unsigned int *timeleft) +static void check_depends_accurate(struct manifest *m, + bool keep, + unsigned int *timeleft, struct score *score) { struct list_head *list; - char *report = talloc_strdup(m, ""); foreach_ptr(list, &m->c_files, &m->h_files, &m->run_tests, &m->api_tests, @@ -61,7 +60,7 @@ static void *check_depends_accurate(struct manifest *m, bool tap_ok; /* Including ccan/tap is fine for tests. */ - tap_ok = (list != &m->c_files && list != &m->h_files); + tap_ok = (list != &m->c_files && list != &m->h_files); list_for_each(list, f, list) { unsigned int i; @@ -79,35 +78,25 @@ static void *check_depends_accurate(struct manifest *m, if (!strchr(strchr(p, '/') + 1, '/')) continue; *strchr(strchr(p, '/') + 1, '/') = '\0'; - if (!has_dep(m, p, tap_ok)) - report = talloc_asprintf_append(report, - "%s:%u:%s\n", - f->name, i+1, lines[i]); + if (has_dep(m, p, tap_ok)) + continue; + score->error = "Includes a ccan module" + " not listed in _info"; + score_file_error(score, f, i+1, lines[i]); } } } - if (streq(report, "")) { - talloc_free(report); - report = NULL; + if (!score->error) { + score->pass = true; + score->score = score->total; } - return report; -} - -static const char *describe_depends_accurage(struct manifest *m, - void *check_result) -{ - return talloc_asprintf(check_result, - "You include ccan modules you don't list as dependencies:\n" - "%s", (char *)check_result); } struct ccanlint depends_accurate = { .key = "depends-accurate", .name = "Module's CCAN dependencies are the only ccan files #included", - .total_score = 1, .check = check_depends_accurate, - .describe = describe_depends_accurage, }; REGISTER_TEST(depends_accurate, &depends_exist, NULL);