-use Test::More tests => 2;
+use Test::More tests => 4;
use Test::MooseX::Daemonize;
+use MooseX::Daemonize;
## Since a daemon will not be able to print terminal output, we
## have a test daemon create a file, and another process test for
with qw(MooseX::Daemonize);
has filename => ( isa => 'Str', is => 'ro' );
-
+
after start => sub { $_[0]->create_file( $_[0]->filename ) };
sub create_file {
my ( $self, $file ) = @_;
- open( FILE, ">$file" ) || die $!;
- close(FILE);
+ open( my $FILE, ">$file" ) || die $!;
+ close($FILE);
}
no Moose;
}
-
package main;
+use strict;
+use warnings;
use Cwd;
## Try to make sure we are in the test directory
chdir 't' if ( Cwd::cwd() !~ m|/t$| );
my $cwd = Cwd::cwd();
-my $file = join( '/', $cwd, 'im_alive' );
-my $daemon = FileMaker->new( pidbase => '.', filename => $file );
-
-daemonize_ok( $daemon, 'child forked okay' );
-ok( -e $file, "$file exists" );
-unlink($file);
-
+my $app = FileMaker->new(
+ pidbase => $cwd,
+ filename => "$cwd/im_alive",
+);
+daemonize_ok( $app, 'child forked okay' );
+ok( -e $app->filename, "file exists" );
+ok( $app->stop( no_exit => 1 ), 'app stopped' );
+ok( not(-e $app->pidfile) , 'pidfile gone' );
+unlink( $app->filename );