1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Add missing #:modules argument for coverage-data->lcov.

The code coverage function `coverage-data->lcov` has a documented
`modules` argument, however that was missing from the source. I have
added it so when supplied it only converts the coverage data for the
supplied modules. If not supplied it defaults the old behavour of
including all the modules currently loaded.

* module/system/vm/coverage.scm (coverage-data->lcov): Add #:modules
parameter and honor it.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Jessica Tallon 2022-04-13 15:57:24 +02:00 committed by Ludovic Courtès
parent 01b686b701
commit 4456245753

View file

@ -300,7 +300,7 @@ was loaded at the time DATA was collected."
;;; LCOV output. ;;; LCOV output.
;;; ;;;
(define* (coverage-data->lcov data port) (define* (coverage-data->lcov data port #:key (modules #f))
"Traverse code coverage information DATA, as obtained with "Traverse code coverage information DATA, as obtained with
`with-code-coverage', and write coverage information in the LCOV format to PORT. `with-code-coverage', and write coverage information in the LCOV format to PORT.
The report will include all the modules loaded at the time coverage data was The report will include all the modules loaded at the time coverage data was
@ -325,6 +325,12 @@ gathered, even if their code was not executed."
;; Output per-file coverage data. ;; Output per-file coverage data.
(format port "TN:~%") (format port "TN:~%")
(define source-files
(filter
(lambda (file)
(or (not modules) (member file modules)))
(instrumented-source-files data)))
(for-each (lambda (file) (for-each (lambda (file)
(let ((path (search-path %load-path file))) (let ((path (search-path %load-path file)))
(if (string? path) (if (string? path)
@ -345,6 +351,6 @@ gathered, even if their code was not executed."
(format port "end_of_record~%")) (format port "end_of_record~%"))
(begin (begin
(format (current-error-port) (format (current-error-port)
"skipping unknown source file: ~a~%" "skipping source file: ~a~%"
file))))) file)))))
(instrumented-source-files data))) source-files))