www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Propsed path to std.cover

What this does is allows for a program to dump coverage data programmatically 
(before the end of the run) with an extra name tag and also to zero the
counters 
programmatically.

the idea is to use it like this

unittest
{
  std.cover.Wipe()
  scope(exit) std.cover.Dump("Unittest.somthing.");


  // unittest for something
}


the you get cov for just that unittest in it's own set of files.


***************
*** 84,89 ****
--- 84,96 ----
      merge = flag;
  }
  
+ void Wipe()
+ {
+ 	foreach(d;gdata)
+ 		foreach(inout v;d.data)
+ 			v=0;
+ }
+ 
  extern (C) void _d_cover_register(char[] filename, BitArray valid, uint[] 
data)
  {
      //printf("_d_cover_register()\n");
***************
*** 99,104 ****
--- 106,116 ----
  
  static ~this()
  {
+ 	Drop("");
+ }
+ 
+ void Drop(char[] name)
+ {
      //printf("cover.~this()\n");
  
      foreach (Cover c; gdata)
***************
*** 112,118 ****
  	char[][] lines = std.string.splitlines(buf);
  
  	// Generate listing file name
! 	char[] lstfilename = std.path.addExt(std.path.getBaseName(c.filename), 
"lst");
  
  	if (merge && exists(lstfilename) && isfile(lstfilename))
  	{
--- 124,130 ----
  	char[][] lines = std.string.splitlines(buf);
  
  	// Generate listing file name
! 	char[] lstfilename = std.path.addExt(name~std.path.getBaseName(c.filename), 
"lst");
  
  	if (merge && exists(lstfilename) && isfile(lstfilename))
  	{
Oct 04 2007