]> git.ozlabs.org Git - ccan/commitdiff
ccanlint: don't use total_score to separate kinds of tests; we have subdirs
authorRusty Russell <rusty@rustcorp.com.au>
Fri, 25 Sep 2009 05:31:46 +0000 (15:01 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Fri, 25 Sep 2009 05:31:46 +0000 (15:01 +0930)
.bzrignore
tools/ccanlint/Makefile
tools/ccanlint/ccanlint.c
tools/ccanlint/ccanlint.h
tools/ccanlint/tests/build_objs.c
tools/ccanlint/tests/compile_tests.c
tools/ccanlint/tests/run_tests.c
tools/tools.h

index 3dfba6e9fc4b27c0359ad511533fb44f56ed4f6c..10cbbc330844183d75b4cc849d9fe494ca1851a6 100644 (file)
@@ -6,7 +6,8 @@ tools/doc_extract
 tools/namespacize
 tools/run_tests
 tools/ccanlint/ccanlint
 tools/namespacize
 tools/run_tests
 tools/ccanlint/ccanlint
-tools/ccanlint/generated-init-tests
+tools/ccanlint/generated-compulsory-tests
+tools/ccanlint/generated-normal-tests
 inter-depends
 test-depends
 lib-depends
 inter-depends
 test-depends
 lib-depends
index a99a6aeb71185efdf0bd6425c9b81d2dfe0355df..dcbd6f9c19b7a8e947984aff9fada5633c4b824a 100644 (file)
@@ -1,6 +1,6 @@
-TEST_CFILES := $(wildcard tools/ccanlint/compulsory_tests/*.c) \
-       $(wildcard tools/ccanlint/tests/*.c)
-TEST_OBJS := $(TEST_CFILES:.c=.o)
+COMPULSORY_TEST_CFILES := $(wildcard tools/ccanlint/compulsory_tests/*.c)
+NORMAL_TEST_CFILES := $(wildcard tools/ccanlint/tests/*.c)
+TEST_OBJS := $(NORMAL_TEST_CFILES:.c=.o) $(COMPULSORY_TEST_CFILES:.c=.o)
 
 CORE_OBJS := tools/ccanlint/ccanlint.o \
        tools/ccanlint/file_analysis.o \
 
 CORE_OBJS := tools/ccanlint/ccanlint.o \
        tools/ccanlint/file_analysis.o \
@@ -13,17 +13,20 @@ CORE_OBJS := tools/ccanlint/ccanlint.o \
 OBJS := $(CORE_OBJS) $(TEST_OBJS)
 
 # FIXME: write a trivial C program to do this
 OBJS := $(CORE_OBJS) $(TEST_OBJS)
 
 # FIXME: write a trivial C program to do this
-tools/ccanlint/generated-init-tests: $(TEST_CFILES)
-       cat $(TEST_CFILES) | grep ^REGISTER_TEST > $@
+tools/ccanlint/generated-normal-tests: $(NORMAL_TEST_CFILES)
+       cat $^ | grep ^REGISTER_TEST > $@
+tools/ccanlint/generated-compulsory-tests: $(COMPULSORY_TEST_CFILES)
+       cat $^ | grep ^REGISTER_TEST > $@
 
 
-$(TEST_OBJS): tools/ccanlint/generated-init-tests
+$(TEST_OBJS): tools/ccanlint/generated-normal-tests tools/ccanlint/generated-compulsory-tests
 
 # Otherwise, ccanlint.c et al. may fail to build
 
 # Otherwise, ccanlint.c et al. may fail to build
-$(CORE_OBJS): tools/ccanlint/generated-init-tests
+$(CORE_OBJS): tools/ccanlint/generated-normal-tests tools/ccanlint/generated-compulsory-tests
 
 tools/ccanlint/ccanlint: $(OBJS)
 
 ccanlint-clean:
 
 tools/ccanlint/ccanlint: $(OBJS)
 
 ccanlint-clean:
-       $(RM) tools/ccanlint/generated-init-tests
+       $(RM) tools/ccanlint/generated-compulsory-tests
+       $(RM) tools/ccanlint/generated-normal-tests
        $(RM) tools/ccanlint/ccanlint
 
        $(RM) tools/ccanlint/ccanlint
 
index be6829c049d8420d5cefd76931ca09bf77a49825..1399edcbc0772dc9eb17a021ab03a772286b88fd 100644 (file)
@@ -160,16 +160,13 @@ static bool run_test(struct ccanlint *i,
        return false;
 }
 
        return false;
 }
 
-static void register_test(struct ccanlint *test, ...)
+static void register_test(struct list_head *h, struct ccanlint *test, ...)
 {
        va_list ap;
        struct ccanlint *depends;
        struct dependent *dchild;
 
 {
        va_list ap;
        struct ccanlint *depends;
        struct dependent *dchild;
 
-       if (!test->total_score)
-               list_add(&compulsory_tests, &test->list);
-       else
-               list_add(&normal_tests, &test->list);
+       list_add(h, &test->list);
 
        va_start(ap, test);
        /* Careful: we might have been initialized by a dependent. */
 
        va_start(ap, test);
        /* Careful: we might have been initialized by a dependent. */
@@ -211,8 +208,11 @@ static void init_tests(void)
        const struct ccanlint *i;
 
 #undef REGISTER_TEST
        const struct ccanlint *i;
 
 #undef REGISTER_TEST
-#define REGISTER_TEST(name, ...) register_test(&name, __VA_ARGS__)
-#include "generated-init-tests"
+#define REGISTER_TEST(name, ...) register_test(&normal_tests, &name, __VA_ARGS__)
+#include "generated-normal-tests"
+#undef REGISTER_TEST
+#define REGISTER_TEST(name, ...) register_test(&compulsory_tests, &name, __VA_ARGS__)
+#include "generated-compulsory-tests"
 
        if (!verbose)
                return;
 
        if (!verbose)
                return;
@@ -289,10 +289,9 @@ int main(int argc, char *argv[])
        if (verbose)
                printf("\nNormal tests:\n");
        score = total_score = 0;
        if (verbose)
                printf("\nNormal tests:\n");
        score = total_score = 0;
-       while ((i = get_next_test(&normal_tests)) != NULL) {
-               if (i->total_score)
-                       run_test(i, summary, &score, &total_score, m);
-       }
+       while ((i = get_next_test(&normal_tests)) != NULL)
+               run_test(i, summary, &score, &total_score, m);
+
        printf("Total score: %u/%u\n", score, total_score);
        return 0;
 }
        printf("Total score: %u/%u\n", score, total_score);
        return 0;
 }
index 271fba9501892b56ff3d9321ebc83e39cdb33afc..c4ae191f835d923d3b9e384abbb7e82e4e74d10e 100644 (file)
@@ -5,7 +5,8 @@
 #include "../doc_extract.h"
 
 #define REGISTER_TEST(name, ...) extern struct ccanlint name
 #include "../doc_extract.h"
 
 #define REGISTER_TEST(name, ...) extern struct ccanlint name
-#include "generated-init-tests"
+#include "generated-compulsory-tests"
+#include "generated-normal-tests"
 #undef REGISTER_TEST
 
 #define REGISTER_TEST(name, ...) 
 #undef REGISTER_TEST
 
 #define REGISTER_TEST(name, ...) 
@@ -41,7 +42,7 @@ struct ccanlint {
        /* Unique name of test */
        const char *name;
 
        /* Unique name of test */
        const char *name;
 
-       /* Total score that this test is worth.  0 means compulsory tests. */
+       /* Total score that this test is worth. */
        unsigned int total_score;
 
        /* Can we run this test?  Return string explaining why, if not. */
        unsigned int total_score;
 
        /* Can we run this test?  Return string explaining why, if not. */
index dc6e4d358f7d11c166754c406615dbabeb81cf11..d932ec74a36145db6e69fba006d639654fbc03bb 100644 (file)
@@ -49,7 +49,6 @@ static void *check_objs_build(struct manifest *m)
        struct ccan_file *i;
 
        /* One point for each obj file. */
        struct ccan_file *i;
 
        /* One point for each obj file. */
-       build_objs.total_score = 0;
        list_for_each(&m->c_files, i, list)
                build_objs.total_score++;
 
        list_for_each(&m->c_files, i, list)
                build_objs.total_score++;
 
@@ -71,7 +70,6 @@ static const char *describe_objs_build(struct manifest *m, void *check_result)
 
 struct ccanlint build_objs = {
        .name = "Module object files can be built",
 
 struct ccanlint build_objs = {
        .name = "Module object files can be built",
-       .total_score = 1,
        .check = check_objs_build,
        .describe = describe_objs_build,
        .can_run = can_build,
        .check = check_objs_build,
        .describe = describe_objs_build,
        .can_run = can_build,
index c9ace30dde687ec0dc889d0019e4bb5f06f592bd..7f0338a4a96906570db3c8518bce73afcf611206 100644 (file)
@@ -83,7 +83,6 @@ static void *do_compile_tests(struct manifest *m)
 
        list_head_init(list);
 
 
        list_head_init(list);
 
-       compile_tests.total_score = 0;
        list_for_each(&m->compile_ok_tests, i, list) {
                compile_tests.total_score++;
                cmdout = compile(list, m, i, false, false);
        list_for_each(&m->compile_ok_tests, i, list) {
                compile_tests.total_score++;
                cmdout = compile(list, m, i, false, false);
@@ -178,7 +177,6 @@ static const char *describe_compile_tests(struct manifest *m,
 
 struct ccanlint compile_tests = {
        .name = "Compile tests succeed",
 
 struct ccanlint compile_tests = {
        .name = "Compile tests succeed",
-       .total_score = 1,
        .score = score_compile_tests,
        .check = do_compile_tests,
        .describe = describe_compile_tests,
        .score = score_compile_tests,
        .check = do_compile_tests,
        .describe = describe_compile_tests,
index e996c4e2607f9e24aab424659b039bc5ccacade6..875ba758e43a70a036d3290c6ecf11effe3bc41c 100644 (file)
@@ -29,7 +29,6 @@ static void *do_run_tests(struct manifest *m)
 
        list_head_init(list);
 
 
        list_head_init(list);
 
-       run_tests.total_score = 0;
        list_for_each(&m->run_tests, i, list) {
                char *testout;
                run_tests.total_score++;
        list_for_each(&m->run_tests, i, list) {
                char *testout;
                run_tests.total_score++;
@@ -80,7 +79,6 @@ static const char *describe_run_tests(struct manifest *m,
 
 struct ccanlint run_tests = {
        .name = "run and api tests run successfully",
 
 struct ccanlint run_tests = {
        .name = "run and api tests run successfully",
-       .total_score = 1,
        .score = score_run_tests,
        .check = do_run_tests,
        .describe = describe_run_tests,
        .score = score_run_tests,
        .check = do_run_tests,
        .describe = describe_run_tests,
index 9fd1e1f6b908e4f7a004d5b89b74198fcef84f04..431a018a8c27b4a5b52fbd7112c5fc043bc88984 100644 (file)
@@ -9,7 +9,7 @@
 #define SPACE_CHARS    " \f\n\r\t\v"
 
 /* FIXME: Remove some -I */
 #define SPACE_CHARS    " \f\n\r\t\v"
 
 /* FIXME: Remove some -I */
-#define CFLAGS "-O3 -Wall -Wundef -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror -Iccan/ -I. -I../.."
+#define CFLAGS "-O3 -Wall -Wundef -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror -Iccan/ -I.. -I../.."
 
 /* This actually compiles and runs the info file to get dependencies. */
 char **get_deps(const void *ctx, const char *dir, const char *name,
 
 /* This actually compiles and runs the info file to get dependencies. */
 char **get_deps(const void *ctx, const char *dir, const char *name,