unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Jessica Tallon <tsyesika@tsyesika.se>
To: 54911@debbugs.gnu.org
Subject: bug#54911: Missing modules argument for coverage-data->lcov
Date: Wed, 13 Apr 2022 16:01:27 +0200	[thread overview]
Message-ID: <87tuax6pp7.fsf@tsyesika.se> (raw)

[-- Attachment #1: Type: text/plain, Size: 789 bytes --]


Hello,

I noticed the documentation specify that the `coverage-data->lcov`
function should be able to take modules to limit the scope of the data
that's coverted to lcov. From the docs:

 -- Scheme Procedure: coverage-data->lcov data port #:key modules
     Traverse code coverage information DATA, as obtained with
     ‘with-code-coverage’, and write coverage information to port in the
     ‘.info’ format used by LCOV
     (http://ltp.sourceforge.net/coverage/lcov.php).  The report will
     include all of MODULES (or, by default, all the currently loaded
     modules) even if their code was not executed.

However I noticed that this didn't match the code. I've attached a patch
which implements the behavour described in the docs.

Thanks,
Jessica.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch adding missing modules argument --]
[-- Type: text/x-patch, Size: 2104 bytes --]

From 828daf200539d3a642fcf8210df7b58aa0d5fede Mon Sep 17 00:00:00 2001
From: Jessica Tallon <tsyesika@tsyesika.se>
Date: Wed, 13 Apr 2022 15:57:24 +0200
Subject: [PATCH] Fix 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 | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/module/system/vm/coverage.scm b/module/system/vm/coverage.scm
index 0d51e261a..f1d65cc6c 100644
--- a/module/system/vm/coverage.scm
+++ b/module/system/vm/coverage.scm
@@ -300,7 +300,7 @@ was loaded at the time DATA was collected."
 ;;; 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
 `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
@@ -325,6 +325,12 @@ gathered, even if their code was not executed."
 
   ;; Output per-file coverage data.
   (format port "TN:~%")
+  (define source-files
+    (filter
+     (lambda (file)
+       (or (not modules) (member file modules)))
+     (instrumented-source-files data)))
+
   (for-each (lambda (file)
               (let ((path (search-path %load-path file)))
                 (if (string? path)
@@ -345,6 +351,6 @@ gathered, even if their code was not executed."
                       (format port "end_of_record~%"))
                     (begin
                       (format (current-error-port)
-                              "skipping unknown source file: ~a~%"
+                              "skipping source file: ~a~%"
                               file)))))
-            (instrumented-source-files data)))
+            source-files))
-- 
2.35.1


             reply	other threads:[~2022-04-13 14:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-13 14:01 Jessica Tallon [this message]
2022-06-16  8:03 ` bug#54911: Missing modules argument for coverage-data->lcov Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tuax6pp7.fsf@tsyesika.se \
    --to=tsyesika@tsyesika.se \
    --cc=54911@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).