develop => {
requires => {
'CatalystX::LeakChecker' => '0.05',
- 'Catalyst::Devel' => '1.0', # For http server test
'Test::WWW::Mechanize::Catalyst' => '0.51',
- 'Test::TCP' => '2.00', # ditto, ships Net::EmptyPort
+ 'Test::TCP' => '2.00',
'File::Copy::Recursive' => '0.40',
'Starman' => 0,
'MooseX::Daemonize' => 0,
--- /dev/null
+package MakeTestApp;
+use strict;
+use warnings;
+
+use Exporter 'import';
+use Cwd qw(abs_path);
+use File::Spec::Functions qw(updir catdir);
+use File::Basename qw(dirname);
+use File::Path qw(rmtree);
+use File::Copy::Recursive qw(dircopy);
+
+our @EXPORT = qw(make_test_app);
+
+our $root = abs_path(catdir(dirname(__FILE__), (updir) x 2));
+
+sub make_test_app {
+ my $tmp = "$root/t/tmp";
+ rmtree $tmp if -d $tmp;
+ mkdir $tmp;
+
+ # create a TestApp and copy the test libs into it
+ my $testapp = "$tmp/TestApp";
+ mkdir $testapp;
+
+ mkdir "$testapp/lib";
+ mkdir "$testapp/script";
+
+ for my $command (qw(CGI FastCGI Server)) {
+ my $script = "$testapp/script/testapp_\L$command\E.pl";
+ open my $fh, '>:raw', $script
+ or die "can't create $script: $!";
+ print $fh <<"END_CODE";
+#!/usr/bin/env perl
+
+use Catalyst::ScriptRunner;
+Catalyst::ScriptRunner->run('TestApp', '$command');
+
+1;
+END_CODE
+ close $fh;
+ chmod 0755, $script;
+ }
+
+ open my $fh, '>:raw', "$testapp/cpanfile";
+ close $fh;
+
+ File::Copy::Recursive::dircopy( "$root/t/lib", "$testapp/lib" );
+
+ return $testapp;
+}
+
+1;
use FindBin;
use IO::Socket;
-# clean up
-rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
-
-# create a TestApp and copy the test libs into it
-mkdir "$FindBin::Bin/../t/tmp";
-chdir "$FindBin::Bin/../t/tmp";
-system "$FindBin::Bin/../script/catalyst.pl TestApp";
-chdir "$FindBin::Bin/..";
-File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
-
-# remove TestApp's tests so Apache::Test doesn't try to run them
-rmtree 't/tmp/TestApp/t';
+use lib 't/lib';
+use MakeTestApp;
+
+make_test_app;
$ENV{CATALYST_SERVER} = 'http://localhost:8529/rewrite';
use FindBin;
use IO::Socket;
-# clean up
-rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
-
-# create a TestApp and copy the test libs into it
-mkdir "$FindBin::Bin/../t/tmp";
-chdir "$FindBin::Bin/../t/tmp";
-system "$FindBin::Bin/../script/catalyst.pl TestApp";
-chdir "$FindBin::Bin/..";
-File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
-
-# remove TestApp's tests so Apache::Test doesn't try to run them
-rmtree 't/tmp/TestApp/t';
+use lib 't/lib';
+use MakeTestApp;
+
+make_test_app;
$ENV{CATALYST_SERVER} = 'http://localhost:8529/cgi';
use FindBin;
use IO::Socket;
-# clean up
-rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
-
-# create a TestApp and copy the test libs into it
-mkdir "$FindBin::Bin/../t/tmp";
-chdir "$FindBin::Bin/../t/tmp";
-system "$FindBin::Bin/../script/catalyst.pl TestApp";
-chdir "$FindBin::Bin/..";
-File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
-
-# remove TestApp's tests so Apache::Test doesn't try to run them
-rmtree 't/tmp/TestApp/t';
+use lib 't/lib';
+use MakeTestApp;
+
+make_test_app;
$ENV{CATALYST_SERVER} = 'http://localhost:8529/fastcgi/deep/path';
use FindBin;
use IO::Socket;
-# clean up
-rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
-
-# create a TestApp and copy the test libs into it
-mkdir "$FindBin::Bin/../t/tmp";
-chdir "$FindBin::Bin/../t/tmp";
-system "$FindBin::Bin/../script/catalyst.pl TestApp";
-chdir "$FindBin::Bin/..";
-File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
-
-# remove TestApp's tests so Apache::Test doesn't try to run them
-rmtree 't/tmp/TestApp/t';
+use lib 't/lib';
+use MakeTestApp;
+
+make_test_app;
$ENV{CATALYST_SERVER} = 'http://localhost:8529';
use IO::Socket;
use IPC::Open3;
use Time::HiRes qw/sleep/;
-eval {require Catalyst::Devel; Catalyst::Devel->VERSION(1.0);};
-plan skip_all => 'Catalyst::Devel required' if $@;
-plan skip_all => 'Catalyst::Devel >= 1.04 required' if $Catalyst::Devel::VERSION <= 1.03;
-eval "use File::Copy::Recursive";
-plan skip_all => 'File::Copy::Recursive required' if $@;
-
-my $tmpdir = "$FindBin::Bin/../t/tmp";
-
-# clean up
-rmtree $tmpdir if -d $tmpdir;
-
-# create a TestApp and copy the test libs into it
-mkdir $tmpdir;
-chdir $tmpdir;
-
-system( $^X, "-I$FindBin::Bin/../lib", '-MFile::Spec', '-e', "\@ARGV=('TestApp'); my \$devnull = File::Spec->devnull; open my \$fh, '>', \$devnull or die \"Cannot write to \$devnull: \$!\"; *STDOUT = \$fh; do \"$FindBin::Bin/../script/catalyst.pl\"");
+BEGIN {
+ eval "use File::Copy::Recursive";
+ plan skip_all => 'File::Copy::Recursive required' if $@;
+}
-chdir "$FindBin::Bin/..";
-File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
+use lib 't/lib';
+use MakeTestApp;
-# remove TestApp's tests
-rmtree 't/tmp/TestApp/t';
+make_test_app;
# spawn the standalone HTTP server
my $port = 30000 + int rand( 1 + 10000 );
use IO::Socket;
use Config ();
-eval "use FCGI";
-plan skip_all => 'FCGI required' if $@;
+BEGIN {
+ eval "use FCGI";
+ plan skip_all => 'FCGI required' if $@;
-eval "use Catalyst::Devel 1.0";
-plan skip_all => 'Catalyst::Devel required' if $@;
+ eval "use File::Copy::Recursive";
+ plan skip_all => 'File::Copy::Recursive required' if $@;
-eval "use File::Copy::Recursive";
-plan skip_all => 'File::Copy::Recursive required' if $@;
+ eval "use Test::Harness";
+ plan skip_all => 'Test::Harness required' if $@;
+}
-eval "use Test::Harness";
-plan skip_all => 'Test::Harness required' if $@;
+use lib 't/lib';
+use MakeTestApp;
my $lighttpd_bin = $ENV{LIGHTTPD_BIN} || `which lighttpd`;
chomp $lighttpd_bin;
plan tests => 1;
-# clean up
-rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
-
-# create a TestApp and copy the test libs into it
-mkdir "$FindBin::Bin/../t/tmp";
-chdir "$FindBin::Bin/../t/tmp";
-system "$^X -I$FindBin::Bin/../lib $FindBin::Bin/../script/catalyst.pl TestApp";
-chdir "$FindBin::Bin/..";
-File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
-
-# remove TestApp's tests
-rmtree 't/tmp/TestApp/t';
+make_test_app;
# Create a temporary lighttpd config
my $docroot = "$FindBin::Bin/../t/tmp";
use IO::Socket;
use Config ();
-eval "use FCGI";
-plan skip_all => 'FCGI required' if $@;
+BEGIN {
+ eval "use FCGI";
+ plan skip_all => 'FCGI required' if $@;
-eval "use Catalyst::Devel 1.0";
-plan skip_all => 'Catalyst::Devel required' if $@;
+ eval "use File::Copy::Recursive";
+ plan skip_all => 'File::Copy::Recursive required' if $@;
-eval "use File::Copy::Recursive";
-plan skip_all => 'File::Copy::Recursive required' if $@;
+ eval "use Test::Harness";
+ plan skip_all => 'Test::Harness required' if $@;
+}
-eval "use Test::Harness";
-plan skip_all => 'Test::Harness required' if $@;
+use lib 't/lib';
+use MakeTestApp;
my $lighttpd_bin = $ENV{LIGHTTPD_BIN} || `which lighttpd`;
chomp $lighttpd_bin;
plan tests => 1;
-# clean up
-rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
-
-# create a TestApp and copy the test libs into it
-mkdir "$FindBin::Bin/../t/tmp";
-chdir "$FindBin::Bin/../t/tmp";
-system "$^X -I$FindBin::Bin/../lib $FindBin::Bin/../script/catalyst.pl TestApp";
-chdir "$FindBin::Bin/..";
-File::Copy::Recursive::dircopy( 't/lib', 't/tmp/TestApp/lib' );
-
-# remove TestApp's tests
-rmtree 't/tmp/TestApp/t';
+# this creates t/tmp/TestApp
+make_test_app;
# Create a temporary lighttpd config
my $docroot = "$FindBin::Bin/../t/tmp";
use Net::EmptyPort qw(wait_port empty_port);
use Try::Tiny;
use Plack::Builder;
-
-eval { require Catalyst::Devel; Catalyst::Devel->VERSION(1.0); 1; } || do {
- fail("Could not load Catalyst::Devel: $@");
- exit 1;
-};
-
-eval { require File::Copy::Recursive; 1 } || do {
- fail("Could not load File::Copy::Recursive: $@");
- exit 1;
-};
+use lib 't/lib';
+use MakeTestApp;
# Run a single test by providing it as the first arg
my $single_test = shift;
-my $tmpdir = "$FindBin::Bin/../../t/tmp";
-
-# clean up
-rmtree $tmpdir if -d $tmpdir;
-
-# create a TestApp and copy the test libs into it
-mkdir $tmpdir;
-chdir $tmpdir;
-system( $^X, "-I$FindBin::Bin/../../lib", "$FindBin::Bin/../../script/catalyst.pl", 'TestApp' );
-chdir "$FindBin::Bin/..";
-File::Copy::Recursive::dircopy( '../t/lib', '../t/tmp/TestApp/lib' ) or die;
-
-# remove TestApp's tests
-rmtree '../t/tmp/TestApp/t' or die;
+my $test_app_dir = make_test_app;
# spawn the standalone HTTP server
my $port = empty_port;
wait_port_timeout($port, 30);
} elsif ($pid == 0) {
# child process
- unshift @INC, "$tmpdir/TestApp/lib", "$FindBin::Bin/../../lib";
+ unshift @INC, "$test_app_dir/lib", "$FindBin::Bin/../../lib";
require TestApp;
my $psgi_app = TestApp->apply_default_middlewares(TestApp->psgi_app);