Commit ca951c94 authored by Rusty Russell's avatar Rusty Russell

ccanlint: print error information even if we pass.

This means we can see messages even if we don't fail; ie. for compiler warnings
once they are no longer fatal.

This means that various tests have to be more careful in not setting
score->error.
parent eaca6b48
......@@ -149,7 +149,7 @@ static bool run_test(struct ccanlint *i,
printf("\n");
}
if (!quiet && !score->pass) {
if ((!quiet && !score->pass) || verbose) {
struct file_error *f;
if (score->error)
......@@ -165,7 +165,7 @@ static bool run_test(struct ccanlint *i,
else
printf("%s\n", f->error);
}
if (i->handle)
if (!quiet && !score->pass && i->handle)
i->handle(m, score);
}
......
......@@ -192,7 +192,6 @@ char *get_symbol_token(void *ctx, const char **line);
/* Similarly for ->doc_sections */
struct list_head *get_ccan_file_docs(struct ccan_file *f);
/* Add an error about this file (and line, if non-zero) to the score struct */
void score_file_error(struct score *, struct ccan_file *f, unsigned line,
const char *error);
......
......@@ -61,7 +61,7 @@ static void extract_examples(struct manifest *m,
unsigned int *timeleft,
struct score *score)
{
struct ccan_file *f;
struct ccan_file *f, *mainh = NULL; /* gcc complains uninitialized */
struct doc_section *d;
bool have_info_example = false, have_header_example = false;
......@@ -81,6 +81,7 @@ static void extract_examples(struct manifest *m,
|| strlen(f->name) != strlen(m->basename) + 2)
continue;
mainh = f;
list_for_each(get_ccan_file_docs(f), d, list) {
if (streq(d->type, "example")) {
score->error = add_example(m, f, keep, d);
......@@ -91,23 +92,21 @@ static void extract_examples(struct manifest *m,
}
}
if (!have_info_example && !have_header_example) {
score->error = "You don't have any Example: sections";
score->score = 0;
} else if (!have_info_example) {
score->error = "You don't have an Example: section in _info";
score->score = 1;
score->pass = true;
} else if (!have_header_example) {
score->error = talloc_asprintf(score,
"You don't have an Example: section in %s.h",
m->basename);
score->score = 1;
score->pass = true;
} else {
if (have_info_example && have_header_example) {
score->score = score->total;
score->pass = true;
return;
}
score->error = "Expect examples in header and _info";
if (!have_info_example)
score_file_error(score, m->info_file, 0, "No Example: section");
if (!have_header_example)
score_file_error(score, mainh, 0, "No Example: section");
score->score = have_info_example + have_header_example;
/* We pass if we find any example. */
score->pass = score->score != 0;
}
struct ccanlint has_examples = {
......
......@@ -90,7 +90,6 @@ static bool check_idem(struct ccan_file *f, struct score *score)
/* FIXME: We assume small headers probably uninteresting. */
return true;
score->error = "Headers are not idempotent";
for (i = 0; i < f->num_lines; i++) {
if (line_info[i].type == DOC_LINE
|| line_info[i].type == COMMENT_LINE)
......@@ -184,8 +183,10 @@ static void check_idempotent(struct manifest *m,
struct ccan_file *f;
list_for_each(&m->h_files, f, list) {
if (!check_idem(f, score))
if (!check_idem(f, score)) {
score->error = "Headers are not idempotent";
return;
}
}
score->pass = true;
score->score = score->total;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment