]> git.ozlabs.org Git - ccan/blobdiff - tools/ccanlint/tests/compile_test_helpers.c
alloc: fix missing header in compilation of example.
[ccan] / tools / ccanlint / tests / compile_test_helpers.c
index 2aa8d8639800a379bad6d42f70652b09b5393cda..0ab0cade7e96f427ad5d9f3f4dfdf7d336bf3941 100644 (file)
@@ -21,27 +21,26 @@ static const char *can_build(struct manifest *m)
        return NULL;
 }
 
-static char *objname(const void *ctx, const char *cfile)
+static char *compile(struct manifest *m,
+                    bool keep,
+                    struct ccan_file *cfile)
 {
-       return talloc_asprintf(ctx, "%.*s.o ", strlen(cfile) - 2, cfile);
+       cfile->compiled = maybe_temp_file(m, ".o", keep, cfile->fullname);
+       return compile_object(m, cfile->fullname, ccan_dir, "",
+                             cfile->compiled);
 }
 
-static char *compile(struct manifest *m, const char *cfile)
-{
-       char *obj;
-
-       obj = objname(m, cfile);
-       return compile_object(m, obj, cfile);
-}
-
-static void *do_compile_test_helpers(struct manifest *m)
+static void *do_compile_test_helpers(struct manifest *m,
+                                    bool keep,
+                                    unsigned int *timeleft)
 {
        char *cmdout = NULL;
        struct ccan_file *i;
 
+       compile_tests.total_score = 0;
        list_for_each(&m->other_test_c_files, i, list) {
                compile_tests.total_score++;
-               cmdout = compile(m, i->name);
+               cmdout = compile(m, keep, i);
                if (cmdout)
                        return talloc_asprintf(m,
                                               "Failed to compile helper C"
@@ -58,11 +57,12 @@ static const char *describe_compile_test_helpers(struct manifest *m,
 }
 
 struct ccanlint compile_test_helpers = {
-       .name = "Compiling test helper files",
+       .key = "compile-helpers",
+       .name = "Module test helper objects compile",
        .total_score = 1,
        .check = do_compile_test_helpers,
        .describe = describe_compile_test_helpers,
        .can_run = can_build,
 };
 
-REGISTER_TEST(compile_test_helpers, &depends_built);
+REGISTER_TEST(compile_test_helpers, &depends_built, &has_tests, NULL);