Subject: | Failure With Devel::Cover |
When running this test with Test::LeakTrace:
no_leaks_ok(sub {
my $obj = Math::Random::ISAAC::PP->new(time);
for (0..10) {
$obj->irand();
}
}, 'Using irand does not leak memory');
I get a success via prove. However, once I enable Devel::Cover (ie, via
cover -test or the ./Build testcover), then I get a bunch of leaked
scalars. This is the output under prove:
Show quoted text
> prove --verbose -Ilib t/01memory.t
t/01memory....
1..2
ok 1 - Using irand does not leak memory
ok 2 - Using irand does not leak memory
ok
All tests successful.
Files=1, Tests=2, 0 wallclock secs ( 0.02 usr 0.01 sys + 0.02 cusr
0.01 csys = 0.06 CPU)
Result: PASS
However, this is the output under cover -test:
t/01memory..........1/2
# Failed test 'Using irand does not leak memory'
# at t/01memory.t line 37.
# got: 15
# expected: 0
A simple workaround would be to alert the user that the test may be
wrong if Devel::Cover is in use, or put that in the documentation
somewhere. Better may be to turn the tests into no-ops with appropriate
diagnostic output if Devel::Cover is in use.
Or maybe it's all a problem on my end, and I should just skip the tests
if running with Devel::Cover.
Nonetheless, I think some documentation stating this problem would be
nice :-)