]> git.ozlabs.org Git - ccan/blobdiff - tools/ccanlint/tests/depends_accurate.c
ccanlint: make depends_accurate test more accurate.
[ccan] / tools / ccanlint / tests / depends_accurate.c
index 34db4f84d0dd75b9d402f7ead9bc798cdf88268b..986fb3bcc398df429e3b09d05cd081dc22e9d039 100644 (file)
@@ -32,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;
@@ -46,6 +45,7 @@ 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 *mod;
@@ -53,18 +53,25 @@ static void check_depends_accurate(struct manifest *m,
                                            "^[ \t]*#[ \t]*include[ \t]*[<\"]"
                                            "ccan/+([^/]+)/", &mod))
                                        continue;
+
                                if (has_dep(m, mod))
                                        continue;
-                               score->error = "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;
        }
 }