Thanks for the solution. However, i get the following error when i execute 'perl cover -report text -ignore_re File/Copy'.
<error> stat(-ignore_re): No such file or directory at /temp/din/Devel-Cover-0.47/cover line 101 Can't open database </error> Any clue why this error occurs. Regards, Guru Prasad -----Original Message----- From: Paul Johnson [mailto:[EMAIL PROTECTED] Sent: Monday, October 11, 2004 6:58 PM To: Padubidri Nagaraja Rao, Guruprasad (Guruprasad)** CTR ** Cc: '[EMAIL PROTECTED]' Subject: Re: Branch coverage issue in Devel::Cover On Mon, Oct 11, 2004 at 06:09:04PM +0530, Padubidri Nagaraja Rao, Guruprasad (Guruprasad)** CTR ** wrote: > Hi, > > I am not able to get branch coverage for the following piece of code. > > <code_snippet> > #!/usr/bin/perl > > use File::Copy; > > if (move("junk", "junk1")) > { > print "file moved\n"; > } > else > { > print "file not moved - $!\n"; > } > > </code_snippet> > > Environment : > > Solaris 9 > Perl 5.6.1 > Devel-Cover-0.47 > > When i run 'cover', Statement coverage shows 100% but > branch coverage shows 0%. Why? Because Devel::Cover is buggy? The problem here is that by default coverage data is not being collected in File::Copy, it being a core module. So as soon as we hit code from File::Copy, a flag is set internally to say don't collect coverage. The trouble is that that flag is not being reset until we hit a new statement in the test file, since that is the first time we can tell from which file the op was created. In this case, the next statement comes after the branch data would be collected. You can get around this by turning on coverage collection for File::Copy. $ perl -MDevel::Cover=-select,File/Copy myprog You can tell cover to ignore data from File::Copy when you generate the report. $ cover -report text -ignore_re File/Copy I was actually just looking at this last night but didn't have a small example to work with, so thank you very much for that. Actually, a small test case is probably the single biggest help to me in cases such as this. The only thing better is if it is accompanied by a perfect patch ;-) I will see if I can work out some sort of solution for the next release. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net