X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F31.with_pid_file_and_poe.t;h=23ac3bb81c2b94e28c2e628701bc80c6f800584b;hb=10769ed347f340ee0e81d85933ae8f82ff0413da;hp=740090f1eae4a94f7150fbb61eac4328dab25f0b;hpb=24b6fd77f2d0f29555c753ea2fcc814368068d65;p=gitmo%2FMooseX-Daemonize.git diff --git a/t/31.with_pid_file_and_poe.t b/t/31.with_pid_file_and_poe.t index 740090f..23ac3bb 100644 --- a/t/31.with_pid_file_and_poe.t +++ b/t/31.with_pid_file_and_poe.t @@ -3,27 +3,31 @@ use strict; use warnings; -use Cwd; use File::Spec::Functions; use Test::More; use Test::Exception; use Test::Moose; +use File::Temp qw(tempdir); + +my $dir = tempdir( CLEANUP => 1 ); + BEGIN { eval 'use POE::Kernel;'; plan skip_all => "POE required for this test" if $@; - plan no_plan => 1; + plan 'no_plan'; use_ok('MooseX::Daemonize::Core'); } use constant DEBUG => 0; -my $CWD = Cwd::cwd; -my $PIDFILE = catfile($CWD, 'test-app.pid'); -$ENV{MX_DAEMON_STDOUT} = catfile($CWD, 'Out.txt'); -$ENV{MX_DAEMON_STDERR} = catfile($CWD, 'Err.txt'); +my $PIDFILE = catfile($dir, 'test-app.pid'); +$ENV{MX_DAEMON_STDOUT} = catfile($dir, 'Out.txt'); +$ENV{MX_DAEMON_STDERR} = catfile($dir, 'Err.txt'); + +unlink $PIDFILE; # clean up anythinf leftover by last run { package MyFooDaemon; @@ -63,6 +67,7 @@ $ENV{MX_DAEMON_STDERR} = catfile($CWD, 'Err.txt'); }, terminate => sub { my ($kernel, $heap) = @_[KERNEL, HEAP]; + $self->pidfile->remove if $self->pidfile->pid == $$; } }, heap => [ 0 ]