[Maypole] Debugging Maypole apps

From: Dave Howorth (dhoworth at mrc-lmb.cam.ac.uk)
Date: Fri Dec 03 2004 - 14:02:54 GMT


I've just spent a few days debugging and getting somewhat tired of
having to insert print statements in modules because Maypole::CLI runs
everything before the debugger gets a chance to stop the program.

Then inspiration flashed and I wrote the script below to let me debug
things more easily. I expect somebody will tell me there's an easier way
to do this, but just in case there isn't, here it is ...

Cheers, Dave

==============

#!/usr/bin/perl
use strict;
use warnings;
use UNIVERSAL::require;

=pod

=head1 Name

maypole-test.pl

Test harness for Maypole applications that allows the debugger to take
control earlier than with raw Maypole::CLI.

=head1 Synopsis

   perl -d maypole-test.pl YourClassName 'http://your/url/'

=head1 Description

Step through the program and just ignore this warning:
   Too late to run CHECK block at /Maypole/CLI.pm line 17.

Step into the call_url and handler to debug the request workflow.

You can also step into the import and turn trace on to debug
initialization code. There's probably a better way to do that
but I haven't thought about it yet.

=cut

my ($class, $url) = @ARGV;
die "Usage: $0 class url\nor: perl -d $0 class url\n"
unless $class and $url and @ARGV == 2;

my $cli = 'Maypole::CLI';
$cli->require;
$cli->import($class);

print $class->call_url($url);

_______________________________________________
maypole mailing list
maypole at lists.netthink.co.uk
http://lists.netthink.co.uk/listinfo/maypole



This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:57 GMT