]> git.ozlabs.org Git - ccan/commitdiff
Make ccanlint tests all positive: ie. "has _info.c file: FAILED".
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 28 May 2009 04:04:27 +0000 (13:34 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 28 May 2009 04:04:27 +0000 (13:34 +0930)
tools/ccanlint/Makefile
tools/ccanlint/has_info.c [new file with mode: 0644]
tools/ccanlint/no_info.c [deleted file]
tools/ccanlint/trailing_whitespace.c

index d236346f7dd967ce30c4202c19e12fa0ccdf7c9d..87ff2d0edce161571b0e7956869e583a88ff75ab 100644 (file)
@@ -1,4 +1,4 @@
-OBJS := tools/ccanlint/no_info.o \
+OBJS := tools/ccanlint/has_info.o \
        tools/ccanlint/has_main_header.o \
        tools/ccanlint/has_tests.o \
        tools/ccanlint/trailing_whitespace.o \
        tools/ccanlint/has_main_header.o \
        tools/ccanlint/has_tests.o \
        tools/ccanlint/trailing_whitespace.o \
diff --git a/tools/ccanlint/has_info.c b/tools/ccanlint/has_info.c
new file mode 100644 (file)
index 0000000..563eb2f
--- /dev/null
@@ -0,0 +1,78 @@
+#include "ccanlint.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <limits.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <err.h>
+#include <string.h>
+#include <ccan/noerr/noerr.h>
+
+static void *check_has_info(struct manifest *m)
+{
+       if (m->info_file)
+               return NULL;
+       return m;
+}
+
+static const char *describe_has_info(struct manifest *m, void *check_result)
+{
+       return "You have no _info.c file.\n\n"
+       "The file _info.c contains the metadata for a ccan package: things\n"
+       "like the dependencies, the documentation for the package as a whole\n"
+       "and license information.\n";
+}
+
+static const char template[] = 
+       "#include <string.h>\n"
+       "#include \"config.h\"\n"
+       "\n"
+       "/**\n"
+       " * %s - YOUR-ONE-LINE-DESCRIPTION-HERE\n"
+       " *\n"
+       " * This code ... YOUR-BRIEF-SUMMARY-HERE\n"
+       " *\n"
+       " * Example:\n"
+       " *     FULLY-COMPILABLE-INDENTED-TRIVIAL-BUT-USEFUL-EXAMPLE-HERE\n"
+       " */\n"
+       "int main(int argc, char *argv[])\n"
+       "{\n"
+       "       /* Expect exactly one argument */\n"
+       "       if (argc != 2)\n"
+       "               return 1;\n"
+       "\n"
+       "       if (strcmp(argv[1], \"depends\") == 0) {\n"
+       "               PRINTF-CCAN-PACKAGES-YOU-NEED-ONE-PER-LINE-IF-ANY\n"
+       "               return 0;\n"
+       "       }\n"
+       "\n"
+       "       return 1;\n"
+       "}\n";
+
+static void create_info_template(struct manifest *m, void *check_result)
+{
+       FILE *info;
+
+       if (!ask("Should I create a template _info.c file for you?"))
+               return;
+
+       info = fopen("_info.c", "w");
+       if (!info)
+               err(1, "Trying to create a template _info.c");
+
+       if (fprintf(info, template, m->basename) < 0) {
+               unlink_noerr("_info.c");
+               err(1, "Writing template into _info.c");
+       }
+       fclose(info);
+}
+
+struct ccanlint has_info = {
+       .name = "Has _info.c file",
+       .check = check_has_info,
+       .describe = describe_has_info,
+       .handle = create_info_template,
+};
diff --git a/tools/ccanlint/no_info.c b/tools/ccanlint/no_info.c
deleted file mode 100644 (file)
index 1ac925c..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#include "ccanlint.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <limits.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <err.h>
-#include <string.h>
-#include <ccan/noerr/noerr.h>
-
-static void *check_no_info(struct manifest *m)
-{
-       if (m->info_file)
-               return NULL;
-       return m;
-}
-
-static const char *describe_no_info(struct manifest *m, void *check_result)
-{
-       return "You have no _info.c file.\n\n"
-       "The file _info.c contains the metadata for a ccan package: things\n"
-       "like the dependencies, the documentation for the package as a whole\n"
-       "and license information.\n";
-}
-
-static const char template[] = 
-       "#include <string.h>\n"
-       "#include \"config.h\"\n"
-       "\n"
-       "/**\n"
-       " * %s - YOUR-ONE-LINE-DESCRIPTION-HERE\n"
-       " *\n"
-       " * This code ... YOUR-BRIEF-SUMMARY-HERE\n"
-       " *\n"
-       " * Example:\n"
-       " *     FULLY-COMPILABLE-INDENTED-TRIVIAL-BUT-USEFUL-EXAMPLE-HERE\n"
-       " */\n"
-       "int main(int argc, char *argv[])\n"
-       "{\n"
-       "       /* Expect exactly one argument */\n"
-       "       if (argc != 2)\n"
-       "               return 1;\n"
-       "\n"
-       "       if (strcmp(argv[1], \"depends\") == 0) {\n"
-       "               PRINTF-CCAN-PACKAGES-YOU-NEED-ONE-PER-LINE-IF-ANY\n"
-       "               return 0;\n"
-       "       }\n"
-       "\n"
-       "       return 1;\n"
-       "}\n";
-
-static void create_info_template(struct manifest *m, void *check_result)
-{
-       FILE *info;
-
-       if (!ask("Should I create a template _info.c file for you?"))
-               return;
-
-       info = fopen("_info.c", "w");
-       if (!info)
-               err(1, "Trying to create a template _info.c");
-
-       if (fprintf(info, template, m->basename) < 0) {
-               unlink_noerr("_info.c");
-               err(1, "Writing template into _info.c");
-       }
-       fclose(info);
-}
-
-struct ccanlint no_info = {
-       .name = "No _info.c file",
-       .check = check_no_info,
-       .describe = describe_no_info,
-       .handle = create_info_template,
-};
index 537e955ee69bed43dd62ac1e38fc6057966a6438..96ab0d9dcfe3e7a60e27eccad66c96c4834c7e45 100644 (file)
@@ -40,7 +40,7 @@ static const char *describe_trailing_whitespace(struct manifest *m,
 }
 
 struct ccanlint trailing_whitespace = {
 }
 
 struct ccanlint trailing_whitespace = {
-       .name = "Lines with unnecessary trailing whitespace",
+       .name = "No lines with unnecessary trailing whitespace",
        .total_score = 1,
        .check = check_trailing_whitespace,
        .describe = describe_trailing_whitespace,
        .total_score = 1,
        .check = check_trailing_whitespace,
        .describe = describe_trailing_whitespace,