]> git.donarmstrong.com Git - lilypond.git/commitdiff
move filename filter out of coverage.scm
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 21 Jan 2007 14:30:32 +0000 (15:30 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 21 Jan 2007 14:30:32 +0000 (15:30 +0100)
scm/coverage.scm
scm/lily.scm

index 0b799599e160a78524475c2f37af8fd609368e36..a7a1b2455278121023060245958b63e16f81e399 100644 (file)
@@ -2,22 +2,26 @@
 
 (use-modules (lily)
             (ice-9 rdelim)
+            (ice-9 regex)
             (ice-9 format))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(define-public (coverage:show-all)
+(define-public (coverage:show-all filter?)
+  
   (newline)
   (hash-fold
    (lambda (key val acc)
-     (if (string-contains key "lilypond")
+     (if (filter? key)
         (begin
           (format #t
                 "
 Coverage for file: ~a
 "
                 key)
-        (display-coverage key val)))
+        (display-coverage key val
+                          (format #f "~a.cov" (basename key))
+                          )))
      #t)
    #t
    coverage-table))
@@ -27,6 +31,7 @@ Coverage for file: ~a
   (trap-enable 'memoize-symbol)
   (trap-enable 'traps))
 
+     
 (define-public (coverage:disable)
   (trap-set! memoize-symbol-handler #f)
   (trap-disable 'memoize-symbol))
@@ -38,19 +43,37 @@ Coverage for file: ~a
 (define (read-lines port)
   (string-split (read-delimited "" port) #\newline))
 
-(define (display-coverage file vec)
+(define (display-coverage file vec out-file)
   (let*
-      ((lines (read-lines (open-file file "r"))))
+      ((lines (read-lines (open-file file "r")))
+       (format-str "~8@a: ~5@a:~a\n")
+       (out (if out-file (open-output-file out-file)
+               (current-output-port))))
 
+    (format out format-str "-" 0 (format #f "Source:~a" file))
     (do
        ((i 0 (1+ i))
         (l lines (cdr l)))
-       ((or (null? l) (>= i (vector-length vec))))
-
-      (display (format #f "~8a: ~a\n"
-                      (if (vector-ref vec i)
-                          "#t"
-                          "") (car l))))))
+       ((or (null? l) ))
+
+      (format out format-str
+                      (cond
+                       ((and (< i (vector-length vec)) (vector-ref vec i)) "1")
+                       ((and (string-contains file ".ly") (string-match "^[ \t]*%.*$" (car l)))
+
+                        "-")
+                       ((string-match  "^[ \t]*[()'`,]*$" (car l))
+
+                        "-")
+                       ((string-match  "^[ \t]*;.*$" (car l))
+                        (format (current-output-port) "~a l=~a, m=~a\n"
+                                i
+                                (car l) (string-match  "^[ \t]*;.*$"  (car l)))
+
+                        "-")
+                       (else "0"))
+                      (1+ i)
+                      (car l)))))
 
 (define (record-coverage key cont exp env)
   (let*
index ebe0cc322428cfabde38ecd652abd0cfbd23131d..183b71e4902b1f46d9ec2ddd68a81fc2e2343f20 100644 (file)
@@ -629,7 +629,8 @@ The syntax is the same as `define*-public'."
     (if (ly:get-option 'trace-scheme-coverage)
        (begin
          (coverage:disable)
-         (coverage:show-all)))
+         (coverage:show-all (lambda (f) (string-contains f "lilypond"))
+                            )))
          
     
     (if (pair? failed)