Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Test-Deep CPAN distribution.

Report information
The Basics
Id: 32330
Status: open
Priority: 0/
Queue: Test-Deep

People
Owner: Nobody in particular
Requestors: dam [...] modsoftsys.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.099
Fixed in: (no value)



Subject: things using Test::Deep::NoTest are untestable with Test::Deep
Download (untitled) / with headers
text/plain 1.3k
Hi, Here's a bug report[1] we've got for the Debian package of Test-Deep. I copy it here for completeness. [1] http://bugs.debian.org/419637 ------8<----- Package: libtest-deep-perl Version: 0.093-1 Severity: normal If one uses the convenient eq_deeply function outside a test scenario (use Test::Deep::NoTest), then such a program/module is no longer testable using Test::Deep. When I build a test that does "use Test::Deep" and then accesses cmp_deeply and friends, I get this error message: "Can't call method "ok" on an undefined value at /usr/share/perl5/Test/Deep.pm line 113." The reason is that while Test:Deep:NoTest avoids pulling in test::builder, it enforces this for subsequent Test::Deep imports as well, thus breaking Test::Deep. I'm not sure how this can be fixed best; looks like a design issue for the upstream author to ponder. Maybe it would be best to transplant the code that is not test-specific to T::D::notest altogether? (and add a use T::D::notest in T::D) for eq_deeply this looks trivial (use T::D::Stack, copy the 8 lines of function, done), not certain about the other functions that T::D::NoTest exports by default. For a user of T::D::NoTest, it looks as the only viable temporary workaround is to "use T::D"; this pulls in Test::Builder but at least doesn't have any major other nasty side effects.
Download (untitled) / with headers
text/plain 786b
I was looking at $Test::Deep::NoTest today and it occurs to me that rather than undefining $Test you could instead use a mock Test::Builder object that does nothing except ok() but silently. Everything else is a no-op (throw in an AUTOLOAD). That would at least make things like cmp_deeply() work without having to do any special checks. As for avoiding Test::Deep::NoTest from stomping on $Test... you could make use of the new lexical pragma stuff in 5.10. mjd might have backported that. Another trick would be to use a local variable to switch. $Test would be a proxy object between the real and mock Test::Builders. It has an AUTOLOAD which simply looks at the flag and decides which to call. if( $NoTest ) { $mock->$method(@args); } else { $real->$metho(@args); }
CC: 419637 [...] bugs.debian.org, Alexander Zangerl <az [...] debian.org>
Subject: Re: [rt.cpan.org #32330] things using Test::Deep::NoTest are untestable with Test::Deep
Date: Sat, 4 Oct 2008 19:21:48 +0300
To: Michael G Schwern via RT <bug-Test-Deep [...] rt.cpan.org>
From: Damyan Ivanov <dmn [...] debian.org>
Download (untitled) / with headers
text/plain 1.3k
Thank you Michhael for your reply. I am forwarding it to the bug submitter (CC-ing also the bug itself to keep the log). Alexander, can you check if the approach below is feasibble? It would also be good if you can reply to Fergal's mail[1] [1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=419637#14 -=| Michael G Schwern via RT, Sat, Oct 04, 2008 at 01:28:30AM -0400 |=- Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=32330 > > > I was looking at $Test::Deep::NoTest today and it occurs to me that > rather than undefining $Test you could instead use a mock Test::Builder > object that does nothing except ok() but silently. Everything else is a > no-op (throw in an AUTOLOAD). That would at least make things like > cmp_deeply() work without having to do any special checks. > > As for avoiding Test::Deep::NoTest from stomping on $Test... you could > make use of the new lexical pragma stuff in 5.10. mjd might have > backported that. Another trick would be to use a local variable to > switch. $Test would be a proxy object between the real and mock > Test::Builders. It has an AUTOLOAD which simply looks at the flag and > decides which to call. > > if( $NoTest ) { > $mock->$method(@args); > } > else { > $real->$metho(@args); > } > >
-- dam JabberID: dam@jabber.minus273.org
Download signature.asc
application/pgp-signature 197b

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #32330] things using Test::Deep::NoTest are untestable with Test::Deep
Date: Tue, 04 Nov 2008 13:01:50 +1000
To: 419637 [...] bugs.debian.org, Michael G Schwern via RT <bug-Test-Deep [...] rt.cpan.org>
From: Alexander Zangerl <az [...] snafu.priv.at>
On Sat, 04 Oct 2008 19:21:48 +0300, Damyan Ivanov writes: Show quoted text
>Alexander, can you check if the approach below is feasibble?
sorry for the late response. no idea regarding feasibility, i'm not using 5.10 yet. Show quoted text
>It would >also be good if you can reply to Fergal's mail[1] > > [1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=3D419637#14
fergal asked for a minimal code example, and here it is. ---notequal.pm-- package notequal; use Test::Deep::NoTest; use strict; sub dud { my @a=(qw(this is not a test)); my @b=(qw(and neither is that)); print "these are not equal, are they? ".eq_deeply(\@a,\@b)."\n"; } 1; --untestable use notequal; use strict; use Test::Deep; use Test::More qw(no_plan); cmp_deeply(undef,&notequal::dud); notequal.pm uses test::deep::notest, and can't be tested using test::deep: 'Can't call method "ok" on an undefined value at /usr/share/perl5/Test/Deep.pm line 113.' regards az -- + Alexander Zangerl + DSA 42BD645D + (RSA 5B586291) I have the diesel-powered Plonkulator warmed up. -- rone
Download signature.asc
application/pgp-signature 189b

Message body not shown because it is not plain text.



This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.