X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=tools%2Fccanlint%2Ftests%2Fcompile_test_helpers.c;h=0ad5a7e67cc7847fb9bbc9c568ef403b7752eb7d;hb=2926cafb52b9d95646d9dafa877d53f2368d8b2c;hp=e2e3ed843f82a9477da9a2ffef48179e1aea19a7;hpb=7a163ea2dcafc056fdafc8c71ef011e2bfdbeb65;p=ccan diff --git a/tools/ccanlint/tests/compile_test_helpers.c b/tools/ccanlint/tests/compile_test_helpers.c index e2e3ed84..0ad5a7e6 100644 --- a/tools/ccanlint/tests/compile_test_helpers.c +++ b/tools/ccanlint/tests/compile_test_helpers.c @@ -21,13 +21,14 @@ static const char *can_run(struct manifest *m) return NULL; } -static char *compile(struct manifest *m, - bool keep, - struct ccan_file *cfile) +static bool compile(struct manifest *m, + bool keep, + struct ccan_file *cfile, + char **output) { cfile->compiled = maybe_temp_file(m, ".o", keep, cfile->fullname); return compile_object(m, cfile->fullname, ccan_dir, "", - cfile->compiled); + cfile->compiled, output); } static void do_compile_test_helpers(struct manifest *m, @@ -36,29 +37,39 @@ static void do_compile_test_helpers(struct manifest *m, struct score *score) { struct ccan_file *i; + bool errors = false, warnings = false; if (list_empty(&m->other_test_c_files)) score->total = 0; + else + score->total = 2; list_for_each(&m->other_test_c_files, i, list) { - char *cmdout = compile(m, keep, i); - if (cmdout) { + char *cmdout; + + if (!compile(m, keep, i, &cmdout)) { + errors = true; score->error = "Failed to compile helper C files"; score_file_error(score, i, 0, cmdout); + } else if (!streq(cmdout, "")) { + warnings = true; + score->error = "Helper C files gave warnings"; + score_file_error(score, i, 0, cmdout); } } - if (!score->error) { + if (!errors) { score->pass = true; - score->score = score->total; + score->score = score->total - warnings; } } -struct ccanlint compile_test_helpers = { - .key = "compile-helpers", +struct ccanlint tests_helpers_compile = { + .key = "tests_helpers_compile", .name = "Module test helper objects compile", .check = do_compile_test_helpers, .can_run = can_run, + .needs = "depends_build tests_exist" }; -REGISTER_TEST(compile_test_helpers, &depends_built, &has_tests, NULL); +REGISTER_TEST(tests_helpers_compile);