Thread overview
Problem with code coverage. No .lst files?
Apr 25, 2014
Jeremy DeHaan
Apr 25, 2014
Ali Çehreli
Apr 25, 2014
Jeremy DeHaan
Apr 26, 2014
Jeremy DeHaan
Apr 27, 2014
Ali Çehreli
Apr 27, 2014
Jeremy DeHaan
April 25, 2014
Hey all,

I tried to use code coverage analysis for the first time tonight. I added the -cov switch to my unit test build, but no matter what I do, I can't seem to locate the produced .lst files. Is there something I should know that isn't in the docs that I might be doing wrong? I'm not sure what's going on here.

Thanks,
   Jeremy
April 25, 2014
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

April 25, 2014
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. :(
April 26, 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
April 27, 2014
On 04/26/2014 01:11 PM, Jeremy DeHaan wrote:

> 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 can reproduce it under Linux if I change to the program directory and run the program in there. However, if I run the program with its full path when I am inside the original directory where I built the program from, then the .lst file gets generated.

> Is this a bug that needs to be reported?

Yes.

> 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

So, under Linux, if I start the program as test/wont then the .lst gets generated in the current directory.

Ali

April 27, 2014
On Sunday, 27 April 2014 at 00:37:39 UTC, Ali Çehreli wrote:
> So, under Linux, if I start the program as test/wont then the .lst gets generated in the current directory.
>
> Ali

Just tried that in Windows, and the same thing happened. Weird!

I'll be sure to file a bug report. Thanks for the confirmation, Ali!