Raising the bar on Phobos unittest coverage

Jonathan M Davis jmdavisProg at gmx.com
Mon Mar 18 16:06:10 PDT 2013


On Monday, March 18, 2013 22:13:36 monarch_dodra wrote:
> On Monday, 18 March 2013 at 20:30:32 UTC, Jonathan M Davis wrote:
> > On Monday, March 18, 2013 12:09:47 Walter Bright wrote:
> >> On 3/18/2013 11:12 AM, Jonathan M Davis wrote:
> >> > On Monday, March 18, 2013 17:34:12 Martin Nowak wrote:
> >> >> Can someone look into std.file's unittests. They use 60%
> >> >> (32s/50s) of
> >> >> the unittest RUNtime on my machine.
> >> > 
> >> > My first guess would be that you're running a different OS
> >> > from Walter and
> >> > that OS-specific code counts as not being run when you run
> >> > it on a
> >> > different OS.
> >> 
> >> Code that is statically compiled out is not counted as
> >> executable code by
> >> the coverage analyzer.
> > 
> > Then it was a bad guess. Good to know (and better behavior that
> > way really).
> 
> Is it though? It basically means that if you don't instantiate a
> template, it statically doesn't get compiled, so it is not
> counted:
> 
> main.d:
> //--------
> 
> |void foo(T)()
> |{
> |
> | int i = 0;
> | ++i;
> | ++i;
> | ++i;
> | ++i;
> | ++i;
> | ++i;
> | ++i;
> | ++i;
> | ++i;
> | ++i;
> | ++i;
> | ++i;
> | ++i;
> | ++i;
> | ++i;
> | ++i;
> | ++i;
> | ++i;
> | ++i;
> | ++i;
> |
> |}
> |
> |void main()
> |{
> 
> 1| int i;
> 
> |}
> 
> main.d is 100% covered
> //--------
> 
> main.d 100% covered my ass.
> 
> I also call BS on std.algorithm's 95% coverage. I looked at the
> .lst. It is *roughly* covered, but not 95% covered.
> 
> We need to be able to differentiate code that is stripped out due
> to "version" blocks (which legitimately doesn't count for the
> current build), and code that simply didn't get compiled because
> it WASN'T COVERED.

Good point. But it _is_ valuable to not have unused version blocks not count 
negatively towards code coverage.

- Jonathan M Davis


More information about the Digitalmars-d mailing list