ccanlint: make depends_accurate test more accurate.
authorRusty Russell <rusty@rustcorp.com.au>
Wed, 18 Jul 2012 03:38:08 +0000 (13:08 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 18 Jul 2012 03:43:29 +0000 (13:13 +0930)
In particular, don't complain on conditional lines.  That's less thorough,
but removes false negatives we have now.

tools/ccanlint/tests/depends_accurate.c

index d3670a62d58ae281ba79d92b0d088c921932932e..986fb3bcc398df429e3b09d05cd081dc22e9d039 100644 (file)
@@ -36,9 +36,6 @@ 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,
@@ -48,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;
@@ -55,17 +53,25 @@ static void check_depends_accurate(struct manifest *m,
                                            "^[ \t]*#[ \t]*include[ \t]*[<\"]"
                                            "ccan/+([^/]+)/", &mod))
                                        continue;
+
                                if (has_dep(m, mod))
                                        continue;
-                               score_file_error(score, f, i+1,
-                                                "%s not listed in _info",
-                                                mod);
+
+                               /* 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->score = score->total;
+               score->pass = true;
        }
 }