From: Han-Wen Nienhuys Date: Sun, 21 Jan 2007 14:30:32 +0000 (+0100) Subject: move filename filter out of coverage.scm X-Git-Tag: release/2.11.13-1~9 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=65876aac5109490e821b623413b6a1a4fc4ddc9e;p=lilypond.git move filename filter out of coverage.scm --- diff --git a/scm/coverage.scm b/scm/coverage.scm index 0b799599e1..a7a1b24552 100644 --- a/scm/coverage.scm +++ b/scm/coverage.scm @@ -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* diff --git a/scm/lily.scm b/scm/lily.scm index ebe0cc3224..183b71e490 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -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)