www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Cumulative code coverage?

reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
Is it possible to get cumulative code coverage using dmd? I.e.,
accumulate code coverage stats over a series of runs from an external
test suite.  Currently, it seems that compiling with -cov will just
overwrite the *.lst files from previous runs.  Do I have to merge the
.lst files externally?

I'm currently writing an external test suite for one of my projects, and
obviously, each individual test isn't going to cover the entire code.
So the idea is to write a series of tests that cumulatively test all
code paths.


T

-- 
"Holy war is an oxymoron." -- Lazarus Long
Mar 21 2018
parent reply Seb <seb wilzba.ch> writes:
On Wednesday, 21 March 2018 at 16:39:48 UTC, H. S. Teoh wrote:
 Is it possible to get cumulative code coverage using dmd? I.e., 
 accumulate code coverage stats over a series of runs from an 
 external test suite.  Currently, it seems that compiling with 
 -cov will just overwrite the *.lst files from previous runs.  
 Do I have to merge the .lst files externally?

 I'm currently writing an external test suite for one of my 
 projects, and obviously, each individual test isn't going to 
 cover the entire code. So the idea is to write a series of 
 tests that cumulatively test all code paths.


 T
Yes, either set dmd_coverSetMerge(true) or pass --DRT-covopt "merge:1" to your program. You can also set the environment variable DRT_COVOPT, but I think you need to enable this by setting rt_envvars_enabled to true before. https://dlang.org/phobos/core_runtime.html#.dmd_coverSetMerge https://dlang.org/changelog/2.078.0.html#covopts
Mar 21 2018
next sibling parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Wed, Mar 21, 2018 at 05:34:58PM +0000, Seb via Digitalmars-d wrote:
 On Wednesday, 21 March 2018 at 16:39:48 UTC, H. S. Teoh wrote:
 Is it possible to get cumulative code coverage using dmd? I.e.,
 accumulate code coverage stats over a series of runs from an
 external test suite.
[...]
 Yes, either set dmd_coverSetMerge(true) or pass --DRT-covopt "merge:1"
 to your program.
[...] Cool, passing --DRT-covopt="merge:1" did the trick. Thanks! T -- Bare foot: (n.) A device for locating thumb tacks on the floor.
Mar 21 2018
prev sibling parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Wed, Mar 21, 2018 at 12:35:08PM -0700, H. S. Teoh via Digitalmars-d wrote:
[...]
 Cool, passing --DRT-covopt="merge:1" did the trick.
[...] Speaking of which, are the --DRT-* options documented anywhere?? I don't even know where to begin to look, besides in the druntime code itself. T -- Unix was not designed to stop people from doing stupid things, because that would also stop them from doing clever things. -- Doug Gwyn
Mar 21 2018
parent reply Petar Kirov [ZombineDev] <petar.p.kirov gmail.com> writes:
On Wednesday, 21 March 2018 at 19:44:19 UTC, H. S. Teoh wrote:
 On Wed, Mar 21, 2018 at 12:35:08PM -0700, H. S. Teoh via 
 Digitalmars-d wrote: [...]
 Cool, passing --DRT-covopt="merge:1" did the trick.
[...] Speaking of which, are the --DRT-* options documented anywhere?? I don't even know where to begin to look, besides in the druntime code itself. T
I think you're looking for: "Controlling the Coverage Analyser" under https://dlang.org/articles/code_coverage.html.
Mar 21 2018
parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Thu, Mar 22, 2018 at 06:31:21AM +0000, Petar via Digitalmars-d wrote:
 On Wednesday, 21 March 2018 at 19:44:19 UTC, H. S. Teoh wrote:
 On Wed, Mar 21, 2018 at 12:35:08PM -0700, H. S. Teoh via Digitalmars-d
 wrote: [...]
 Cool, passing --DRT-covopt="merge:1" did the trick.
[...] Speaking of which, are the --DRT-* options documented anywhere?? I don't even know where to begin to look, besides in the druntime code itself.
[...]
 I think you're looking for: "Controlling the Coverage Analyser" under
 https://dlang.org/articles/code_coverage.html.
Ah, thanks! That's exactly what I was looking for. Still, it would be nice to have a list of all --DRT-* options (not necessarily related to coverage) somewhere, just for reference. T -- If you want to solve a problem, you need to address its root cause, not just its symptoms. Otherwise it's like treating cancer with Tylenol...
Mar 22 2018