1 #include <tools/ccanlint/ccanlint.h>
2 #include <tools/tools.h>
3 #include <ccan/talloc/talloc.h>
4 #include <ccan/str/str.h>
5 #include <ccan/str_talloc/str_talloc.h>
6 #include <ccan/foreach/foreach.h>
19 static bool has_dep(struct manifest *m, const char *depname)
23 /* We can include ourselves, of course. */
24 if (streq(depname, m->basename))
27 list_for_each(&m->deps, i, list) {
28 if (streq(i->basename, depname))
34 static void check_depends_accurate(struct manifest *m,
36 unsigned int *timeleft, struct score *score)
38 struct list_head *list;
40 /* FIXME: This isn't reliable enough with #ifdefs, so we don't fail. */
43 foreach_ptr(list, &m->c_files, &m->h_files,
44 &m->run_tests, &m->api_tests,
45 &m->compile_ok_tests, &m->compile_fail_tests,
46 &m->other_test_c_files) {
49 list_for_each(list, f, list) {
51 char **lines = get_ccan_file_lines(f);
53 for (i = 0; lines[i]; i++) {
55 if (!strreg(f, lines[i],
56 "^[ \t]*#[ \t]*include[ \t]*[<\"]"
57 "ccan/+([^/]+)/", &mod))
61 score_file_error(score, f, i+1,
62 "%s not listed in _info",
69 score->score = score->total;
73 struct ccanlint depends_accurate = {
74 .key = "depends_accurate",
75 .name = "Module's CCAN dependencies are the only CCAN files #included",
76 .check = check_depends_accurate,
77 .needs = "depends_exist"
80 REGISTER_TEST(depends_accurate);