From: Yuval Kogman Date: Wed, 18 Jun 2008 08:20:21 +0000 (+0000) Subject: use tempdir, not cwd in tests X-Git-Tag: 0.15~17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=23b6ee85e8bcc041c8df6d3dabf2cd15ce93e91c;p=gitmo%2FMooseX-Daemonize.git use tempdir, not cwd in tests --- diff --git a/t/01.filecreate.t b/t/01.filecreate.t index d4e977a..d961841 100644 --- a/t/01.filecreate.t +++ b/t/01.filecreate.t @@ -2,22 +2,24 @@ 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'); { @@ -42,7 +44,7 @@ $ENV{MX_DAEMON_STDERR} = catfile($CWD, 'Err.txt'); } my $app = FileMaker->new( - pidbase => $CWD, + pidbase => $dir, filename => $FILENAME, ); isa_ok($app, 'FileMaker'); @@ -52,7 +54,7 @@ does_ok($app, 'MooseX::Daemonize::Core'); 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'); diff --git a/t/31.with_pid_file_and_poe.t b/t/31.with_pid_file_and_poe.t index ae1c201..2fc888c 100644 --- a/t/31.with_pid_file_and_poe.t +++ b/t/31.with_pid_file_and_poe.t @@ -3,13 +3,16 @@ 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 $@; @@ -20,10 +23,9 @@ BEGIN { 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