--- On Mon, 18/5/09, Gabor Szabo <szab...@gmail.com> wrote:

> From: Gabor Szabo <szab...@gmail.com>

> I have a test script that blows up after 18 calls to ok()
> inside
> the application printing only the line number in the
> application.
> I can search for the title of the ok() all but it would be
> nice if I
> could ask prove
> (maybe in the -d flag) to print the line number of each
> ok() call.


ok() generally comes from Test::Simple/Test::More, which in turn comes from 
Test::Builder.  It's the test builder which controls what can and cannot be 
printed and it really doesn't have a direct way of handling this.  Thus, I 
don't think there's much which could be exposed via prove.  (Seriously 
hungover, though, so I might be talking complete bollocks -- again).

If it's a one-off, though, you could try the following (untested):

  {
    my $ok = \&Test::Builder::ok;
    no warnings 'redefined';
    *Test::Builder::ok = sub {
        my ( $package, $filename, $line ) = caller;
        $_[0]->diag("ok() called in $package, $filename at line $line");
        goto $ok;
    };
  }

Cheers,
Ovid
--
Buy the book         - http://www.oreilly.com/catalog/perlhks/
Tech blog            - http://use.perl.org/~Ovid/journal/
Twitter              - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6

Reply via email to