I run SWI-Prolog v8.0.3 (32 bit) on a W10 box. I am writing a little compiler and I want to provide comprehensive test case coverage. I use PLUnit pretty much according to the documentation - or so I thought:
- I have files foo.pl for a module with a set of grammatical rules, exporting these rules
- I have files foo_TEST.pl that include the rule file by ‘use_module(foo)’, and declare the test cases.
- I have a file test.pl that calls all the individual tests by ‘:- consult(‘foo_TEST.pl’)’ for each.
When running 'show_coverage(test.pl), I do get the output I want, but also lots of stuff that I think shouldn’t be there. Here’s a sample (line numbers added for reference).
1 c:/_tools/momat/app/monotype/src/grammar/foo.pl 43 97.7 0.0
2 …ols/momat/app/monotype/src/grammar/foo_test.pl 110 50.0 0.0
3 …ols/momat/app/monotype/src/grammar/bar_test.pl 110 50.0 0.0
4 c:/program files (x86)/swipl803-1-w32/library/option.pl 40 5.0 2.5
5 c:/program files (x86)/swipl803-1-w32/library/plunit.pl 261 0.4 0.0
1 - I expect lines like this
2 - I kind of get why this is here, but it does look awkward.
3 - And when “:-consult(bar_TEST.pl)” is commented out in test.pl I still get this …why?
4 - This I really don’t get. Why would I be interested in the test coverage of basic libraries?
5 - And this is really weird. I think this shouldn’t be here.
So, is this all on purpose and I just have strange expectations?
Or am I doing this wrong? If so, how to fix it? It would be great to have a working, exemplary demo project somewhere that I could consult for inspiration (sorry for the pun).
I see that JW uses “:-test_foo.” in PLUnit - summary report, suggesting that file “foo_TEST.pl” should define “test_foo/0” doing - what exactly? So I guess there’s a different file organization that is supposed to be used?
Thanks in advance for enlightenment and tips!