Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl

Re: Hello, I think TestRunPerl can save me, but I am not sure how to go about it...

 

 

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded


fred at redhotpenguin

Mar 15, 2012, 9:28 AM

Post #1 of 3 (750 views)
Permalink
Re: Hello, I think TestRunPerl can save me, but I am not sure how to go about it...

Steve, please direct these questions to the mod_perl list which I have
cc'd. You're much more likely to get an answer from any one of the
thousands of experienced users on this list than emailing any of the
posters directly.

On Tue, Mar 13, 2012 at 1:18 PM, Steven Lembark <lembark [at] wrkhors> wrote:
>
> Say I have a mod_perl2 handler that does nothing more
> than pass off its request object to another sub. The
> sub gets a few things out of $request->args and the
> headers, proceses its result, and life is good.
>
> 99% of the work inside the handler has nothing whatever
> to do with mod_perl.
>
> I would like to run:
>
>    perl -d submit_a_fake_request;
>
> and watch the request get handled.
>
> I think that PerlTest or PerlTestRun might offer some
> way to do this but, but the POD includes only:
>
>     My::TestRun->new->run(@ARGV);
>
> and I have no idea what to pass in as @ARGV.
>
> Note that I am not trying to debug Apache itself,
> just the code that lives below the handler sub. Nor
> am I writing tests for the most part, I just need
> to see the code in "perl -d" to find out some things
> about what is going on inside the code.
>
> If this were mod_perl with an HTTP::Request object
> I could take an old $r->as_string, strip the method
> and uri, split the headers on newlines, extract the
> query and construct a new HTTP::Request object. I
> am trying to duplicate this procedure in Apache2.
>
> I'll be happy to hand back POD for the PerlTestRun
> that shows someone how to assemble a working Apache2
> request out of as_string output in order to run a
> test. But several days of stumbling through google and
> mod_perl archives leave me with no examples that don't
> already assume that someone knows all of the appropriate
> arguments and methods to call for setting up an object.
>
> Any help would be appreciated.
>
> --
> Steven Lembark                                             3646 Flora Pl
> Workhorse Computing                                   St Louis, MO 63110
> lembark [at] wrkhors                                      +1 888 359 3508


david at dbooth

Mar 15, 2012, 10:00 AM

Post #2 of 3 (700 views)
Permalink
Re: Hello, I think TestRunPerl can save me, but I am not sure how to go about it... [In reply to]

FYI, I tried doing this with using the Test::MockObject module, but
abandoned the effort due to a bug that causes Apache2 child process
segmentation fault even when no Test::MockObject functions are called:
https://rt.cpan.org/Public/Bug/Display.html?id=73723

I don't know if there might have been other workarounds possible.

David

On Thu, 2012-03-15 at 09:28 -0700, Fred Moyer wrote:
> Steve, please direct these questions to the mod_perl list which I have
> cc'd. You're much more likely to get an answer from any one of the
> thousands of experienced users on this list than emailing any of the
> posters directly.
>
> On Tue, Mar 13, 2012 at 1:18 PM, Steven Lembark <lembark [at] wrkhors> wrote:
> >
> > Say I have a mod_perl2 handler that does nothing more
> > than pass off its request object to another sub. The
> > sub gets a few things out of $request->args and the
> > headers, proceses its result, and life is good.
> >
> > 99% of the work inside the handler has nothing whatever
> > to do with mod_perl.
> >
> > I would like to run:
> >
> > perl -d submit_a_fake_request;
> >
> > and watch the request get handled.
> >
> > I think that PerlTest or PerlTestRun might offer some
> > way to do this but, but the POD includes only:
> >
> > My::TestRun->new->run(@ARGV);
> >
> > and I have no idea what to pass in as @ARGV.
> >
> > Note that I am not trying to debug Apache itself,
> > just the code that lives below the handler sub. Nor
> > am I writing tests for the most part, I just need
> > to see the code in "perl -d" to find out some things
> > about what is going on inside the code.
> >
> > If this were mod_perl with an HTTP::Request object
> > I could take an old $r->as_string, strip the method
> > and uri, split the headers on newlines, extract the
> > query and construct a new HTTP::Request object. I
> > am trying to duplicate this procedure in Apache2.
> >
> > I'll be happy to hand back POD for the PerlTestRun
> > that shows someone how to assemble a working Apache2
> > request out of as_string output in order to run a
> > test. But several days of stumbling through google and
> > mod_perl archives leave me with no examples that don't
> > already assume that someone knows all of the appropriate
> > arguments and methods to call for setting up an object.
> >
> > Any help would be appreciated.
> >
> > --
> > Steven Lembark 3646 Flora Pl
> > Workhorse Computing St Louis, MO 63110
> > lembark [at] wrkhors +1 888 359 3508
>
>

--
David Booth, Ph.D.
http://dbooth.org/

Opinions expressed herein are those of the author and do not necessarily
reflect those of his employer.


cosimo at streppone

Mar 15, 2012, 10:07 AM

Post #3 of 3 (712 views)
Permalink
Re: Hello, I think TestRunPerl can save me, but I am not sure how to go about it... [In reply to]

On Thu, 15 Mar 2012 18:00:24 +0100, David Booth <david [at] dbooth> wrote:

> FYI, I tried doing this with using the Test::MockObject module, but
> abandoned the effort due to a bug that causes Apache2 child process
> segmentation fault even when no Test::MockObject functions are called:
> https://rt.cpan.org/Public/Bug/Display.html?id=73723
>
> I don't know if there might have been other workarounds possible.

Just skimming through the mail content, sorry,
maybe it's not what you want. But...

I've hacked together this for some unit tests
of code that was dependent on mod-perl,

https://metacpan.org/module/Test::Mock::Apache2
https://github.com/cosimo/perl5-test-mock-apache2

YMMV,

--
Cosimo

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.