use strict;
use warnings;
-use Cwd;
use File::Spec::Functions;
use Test::More tests => 29;
use Test::Moose;
+use File::Temp qw(tempdir);
+
+my $dir = tempdir( CLEANUP => 1 );
+
BEGIN {
use_ok('MooseX::Daemonize');
}
use constant DEBUG => 0;
-my $CWD = Cwd::cwd;
-my $FILENAME = "$CWD/im_alive";
-$ENV{MX_DAEMON_STDOUT} = catfile($CWD, 'Out.txt');
-$ENV{MX_DAEMON_STDERR} = catfile($CWD, 'Err.txt');
+my $FILENAME = catfile($dir, "im_alive");
+$ENV{MX_DAEMON_STDOUT} = catfile($dir, 'Out.txt');
+$ENV{MX_DAEMON_STDERR} = catfile($dir, 'Err.txt');
{
}
my $app = FileMaker->new(
- pidbase => $CWD,
+ pidbase => $dir,
filename => $FILENAME,
);
isa_ok($app, 'FileMaker');
isa_ok($app->pidfile, 'MooseX::Daemonize::Pid::File');
-is($app->pidfile->file, "$CWD/filemaker.pid", '... got the right PID file path');
+is($app->pidfile->file, catfile($dir, "filemaker.pid"), '... got the right PID file path');
ok(not(-e $app->pidfile->file), '... our pidfile does not exist');
ok(!$app->status, '... the daemon is running');
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 $@;
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