Browse Source

ccanlint: don't use total_score to separate kinds of tests; we have subdirs

Rusty Russell 16 years ago
parent
commit
156dfda864

+ 2 - 1
.bzrignore

@@ -6,7 +6,8 @@ tools/doc_extract
 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

+ 11 - 8
tools/ccanlint/Makefile

@@ -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 \
@@ -13,17 +13,20 @@ CORE_OBJS := tools/ccanlint/ccanlint.o \
 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
-$(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:
-	$(RM) tools/ccanlint/generated-init-tests
+	$(RM) tools/ccanlint/generated-compulsory-tests
+	$(RM) tools/ccanlint/generated-normal-tests
 	$(RM) tools/ccanlint/ccanlint
 

+ 10 - 11
tools/ccanlint/ccanlint.c

@@ -160,16 +160,13 @@ static bool run_test(struct ccanlint *i,
 	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;
 
-	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. */
@@ -211,8 +208,11 @@ static void init_tests(void)
 	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;
@@ -289,10 +289,9 @@ int main(int argc, char *argv[])
 	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;
 }

+ 3 - 2
tools/ccanlint/ccanlint.h

@@ -5,7 +5,8 @@
 #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, ...) 
@@ -41,7 +42,7 @@ struct ccanlint {
 	/* 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. */

+ 0 - 2
tools/ccanlint/tests/build_objs.c

@@ -49,7 +49,6 @@ static void *check_objs_build(struct manifest *m)
 	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++;
 
@@ -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",
-	.total_score = 1,
 	.check = check_objs_build,
 	.describe = describe_objs_build,
 	.can_run = can_build,

+ 0 - 2
tools/ccanlint/tests/compile_tests.c

@@ -83,7 +83,6 @@ static void *do_compile_tests(struct manifest *m)
 
 	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);
@@ -178,7 +177,6 @@ static const char *describe_compile_tests(struct manifest *m,
 
 struct ccanlint compile_tests = {
 	.name = "Compile tests succeed",
-	.total_score = 1,
 	.score = score_compile_tests,
 	.check = do_compile_tests,
 	.describe = describe_compile_tests,

+ 0 - 2
tools/ccanlint/tests/run_tests.c

@@ -29,7 +29,6 @@ static void *do_run_tests(struct manifest *m)
 
 	list_head_init(list);
 
-	run_tests.total_score = 0;
 	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",
-	.total_score = 1,
 	.score = score_run_tests,
 	.check = do_run_tests,
 	.describe = describe_run_tests,

+ 1 - 1
tools/tools.h

@@ -9,7 +9,7 @@
 #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,