]> git.donarmstrong.com Git - lilypond.git/commitdiff
add scheme coverage analysis to build-coverage.sh
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 22 Jan 2007 19:38:20 +0000 (20:38 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 22 Jan 2007 19:38:20 +0000 (20:38 +0100)
buildscripts/build-coverage.sh
buildscripts/coverage.py

index 6e543860a3fc7ee0faa095c6aa08f6801d6520df..765818300ddeaf54fcbf6eeec2632932acf5daac 100755 (executable)
@@ -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
index a3b68dd58d074230c5fb5598c1978ce5f15e4da4..668b6a0043fa4c3d65f6158c69b416ff23e0df6b 100644 (file)
@@ -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]