]> git.ozlabs.org Git - ccan/commitdiff
ccanlint: handle gcov where there's actually no C code
authorRusty Russell <rusty@rustcorp.com.au>
Sun, 26 Sep 2010 05:58:11 +0000 (15:28 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Sun, 26 Sep 2010 05:58:11 +0000 (15:28 +0930)
Macro packages do this.

tools/ccanlint/ccanlint.c
tools/ccanlint/tests/run-coverage.c

index 8f4c5fe0aa959c8a410f004307735da78543ac72..3b7dceb23ababae98ec458d29934a49009d79523 100644 (file)
@@ -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)) {
index a46b02e0722beea2941ee6aa2b184979f3cff72d..886aebd54424b9019eb212eca4a91e649c799dd7 100644 (file)
@@ -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;
 }