X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fexamples_compile.c;h=578805fe0c62a23db549a6e54e6fb0018980a15a;hp=ff9e529b645a8d46b39f4c4a2e2c976221402905;hb=fee8416f9d5c23f05d0c4fc57cfb56aaf91c0769;hpb=f9423c171395571f9880286190d9cf63da147668 diff --git a/tools/ccanlint/tests/examples_compile.c b/tools/ccanlint/tests/examples_compile.c index ff9e529b..578805fe 100644 --- a/tools/ccanlint/tests/examples_compile.c +++ b/tools/ccanlint/tests/examples_compile.c @@ -122,6 +122,9 @@ static bool compile(const void *ctx, if (!compile_and_link(ctx, file->fullname, ccan_dir, obj_list(m, file), "", lib_list(m), file->compiled, output)) { + /* Don't keep failures. */ + if (keep) + unlink(file->compiled); talloc_free(file->compiled); file->compiled = NULL; return false; @@ -542,25 +545,23 @@ static void build_examples(struct manifest *m, bool keep, prev = lines[j]; score->score++; warnings = true; - score->error = "Compiling extracted example" - " gave warnings"; - error = talloc_asprintf(score, - "Example:\n" - "%s\n" - "Compiler:\n" - "%s", - get_ccan_file_contents(file[j]), - err[j]); - score_file_error(score, file[j], 0, error); + score_file_error(score, file[j], 0, + "Compiling extracted example" + " gave warnings:\n" + "Example:\n" + "%s\n" + "Compiler:\n" + "%s", + get_ccan_file_contents(file[j]), + err[j]); goto next; } } score->pass = false; - score->error = "Compiling extracted examples failed"; if (!verbose) { if (num == 3) - error = "Standalone, adding headers, " + error = "Compiling standalone, adding headers, " "and including previous " "example all failed"; else @@ -598,7 +599,7 @@ static void build_examples(struct manifest *m, bool keep, err[1]); } } - score_file_error(score, i, 0, error); + score_file_error(score, i, 0, "%s", error); /* This didn't work, so not a candidate for combining. */ prev = NULL; @@ -619,6 +620,7 @@ struct ccanlint examples_compile = { .name = "Module examples compile", .check = build_examples, .can_run = can_run, + .needs = "examples_exist module_builds" }; -REGISTER_TEST(examples_compile, &has_examples, &build, NULL); +REGISTER_TEST(examples_compile);