]> git.ozlabs.org Git - ccan/blobdiff - tools/ccanlint/ccanlint.c
ccanlint: exit with non-zero exit status if a test fails.
[ccan] / tools / ccanlint / ccanlint.c
index 291a151842e0ce0d1126ae8ce6250ad68dc8dc48..e3d99c79a7b72bda874466b48d427b5df2dad65c 100644 (file)
@@ -161,9 +161,9 @@ static bool run_test(struct ccanlint *i,
                        printf("%s%s", score->error,
                               strends(score->error, "\n") ? "" : "\n");
                }
-               if (!quiet && !score->pass && i->handle)
-                       i->handle(m, score);
        }
+       if (!quiet && score->score < score->total && i->handle)
+               i->handle(m, score);
 
        *running_score += score->score;
        *running_total += score->total;
@@ -584,7 +584,7 @@ static char *opt_set_const_charp(const char *arg, const char **p)
 
 int main(int argc, char *argv[])
 {
-       bool summary = false;
+       bool summary = false, pass = true;
        unsigned int score = 0, total_score = 0;
        struct manifest *m;
        struct ccanlint *i;
@@ -675,8 +675,8 @@ int main(int argc, char *argv[])
                add_info_options(m->info_file, !target);
 
        while ((i = get_next_test(&normal_tests)) != NULL)
-               run_test(i, summary, &score, &total_score, m);
+               pass &= run_test(i, summary, &score, &total_score, m);
 
        printf("%sTotal score: %u/%u\n", prefix, score, total_score);
-       return 0;
+       return pass ? 0 : 1;
 }