use IPC::Open3;
use Time::HiRes qw/sleep/;
use Catalyst::Helper;
-eval "use Catalyst::Devel 1.04;";
-
-plan skip_all => 'Catalyst::Devel >= 1.04 required' if $@;
-eval "use File::Copy::Recursive";
-plan skip_all => 'File::Copy::Recursive required' if $@;
+use File::Copy::Recursive;
plan tests => 35;
copy_test_app();
# remove TestApp's tests
-rmtree 't/tmp/TestApp/t';
+rmtree "$tmpdir/TestApp/t";
# spawn the standalone HTTP server
my $port = 30000 + int rand( 1 + 10000 );
# change various files
my @files = (
- "$FindBin::Bin/../t/tmp/TestApp/lib/TestApp.pm",
- "$FindBin::Bin/../t/tmp/TestApp/lib/TestApp/Controller/Foo.pm",
- "$FindBin::Bin/../t/tmp/TestApp/lib/TestApp/Controller/Root.pm",
+ "$tmpdir/TestApp/lib/TestApp.pm",
+ "$tmpdir/TestApp/lib/TestApp/Controller/Foo.pm",
+ "$tmpdir/TestApp/lib/TestApp/Controller/Root.pm",
);
# change some files and make sure the server restarts itself
# we need different options so we have to rebuild most
# of the testing environment
-kill 'KILL', $pid or die "Cannot kill $pid: $!";
+kill 9, $pid or die "Cannot send kill signal to $pid: $!";
close $server or die "Cannot close handle to server process: $!";
wait;
copy_test_app();
@files = (
- "$FindBin::Bin/../t/tmp/TestApp/lib/TestApp/Controller/Subdir1/Foo.pm",
- "$FindBin::Bin/../t/tmp/TestApp/lib/TestApp/Controller/Subdir2/Foo.pm",
+ "$tmpdir/TestApp/lib/TestApp/Controller/Subdir1/Foo.pm",
+ "$tmpdir/TestApp/lib/TestApp/Controller/Subdir2/Foo.pm",
);
-my $app_root = "$FindBin::Bin/../t/tmp/TestApp";
+my $app_root = "$tmpdir/TestApp";
my $restartdirs = join ' ', map{
"-restartdirectory $app_root/lib/TestApp/Controller/Subdir$_"
} 1, 2;
'Non-error restart with multiple watched dirs' );
}
-kill 'KILL', $pid;
+kill 9, $pid;
close $server;
wait;
-rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
+rmtree $tmpdir if -d $tmpdir;
sub copy_test_app {
{ no warnings 'once'; $File::Copy::Recursive::RMTrgFil = 1; }
- copy( 't/lib/TestApp.pm', 't/tmp/TestApp/lib/TestApp.pm' );
- File::Copy::Recursive::dircopy( 't/lib/TestApp', 't/tmp/TestApp/lib/TestApp' );
+ File::Copy::Recursive::dircopy( 't/lib/TestApp', "$tmpdir/TestApp/lib/TestApp" );
}
sub start_server {
my $pid = open3(
undef, $server, undef,
$^X, "-I$FindBin::Bin/../lib",
- "$FindBin::Bin/../t/tmp/TestApp/script/testapp_server.pl", '-port',
- $port, '-restart'
+ "$tmpdir/TestApp/script/testapp_server.pl", '--port',
+ $port, '--restart'
) or die "Unable to spawn standalone HTTP server: $!";
# switch to non-blocking reads so we can fail gracefully instead