ccanlint: Add -k option to keep results.
[ccan] / tools / ccanlint / compulsory_tests / check_depends_exist.c
index 2ac60a2a556c8db27b309216399e496d986ea718..7cdb49f5336a3426cd40adbb8441c191347232e0 100644 (file)
 
 static char *add_dep(char *sofar, struct manifest *m, const char *dep)
 {
 
 static char *add_dep(char *sofar, struct manifest *m, const char *dep)
 {
-       char *dir;
        struct stat st;
        struct ccan_file *f;
 
        struct stat st;
        struct ccan_file *f;
 
-       dir = talloc_asprintf(m, "../%s", dep);
-       if (stat(dir, &st) != 0) {
+       f = new_ccan_file(m, ccan_dir, talloc_strdup(m, dep));
+       if (stat(f->fullname, &st) != 0) {
                return talloc_asprintf_append(sofar,
                                              "ccan/%s: expected it in"
                                              " directory %s\n",
                return talloc_asprintf_append(sofar,
                                              "ccan/%s: expected it in"
                                              " directory %s\n",
-                                             dep, dir);
+                                             dep, f->fullname);
        }
 
        }
 
-       f = new_ccan_file(m, dir);
        list_add_tail(&m->dep_dirs, &f->list);
        return sofar;
 }
 
        list_add_tail(&m->dep_dirs, &f->list);
        return sofar;
 }
 
-static void *check_depends_exist(struct manifest *m)
+static void *check_depends_exist(struct manifest *m,
+                                bool keep,
+                                unsigned int *timeleft)
 {
        unsigned int i;
        char *report = NULL;
        char **deps;
 {
        unsigned int i;
        char *report = NULL;
        char **deps;
+       char *updir = talloc_strdup(m, m->dir);
+
+       *strrchr(updir, '/') = '\0';
 
        if (safe_mode)
 
        if (safe_mode)
-               deps = get_safe_ccan_deps(m, "..", m->basename, true,
+               deps = get_safe_ccan_deps(m, m->dir, true,
                                          &m->info_file->compiled);
        else
                                          &m->info_file->compiled);
        else
-               deps = get_deps(m, "..", m->basename, true,
-                               &m->info_file->compiled);
+               deps = get_deps(m, m->dir, true, &m->info_file->compiled);
 
        for (i = 0; deps[i]; i++) {
                if (!strstarts(deps[i], "ccan/"))
                        continue;
 
 
        for (i = 0; deps[i]; i++) {
                if (!strstarts(deps[i], "ccan/"))
                        continue;
 
-               report = add_dep(report, m, deps[i] + strlen("ccan/"));
+               report = add_dep(report, m, deps[i]);
        }
        return report;
 }
        }
        return report;
 }
@@ -64,7 +66,8 @@ static const char *describe_depends_exist(struct manifest *m,
 }
 
 struct ccanlint depends_exist = {
 }
 
 struct ccanlint depends_exist = {
-       .name = "CCAN dependencies are present",
+       .key = "depends-exist",
+       .name = "Module's CCAN dependencies are present",
        .total_score = 1,
        .check = check_depends_exist,
        .describe = describe_depends_exist,
        .total_score = 1,
        .check = check_depends_exist,
        .describe = describe_depends_exist,