Commit b6425505 authored by Rusty Russell's avatar Rusty Russell

ccanlint: really fix failing test logic.

Some of the compulsory tests don't have a total_score; treat that as "1".
And don't print out a score if the total is <= 1.
parent 29c59e05
...@@ -107,7 +107,7 @@ static bool run_test(struct ccanlint *i, ...@@ -107,7 +107,7 @@ static bool run_test(struct ccanlint *i,
struct manifest *m) struct manifest *m)
{ {
void *result; void *result;
unsigned int this_score, timeleft; unsigned int this_score, max_score, timeleft;
const struct dependent *d; const struct dependent *d;
const char *skip; const char *skip;
bool bad, good; bool bad, good;
...@@ -143,22 +143,25 @@ static bool run_test(struct ccanlint *i, ...@@ -143,22 +143,25 @@ static bool run_test(struct ccanlint *i,
goto skip; goto skip;
} }
max_score = i->total_score;
if (!max_score)
max_score = 1;
if (!result) if (!result)
this_score = i->total_score ? i->total_score : 1; this_score = max_score;
else if (i->score) else if (i->score)
this_score = i->score(m, result); this_score = i->score(m, result);
else else
this_score = 0; this_score = 0;
bad = (this_score == 0 && i->total_score != 0); bad = (this_score == 0);
good = (this_score >= i->total_score); good = (this_score >= max_score);
if (verbose || (bad && !quiet)) { if (verbose || (!good && !quiet)) {
printf(" %s: %s", i->name, printf(" %s: %s", i->name,
bad ? "FAIL" : good ? "PASS" : "PARTIAL"); bad ? "FAIL" : good ? "PASS" : "PARTIAL");
if (i->total_score) if (max_score > 1)
printf(" (+%u/%u)", printf(" (+%u/%u)", this_score, max_score);
this_score, i->total_score);
printf("\n"); printf("\n");
} }
...@@ -185,7 +188,7 @@ static bool run_test(struct ccanlint *i, ...@@ -185,7 +188,7 @@ static bool run_test(struct ccanlint *i,
d->dependent->skip_fail = true; d->dependent->skip_fail = true;
} }
} }
return !bad; return good;
} }
static void register_test(struct list_head *h, struct ccanlint *test, ...) static void register_test(struct list_head *h, struct ccanlint *test, ...)
......
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