1 #include <tools/ccanlint/ccanlint.h>
2 #include <tools/tools.h>
3 #include <ccan/str/str.h>
15 #include "reduce_features.h"
17 static const char *can_run(struct manifest *m)
20 return "Safe mode enabled";
24 static bool compile(struct manifest *m,
25 struct ccan_file *cfile,
27 enum compile_type ctype,
30 cfile->compiled[ctype] = temp_file(m, ".o", cfile->fullname);
31 return compile_object(m, cfile->fullname, ccan_dir, compiler, flags,
32 cfile->compiled[ctype], output);
35 static void compile_test_helpers(struct manifest *m,
36 unsigned int *timeleft,
39 enum compile_type ctype)
42 bool errors = false, warnings = false;
44 if (list_empty(&m->other_test_c_files))
49 list_for_each(&m->other_test_c_files, i, list) {
52 if (!compile(m, i, flags, ctype, &cmdout)) {
54 score_file_error(score, i, 0, "Compile failed:\n%s",
56 } else if (!streq(cmdout, "")) {
58 score_file_error(score, i, 0,
59 "Compile gave warnings:\n%s", cmdout);
65 score->score = score->total - warnings;
69 static void do_compile_test_helpers(struct manifest *m,
70 unsigned int *timeleft,
73 compile_test_helpers(m, timeleft, score, cflags, COMPILE_NORMAL);
76 struct ccanlint tests_helpers_compile = {
77 .key = "tests_helpers_compile",
78 .name = "Module test helper objects compile",
79 .check = do_compile_test_helpers,
81 .needs = "depends_build tests_exist"
84 REGISTER_TEST(tests_helpers_compile);
86 static const char *features_reduced(struct manifest *m)
88 if (features_were_reduced)
90 return "No features to turn off";
93 static void do_compile_test_helpers_without_features(struct manifest *m,
94 unsigned int *timeleft,
99 flags = tal_fmt(score, "%s %s", cflags, REDUCE_FEATURES_FLAGS);
101 compile_test_helpers(m, timeleft, score, flags, COMPILE_NOFEAT);
104 struct ccanlint tests_helpers_compile_without_features = {
105 .key = "tests_helpers_compile_without_features",
106 .name = "Module tests helpers compile (without features)",
107 .check = do_compile_test_helpers_without_features,
108 .can_run = features_reduced,
109 .needs = "depends_build_without_features tests_exist"
111 REGISTER_TEST(tests_helpers_compile_without_features);