From a2b6d4fe6259e07a1bee7f497966242124718a1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Wed, 18 Oct 2023 05:21:21 +0200 Subject: Include non-touched file in coverage report. The recent rewrite where coverage reports where limited to explictly mentioned files lead to non-covered files being completely left out. This re-introduces them with 0% coverage, noted on the second line (to hopefully indicate that something is amiss). --- testrunner.scm | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/testrunner.scm b/testrunner.scm index 7ae577f7..014dd096 100755 --- a/testrunner.scm +++ b/testrunner.scm @@ -33,6 +33,8 @@ exec "$GUILE" --debug --no-auto-compile -e main -s "$0" "$@" (hnh test util) ((hnh util io) :select (displayln)) (crypto) + (ice-9 popen) + (ice-9 rdelim) (ice-9 getopt-long) (ice-9 control) (ice-9 format)) @@ -273,6 +275,22 @@ Flags: (read port))) +;;; TODO replace this with native Guile variant +(define (all-files-under-dir dir) + (let ((pipe (open-pipe* + OPEN_READ + "find" dir + "-type" "f" + "-name" "*.scm" + "-exec" "realpath" "--zero" "{}" ";"))) + (let loop ((done '())) + (let ((line (read-delimited "\0" pipe))) + (if (eof-object? line) + (begin + (close-pipe pipe) + done) + (loop (cons line done))))))) + (define (main args) (define options (getopt-long args option-spec)) @@ -347,11 +365,23 @@ Flags: (stack->list results)))))) + (define uncovered-files + (lset-difference! string=? + (all-files-under-dir "module/") + (map filename merged-coverages))) + (unless (null? merged-coverages) (with-output-to-file coverage (lambda () (display "TN:") (newline) - (for-each output-coverage merged-coverages)))) + (for-each output-coverage merged-coverages) + (for-each output-coverage + (map (lambda (filename) + (coverage-info filename: filename + lines: '((2 . 0)) + total-lines: 1 + hit-lines: 0)) + uncovered-files))))) (format #t "~%== Gathered errors ==~%") (let loop () -- cgit v1.2.3