From a8e0cfb1b02bd89850540f60232fc52fb0a11500 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sun, 26 Sep 2010 15:28:11 +0930 Subject: [PATCH] ccanlint: handle gcov where there's actually no C code Macro packages do this. --- tools/ccanlint/ccanlint.c | 2 +- tools/ccanlint/tests/run-coverage.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/ccanlint/ccanlint.c b/tools/ccanlint/ccanlint.c index 8f4c5fe..3b7dceb 100644 --- a/tools/ccanlint/ccanlint.c +++ b/tools/ccanlint/ccanlint.c @@ -150,7 +150,7 @@ static bool run_test(struct ccanlint *i, else this_score = 0; - bad = (this_score == 0); + bad = (this_score == 0 && i->total_score != 0); good = (this_score >= i->total_score); if (verbose || (bad && !quiet)) { diff --git a/tools/ccanlint/tests/run-coverage.c b/tools/ccanlint/tests/run-coverage.c index a46b02e..886aebd 100644 --- a/tools/ccanlint/tests/run-coverage.c +++ b/tools/ccanlint/tests/run-coverage.c @@ -47,7 +47,7 @@ static void analyze_coverage(struct manifest *m, unsigned int i, total_lines = 0; bool lines_matter = false; - /* FIXME: We assume GCOV mentions all files! + /* Output looks like: File '../../../ccan/tdb2/private.h' Lines executed:0.00% of 8 @@ -99,10 +99,13 @@ static void analyze_coverage(struct manifest *m, } } - /* Nothing covered? */ - if (total_lines == 0) + /* Nothing covered? We can't tell if there's a source file which + * was never executed, or there really is no code to execute, so + * assume the latter: this test deserves no score. */ + if (total_lines == 0) { res->uncovered = 1.0; - else + run_coverage_tests.total_score = 0; + } else res->uncovered = 1.0 - covered_lines / total_lines; } -- 2.39.2