Discussion:
Help me setup test coverage
amirouche
2018-03-06 19:07:54 UTC
Permalink
Hello all!


I have some difficulties setting up test coverage.

Here the procedure I use that inspired from guile/test-suite/guile-test:


(use-modules (system vm coverage)
(system vm vm))


(define (run-test-with-coverage test)
(call-with-values (lambda ()
(with-code-coverage
(lambda ()
(load test))))
(lambda (data result)
(let ((port (open-output-file (string-append test ".info"))))
(coverage-data->lcov data port)
(close port)))))

(run-test-with-coverage (cadr (program-arguments)))


It takes the name of a module as first argument and will load that file
inside 'with-code-coverage' and write the lcov .info file.

I've setup a simple example, it requires guile and lcov for genhtml.

You can reproduce the issue as follow:

$ git clone https://github.com/a-guile-mind/coverage
$ cd coverage
$ make
test echo
Overall coverage rate:
lines......: 0.0% (0 of 9164 lines)
functions..: no data found

As you can see in the output, no lines seems to be visited by the vm.
The output should be at least one, the line inside test.scm.

What I am doing wrong?

Thanks in advance!
Ludovic Courtès
2018-03-12 14:55:36 UTC
Permalink
Hello,
Post by amirouche
I've setup a simple example, it requires guile and lcov for genhtml.
$ git clone https://github.com/a-guile-mind/coverage
$ cd coverage
$ make
test echo
lines......: 0.0% (0 of 9164 lines)
functions..: no data found
As you can see in the output, no lines seems to be visited by the vm.
The output should be at least one, the line inside test.scm.
I think you need to use the VM’s “debug” engine, the one you get when
invoking “guile --debug”.

HTH!

Ludo’.
amirouche
2018-03-12 22:40:52 UTC
Permalink
Post by Ludovic Courtès
Hello,
Post by amirouche
I've setup a simple example, it requires guile and lcov for genhtml.
$ git clone https://github.com/a-guile-mind/coverage
$ cd coverage
$ make
test echo
lines......: 0.0% (0 of 9164 lines)
functions..: no data found
As you can see in the output, no lines seems to be visited by the vm.
The output should be at least one, the line inside test.scm.
I think you need to use the VM’s “debug” engine, the one you get when
invoking “guile --debug”.
HTH!
Indeed, thanks a lot, I really appreciate your input as usual. I updated
the code in the repository [0]

[0]
https://github.com/a-guile-mind/coverage/commit/d66861f949bcd6eea680506caee2268b48fcb75a

There is still a minor annoyance. In the manual [1] there is a 'modules'
keyword documented for the procedure 'coverage-data->lcov' but in the
current code that argument is gone [2]

[1]
https://www.gnu.org/software/guile/manual/html_node/Code-Coverage.html#Code-Coverage
[2]
http://git.savannah.gnu.org/cgit/guile.git/tree/module/system/vm/coverage.scm?h=stable-2.2#n301

Is there a known workaround to get the coverage only for a given module?

TIA!
Ludovic Courtès
2018-03-13 10:54:29 UTC
Permalink
Hello,
Post by amirouche
Post by Ludovic Courtès
I think you need to use the VM’s “debug” engine, the one you get when
invoking “guile --debug”.
HTH!
Indeed, thanks a lot, I really appreciate your input as usual. I updated
the code in the repository [0]
[0]
https://github.com/a-guile-mind/coverage/commit/d66861f949bcd6eea680506caee2268b48fcb75a
There is still a minor annoyance. In the manual [1] there is a 'modules'
keyword documented for the procedure 'coverage-data->lcov' but in the
current code that argument is gone [2]
I don’t know how to fix it, but there may be other issues: commit
581a4eb82b1534970060e3cbd79b9a96d351edf9 commented out a few things
there, with an explanation of what needs to be done to re-enable it.

Would you like to give it a go?

Ludo’.

Loading...