From: Han-Wen Nienhuys Date: Mon, 22 Jan 2007 19:38:20 +0000 (+0100) Subject: add scheme coverage analysis to build-coverage.sh X-Git-Tag: release/2.11.14-1~67 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=305f1a98bad22056fe6c343dd45fd50f94269503;p=lilypond.git add scheme coverage analysis to build-coverage.sh --- diff --git a/buildscripts/build-coverage.sh b/buildscripts/build-coverage.sh index 6e543860a3..765818300d 100755 --- a/buildscripts/build-coverage.sh +++ b/buildscripts/build-coverage.sh @@ -22,7 +22,7 @@ mkdir -p scripts/out-cov/ touch scripts/out-cov/midi2ly.1 make conf=cov -j2 && \ make conf=cov test-clean OUT_TEST=testcov LILYPOND_JOBS= && \ - make conf=cov test OUT_TEST=testcov LILYPOND_JOBS= + make conf=cov test OUT_TEST=testcov LILYPOND_JOBS='-dtrace-scheme-coverage ' if test "$?" != "0"; then tail -100 out-cov/test-run.log @@ -37,6 +37,8 @@ mkdir $resultdir cd $resultdir ln $depth/lily/* . +ln $depth/scm/*.scm . +ln $depth/ly/*.ly . ln $depth/lily/out-cov/*[ch] . mkdir include ln $depth/lily/include/* include/ @@ -49,6 +51,7 @@ done python $depth/buildscripts/coverage.py --uncovered *.cc > uncovered.txt python $depth/buildscripts/coverage.py --hotspots *.cc > hotspots.txt python $depth/buildscripts/coverage.py --summary *.cc > summary.txt +python $depth/buildscripts/coverage.py --uncovered *.scm > uncovered-scheme.txt head -20 summary.txt @@ -57,6 +60,7 @@ results in out/coverage-results/summary.txt out/coverage-results/uncovered.txt + out/coverage-results/uncovered-scheme.txt out/coverage-results/hotspots.txt EOF diff --git a/buildscripts/coverage.py b/buildscripts/coverage.py index a3b68dd58d..668b6a0043 100644 --- a/buildscripts/coverage.py +++ b/buildscripts/coverage.py @@ -69,6 +69,18 @@ class Chunk: cov = '' sys.stdout.write ('%8s:%8d:%s' % (cov, n, l)) + def uncovered_score (self): + return length (self) + +class SchemeChunk (Chunk): + def uncovered_score (self): + text = self.text () + if (text.startswith ('(define') + and not text.startswith ('(define (')): + return 0 + + return len ([l for (c,n,l) in self.lines() if (c == 0)]) + def read_gcov (f): ls = [] @@ -120,28 +132,22 @@ def get_scm_chunks (ls, file): chunk = [] def new_chunk (): - nums = [n-1 for (n, l) in chunk] - chunks.append (Chunk ((min (nums), max (nums)+1), - last_c, ls, file)) - chunk = [] + if chunk: + nums = [n-1 for (n, l) in chunk] + chunks.append (SchemeChunk ((min (nums), max (nums)+1), + max (last_c, 0), ls, file)) + chunk[:] = [] last_c = -1 - for (c, n, l) in ls: - - if l.startswith ('(define'): + for (cov_count, line_number, line) in ls: + if line.startswith ('(define'): new_chunk () - last_c = - continue + last_c = -1 - if not (c == last_c or c < 0): + chunk.append ((line_number, line)) + if cov_count >= 0: + last_c = cov_count - - if chunk and last_c >= 0: - - chunk.append ((n,l)) - if c >= 0: - last_c = c - return chunks def widen_chunk (ch, ls): @@ -218,7 +224,7 @@ def main (): if options.uncovered: chunks = filter_uncovered (chunks) - chunks = [(c.length (), c) for c in chunks] + chunks = [(c.uncovered_score (), c) for c in chunks] elif options.hotspots: chunks = [((c.coverage_count, -c.length()), c) for c in chunks]