Problem with code coverage. No .lst files?

Jeremy DeHaan via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Apr 26 13:11:17 PDT 2014


On Friday, 25 April 2014 at 08:20:37 UTC, Jeremy DeHaan wrote:
> On Friday, 25 April 2014 at 04:23:45 UTC, Ali Çehreli wrote:
>> On 04/24/2014 08:32 PM, Jeremy DeHaan wrote:
>>
>> > added the -cov switch to my unit test build
>>
>> Then you must execute the program. :)
>>
>> Ali
>
> I did, but still nothing. I even tried using the switch in a 
> debug build and the same thing happened(or didn't happen I 
> guess). I'm using Mono-D to build if that makes any difference, 
> and I've tried running it both through Mono-D and via the 
> application itself. I'm not sure what to do. :(

Well, I think I found out what was happening. If you compile with 
-cov AND use -of where the output file is in a different 
directory than where the build is taking place(eg, buld happens 
in C:/DProject/, and the command line has 
-ofC:/DProject/Unittest/Unittest.exe), no .lst files are 
produced. I guess the compiler isn't sure where to put them? In 
any case, I removed the -of switch and when I ran that 
application .lst files were now created in the same directory as 
the application. Is this a bug that needs to be reported?

Here's a simple test that reproduces the issues.

test.d
===
module test;

class Test
{
	int thing;
	this(int newThing)
	{
		thing = newThing;
	}

	void showThing()
	{
		import std.stdio;
		writeln(thing);
	}
}

unittest
{
	auto tester = new Test(100);
	tester.showThing();
}


command line that will produce .lst file: dmd test.d -cov 
-unittest -main -ofWill.exe

command line that won't produce .lst file: dmd test.d -cov 
-unittest -main -oftest\Wont.exe


More information about the Digitalmars-d-learn mailing list