Tyler MacDonald wrote:
My unit tests all need a database to operate. I was having each .t file
setup and teardown the test database before, but I want to move to having
this happen when apache is started and stopped, so that I can interact with
things manually on the server and run individual tests with prove a lot
quicker, since that's part of my regular coding flow.

So I tried to subclass the "start" and "stop" methods to set up / tear down
the database. I was suprised to find that my "stop" method gets called even
when I run "perl t/TEST -start"! :

$ perl t/TEST -start
[warning] setting ulimit to allow core files
ulimit -c unlimited; /usr/bin/perl /home/faraway/dev/Apache2-AUS/t/TEST
running start! at /home/faraway/dev/Apache2-AUS/t/TEST line 33.
/usr/sbin/apache2 -d /home/faraway/dev/Apache2-AUS/t -f
/home/faraway/dev/Apache2-AUS/t/conf/httpd.conf -D APACHE2 -D
using Apache/2.0.55 (prefork MPM)

waiting 60 seconds for server to start: ...
waiting 60 seconds for server to start: ok (waited 1 secs)
server crackerjack:8529 started
running stop! at /home/faraway/dev/Apache2-AUS/t/TEST line 47.

I'm kind of confused here. Looking at TestRun.pm's "stop" method, it looks
like it's supposed to stop the test server. Yet it runs when I call
"-start". Yet apache doesn't stop. Yet apache does stop when I call "-stop".
How does this work? :)
It restores the perms if it has changed them. It needs to do that,
regardless of whether the server was stopped - since it may not be stopped
at all.

Usually you use t/conf/modperl_extra.pl to do anything you need to happen
at the startup and an END block (registered in the same file) for
shutdown. Just remember that Apache is not very reliable when it comes to
shutdown, since it will wait a bit and then kill the process outright.

Stas Bekman mailto:stas@stason.org http://stason.org/
MailChannels: Assured Messaging(TM) http://mailchannels.com/
The "Practical mod_perl" book http://modperlbook.org/
http://perl.apache.org/ http://perl.org/ http://logilune.com/

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 5 | next ›
Discussion Overview
grouptest-dev @
categoriesmodperl, perl
postedMar 9, '06 at 7:50p
activeMar 10, '06 at 8:44p

2 users in discussion

Tyler MacDonald: 3 posts Stas Bekman: 2 posts



site design / logo © 2018 Grokbase