Merge pull request #170 from perl-catalyst/haarg/no-dev-circ-deps
Graham Knop [Sun, 26 Jul 2020 15:52:31 +0000 (17:52 +0200)]
Eliminate circular dependencies in develop prereqs

36 files changed:
Makefile.PL
maint/Makefile.PL.include
t/class_traits_CAR_bug.t
t/encoding_set_in_config.t [deleted file]
t/encoding_set_in_plugin.t [new file with mode: 0644]
t/lib/MakeTestApp.pm [new file with mode: 0644]
t/lib/TestApp.pm
t/lib/TestApp2.pm [deleted file]
t/lib/TestApp2/Controller/Root.pm [deleted file]
t/lib/TestAppEncodingSetInConfig.pm [deleted file]
t/lib/TestAppEncodingSetInConfig/testappencodingsetinconfig.json [deleted file]
t/lib/TestAppEncodingSetInPlugin.pm [new file with mode: 0644]
t/lib/TestAppEncodingSetInPlugin/Controller/Root.pm [moved from t/lib/TestAppEncodingSetInConfig/Controller/Root.pm with 63% similarity]
t/lib/TestAppEncodingSetInPlugin/SetEncoding.pm [new file with mode: 0644]
t/lib/TestMiddlewareFromPlugin.pm [moved from t/lib/TestMiddlewareFromConfig.pm with 55% similarity]
t/lib/TestMiddlewareFromPlugin/Controller/Root.pm [moved from t/lib/TestMiddlewareFromConfig/Controller/Root.pm with 80% similarity]
t/lib/TestMiddlewareFromPlugin/Custom.pm [moved from t/lib/TestMiddlewareFromConfig/Custom.pm with 63% similarity]
t/lib/TestMiddlewareFromPlugin/SetMiddleware.pm [new file with mode: 0644]
t/lib/TestMiddlewareFromPlugin/share/static/forced.txt [moved from t/lib/TestMiddlewareFromConfig/share/static/forced.txt with 100% similarity]
t/lib/TestMiddlewareFromPlugin/share/static/message.txt [moved from t/lib/TestMiddlewareFromConfig/share/static/message.txt with 100% similarity]
t/lib/TestMiddlewareFromPlugin/share/static2/message2.txt [moved from t/lib/TestMiddlewareFromConfig/share/static2/message2.txt with 100% similarity]
t/lib/TestMiddlewareFromPlugin/share/static3/message3.txt [moved from t/lib/TestMiddlewareFromConfig/share/static3/message3.txt with 100% similarity]
t/lib/TestMiddlewareFromPlugin/testmiddlewarefromplugin.pl [moved from t/lib/TestMiddlewareFromConfig/testmiddlewarefromconfig.pl with 74% similarity]
t/live_component_controller_context_closure.t
t/optional_apache-cgi-rewrite.pl
t/optional_apache-cgi.pl
t/optional_apache-fastcgi-non-root.pl
t/optional_apache-fastcgi.pl
t/optional_http-server-restart.t
t/optional_lighttpd-fastcgi-non-root.t
t/optional_lighttpd-fastcgi.t
t/plack-middleware-plugin.t [moved from t/plack-middleware-config.t with 87% similarity, mode: 0755]
t/unicode_plugin_config.t
t/unicode_plugin_live.t
xt/author/http-server.t
xt/author/unicode_plugin_nested_params.t [deleted file]

index f951674..1f76be6 100644 (file)
@@ -83,10 +83,7 @@ my %META = (
     },
     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,
@@ -95,10 +92,7 @@ my %META = (
         'Test::Pod::Coverage'     => 0,
         'Test::Spelling'          => 0,
         'Pod::Coverage::TrustPod' => 0,
-        'Catalyst::Plugin::Params::Nested' => 0,
-        'Catalyst::Plugin::ConfigLoader' => 0,
         'Compress::Zlib'          => 0,
-        'Catalyst::Action::REST'  => 0,
         'Type::Tiny'              => 0,
         'Proc::ProcessTable'      => 0,
       },
index ef141e3..5b50f1f 100644 (file)
@@ -7,11 +7,10 @@ author 'Sebastian Riedel <sri@cpan.org>';
 manifest_include script => 'catalyst.pl';
 manifest_include t => 'catalyst_130pix.gif';
 manifest_include 't/conf' => 'extra.conf.in';
-manifest_include 't/lib/TestAppEncodingSetInConfig' => 'testappencodingsetinconfig.json';
 manifest_include 't/lib/TestContentNegotiation/share', 'file.txt';
 manifest_include 't/lib/TestMiddleware/share' => qr/.*/;
-manifest_include 't/lib/TestMiddlewareFromConfig/share' => qr/.*/;
-manifest_include 't/lib/TestMiddlewareFromConfig' => 'testmiddlewarefromconfig.pl';
+manifest_include 't/lib/TestMiddlewareFromPlugin/share' => qr/.*/;
+manifest_include 't/lib/TestMiddlewareFromPlugin' => 'testmiddlewarefromplugin.pl';
 manifest_include t => qr/optional_apache-.*\.pl/;
 manifest_include t => 'optional_stress.json';
 manifest_include t => 'something/Makefile.PL';
index 2e9743b..4c58d0c 100644 (file)
@@ -4,13 +4,6 @@ use Test::More;
 use Class::MOP;
 
 BEGIN {
-  use Test::More;
-  eval "use Catalyst::Action::REST; 1" || do {
-    plan skip_all => "Trouble loading Catalyst::Action::REST => $@";
-  };
-}
-
-BEGIN {
   my %hidden = map { (my $m = "$_.pm") =~ s{::}{/}g; $m => 1 } qw(
     Foo
     Bar
diff --git a/t/encoding_set_in_config.t b/t/encoding_set_in_config.t
deleted file mode 100644 (file)
index faf860b..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-use strict;
-use warnings;
-
-use FindBin '$Bin';
-use lib "$Bin/lib";
-
-use Test::More;
-
-BEGIN { eval { require Catalyst::Plugin::ConfigLoader; 1; } ||
-    plan skip_all => 'Need Catalyst::Plugin::ConfigLoader' }
-
-#for this test encoding => 'UTF-8' is set in testappencodingsetinconfig.json
-use Catalyst::Test 'TestAppEncodingSetInConfig';
-
-my ( undef, $c ) = ctx_request('/');
-isa_ok( $c->encoding,  'Encode::utf8', '$c->encoding' );
-
-done_testing;
diff --git a/t/encoding_set_in_plugin.t b/t/encoding_set_in_plugin.t
new file mode 100644 (file)
index 0000000..56359b6
--- /dev/null
@@ -0,0 +1,15 @@
+use strict;
+use warnings;
+
+use FindBin '$Bin';
+use lib "$Bin/lib";
+
+use Test::More;
+
+#for this test encoding => 'UTF-8' is set in a plugin
+use Catalyst::Test 'TestAppEncodingSetInPlugin';
+
+my ( undef, $c ) = ctx_request('/');
+isa_ok( $c->encoding,  'Encode::utf8', '$c->encoding' );
+
+done_testing;
diff --git a/t/lib/MakeTestApp.pm b/t/lib/MakeTestApp.pm
new file mode 100644 (file)
index 0000000..c48c501
--- /dev/null
@@ -0,0 +1,52 @@
+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;
index 3d50a73..20d12f7 100644 (file)
@@ -60,23 +60,35 @@ TestApp->config(
 # above ->setup so we have some generated methods to be double sure.
 has an_attribute_before_we_change_base_classes => ( is => 'ro');
 
-if ($::setup_leakchecker && try_load_class('CatalystX::LeakChecker')) {
-    with 'CatalystX::LeakChecker';
+if ($::setup_leakchecker) {
+    require Scalar::Util;
+    require Devel::Cycle;
 
     has leaks => (
         is      => 'ro',
         default => sub { [] },
     );
-}
 
-sub found_leaks {
-    my ($ctx, @leaks) = @_;
-    push @{ $ctx->leaks }, @leaks;
-}
+    sub count_leaks {
+        my ($ctx) = @_;
+        return scalar @{ $ctx->leaks };
+    }
+
+    after finalize => sub {
+        my ($ctx) = @_;
+        my @leaks;
+
+        my $weak_ctx = $ctx;
+        Scalar::Util::weaken $weak_ctx;
+
+        Devel::Cycle::find_cycle($ctx, sub {
+            my ($path) = @_;
+            push @leaks, $path
+                if $path->[0]->[2] == $weak_ctx;
+        });
 
-sub count_leaks {
-    my ($ctx) = @_;
-    return scalar @{ $ctx->leaks };
+        push @{ $ctx->leaks }, @leaks;
+    };
 }
 
 TestApp->setup;
diff --git a/t/lib/TestApp2.pm b/t/lib/TestApp2.pm
deleted file mode 100644 (file)
index 53b483f..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-package TestApp2;
-use strict;
-use warnings;
-use base qw/Catalyst/;
-use Catalyst qw/Params::Nested/;
-
-__PACKAGE__->config(
-  'name' => 'TestApp2',
-  encoding => 'UTF-8',
-);
-
-__PACKAGE__->setup;
-
-sub handle_unicode_encoding_exception {
-  my ( $self, $param_value, $error_msg ) = @_;
-  return $param_value;
-}
-
-1;
diff --git a/t/lib/TestApp2/Controller/Root.pm b/t/lib/TestApp2/Controller/Root.pm
deleted file mode 100644 (file)
index e40ee8c..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package TestApp2::Controller::Root;
-use strict;
-use warnings;
-use utf8;
-
-__PACKAGE__->config(namespace => q{});
-
-use base 'Catalyst::Controller';
-
-# your actions replace this one
-sub main :Path('') {
-    $_[1]->res->body('<h1>It works</h1>');
-    $_[1]->res->content_type('text/html');
-}
-
-1;
diff --git a/t/lib/TestAppEncodingSetInConfig.pm b/t/lib/TestAppEncodingSetInConfig.pm
deleted file mode 100644 (file)
index 7abd703..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-package TestAppEncodingSetInConfig;
-use Moose;
-
-use Catalyst qw/ConfigLoader/;
-
-extends 'Catalyst';
-
-__PACKAGE__->setup;
-
-1;
diff --git a/t/lib/TestAppEncodingSetInConfig/testappencodingsetinconfig.json b/t/lib/TestAppEncodingSetInConfig/testappencodingsetinconfig.json
deleted file mode 100644 (file)
index 2b8b413..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-{
-    "encoding": "UTF-8"
-}
diff --git a/t/lib/TestAppEncodingSetInPlugin.pm b/t/lib/TestAppEncodingSetInPlugin.pm
new file mode 100644 (file)
index 0000000..49844af
--- /dev/null
@@ -0,0 +1,10 @@
+package TestAppEncodingSetInPlugin;
+use Moose;
+
+use Catalyst qw/+TestAppEncodingSetInPlugin::SetEncoding/;
+
+extends 'Catalyst';
+
+__PACKAGE__->setup;
+
+1;
@@ -1,6 +1,6 @@
-package TestAppEncodingSetInConfig::Controller::Root;
+package TestAppEncodingSetInPlugin::Controller::Root;
 use Moose;
-use namespace::clean -except => [ 'meta' ];
+use namespace::autoclean;
 
 BEGIN { extends 'Catalyst::Controller'; }
 
diff --git a/t/lib/TestAppEncodingSetInPlugin/SetEncoding.pm b/t/lib/TestAppEncodingSetInPlugin/SetEncoding.pm
new file mode 100644 (file)
index 0000000..92d3078
--- /dev/null
@@ -0,0 +1,11 @@
+package TestAppEncodingSetInPlugin::SetEncoding;
+use strict;
+use warnings;
+
+sub setup {
+    my $c = shift;
+    $c->config(encoding => 'UTF-8');
+    $c->next::method(@_);
+}
+
+1;
similarity index 55%
rename from t/lib/TestMiddlewareFromConfig.pm
rename to t/lib/TestMiddlewareFromPlugin.pm
index 4c0af79..ce95ee8 100644 (file)
@@ -1,10 +1,11 @@
-package TestMiddlewareFromConfig;
+package TestMiddlewareFromPlugin;
 
-use Catalyst qw/ConfigLoader/;
+use Catalyst qw/+TestMiddlewareFromPlugin::SetMiddleware/;
 
 ## Proof this is good config
-##__PACKAGE__->config( do TestMiddlewareFromConfig->path_to('testmiddlewarefromconfig.pl') );
+##__PACKAGE__->config( do TestMiddlewareFromConfig->path_to('testmiddlewarefromplugin.pl') );
 
 __PACKAGE__->setup_middleware('Head');
 __PACKAGE__->setup;
 
+1;
@@ -1,4 +1,4 @@
-package TestMiddlewareFromConfig::Controller::Root;
+package TestMiddlewareFromPlugin::Controller::Root;
 
 use Moose;
 use MooseX::MethodAttributes;
similarity index 63%
rename from t/lib/TestMiddlewareFromConfig/Custom.pm
rename to t/lib/TestMiddlewareFromPlugin/Custom.pm
index dde1613..0b89b59 100644 (file)
@@ -1,4 +1,4 @@
-package TestMiddlewareFromConfig::Custom;
+package TestMiddlewareFromPlugin::Custom;
 
 use strict;
 use warnings;
diff --git a/t/lib/TestMiddlewareFromPlugin/SetMiddleware.pm b/t/lib/TestMiddlewareFromPlugin/SetMiddleware.pm
new file mode 100644 (file)
index 0000000..7bd32bb
--- /dev/null
@@ -0,0 +1,15 @@
+package TestMiddlewareFromPlugin::SetMiddleware;
+use strict;
+use warnings;
+use File::Spec;
+use File::Basename ();
+
+my $config_path = File::Spec->catfile(File::Basename::dirname(__FILE__), 'testmiddlewarefromplugin.pl');
+
+sub setup {
+    my $c = shift;
+    $c->config(do $config_path);
+    $c->next::method(@_);
+}
+
+1;
@@ -1,21 +1,21 @@
 use Plack::Middleware::Static;
 
 my $static = Plack::Middleware::Static->new(
-  path => qr{^/static/}, root => TestMiddlewareFromConfig->path_to('share'));
+  path => qr{^/static/}, root => TestMiddlewareFromPlugin->path_to('share'));
 
 my $conf = +{
   'Controller::Root', { namespace => '' },
   'psgi_middleware', [
     $static,
-    'Static', { path => qr{^/static2/}, root => TestMiddlewareFromConfig->path_to('share') },
+    'Static', { path => qr{^/static2/}, root => TestMiddlewareFromPlugin->path_to('share') },
     'Runtime',
-    '+TestMiddleware::Custom', { path => qr{^/static3/}, root => TestMiddlewareFromConfig->path_to('share') },
+    '+TestMiddleware::Custom', { path => qr{^/static3/}, root => TestMiddlewareFromPlugin->path_to('share') },
     sub {
       my $app = shift;
       return sub {
         my $env = shift;
         if($env->{PATH_INFO} =~m/forced/) {
-          Plack::App::File->new(file=>TestMiddlewareFromConfig->path_to(qw/share static forced.txt/))
+          Plack::App::File->new(file=>TestMiddlewareFromPlugin->path_to(qw/share static forced.txt/))
             ->call($env);
         } else {
           return $app->($env);
index 69fa504..ff0bbe9 100644 (file)
@@ -3,8 +3,8 @@ use warnings;
 use Test::More;
 
 BEGIN {
-    unless (eval 'use CatalystX::LeakChecker 0.05; 1') {
-        plan skip_all => 'CatalystX::LeakChecker 0.05 required for this test';
+    unless (eval 'use Devel::Cycle 1.11; 1') {
+        plan skip_all => 'Devel::Cycle 1.11 required for this test';
     }
 
     plan tests => 6;
index abf467e..ebfe69c 100644 (file)
@@ -16,18 +16,10 @@ use File::Copy::Recursive;
 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';
 
index f81c7c4..09363a6 100644 (file)
@@ -16,18 +16,10 @@ use File::Copy::Recursive;
 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';
 
index bc1b2a5..3b5eae9 100644 (file)
@@ -16,18 +16,10 @@ use File::Copy::Recursive;
 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';
 
index 95c3702..adc68ea 100644 (file)
@@ -16,18 +16,10 @@ use File::Copy::Recursive;
 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';
 
index 9d58e08..ff7049d 100644 (file)
@@ -14,29 +14,16 @@ use LWP::Simple;
 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 );
index 80600f9..c402090 100644 (file)
@@ -10,18 +10,21 @@ BEGIN {
 use File::Path;
 use FindBin;
 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;
@@ -31,25 +34,16 @@ plan skip_all => 'Please set LIGHTTPD_BIN to the path to lighttpd'
 
 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";
 my $port    = 8529;
 
 # Clean up docroot path
-$docroot =~ s{/t/..}{};
+$docroot =~ s{/t/\.\.}{};
+
+my $perl5lib = join($Config::Config{path_sep}, "$docroot/../../lib", $ENV{PERL5LIB} || ());
 
 my $conf = <<"END";
 # basic lighttpd config file for testing fcgi+catalyst
@@ -83,7 +77,7 @@ fastcgi.server = (
             "max-procs"       => 1,
             "idle-timeout"    => 20,
             "bin-environment" => (
-                "PERL5LIB" => "$docroot/../../lib"
+                "PERL5LIB" => "$perl5lib"
             )
         )
     )
index fefa06a..1d3ca40 100644 (file)
@@ -10,18 +10,21 @@ BEGIN {
 use File::Path;
 use FindBin;
 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;
@@ -31,25 +34,17 @@ plan skip_all => 'Please set LIGHTTPD_BIN to the path to lighttpd'
 
 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";
 my $port    = 8529;
 
 # Clean up docroot path
-$docroot =~ s{/t/..}{};
+$docroot =~ s{/t/\.\.}{};
+
+my $perl5lib = join($Config::Config{path_sep}, "$docroot/../../lib", $ENV{PERL5LIB} || ());
 
 my $conf = <<"END";
 # basic lighttpd config file for testing fcgi+catalyst
@@ -78,7 +73,7 @@ fastcgi.server = (
             "max-procs"       => 1,
             "idle-timeout"    => 20,
             "bin-environment" => (
-                "PERL5LIB" => "$docroot/../../lib"
+                "PERL5LIB" => "$perl5lib"
             )
         )
     )
old mode 100644 (file)
new mode 100755 (executable)
similarity index 87%
rename from t/plack-middleware-config.t
rename to t/plack-middleware-plugin.t
index 728bff6..e2d7bcb
@@ -7,11 +7,8 @@ use FindBin;
 use Test::More;
 use HTTP::Request::Common;
 
-BEGIN { eval { require Catalyst::Plugin::ConfigLoader; 1; } ||
-    plan skip_all => 'Need Catalyst::Plugin::ConfigLoader' }
-
 use lib "$FindBin::Bin/lib";
-use Catalyst::Test 'TestMiddlewareFromConfig';
+use Catalyst::Test 'TestMiddlewareFromPlugin';
 
 ok my($res, $c) = ctx_request('/');
 
index 8335b1f..5c4aef7 100644 (file)
@@ -8,21 +8,11 @@ BEGIN { $ENV{TESTAPP_ENCODING} = 'UTF-8' };
 use FindBin qw($Bin);
 use lib "$Bin/lib";
 
-BEGIN {
-if ( !eval { require Test::WWW::Mechanize::Catalyst; Test::WWW::Mechanize::Catalyst->VERSION('0.51')} ) {
-    plan skip_all => 'Need Test::WWW::Mechanize::Catalyst for this test';
-}
-}
-
-# make sure testapp works
-use_ok('TestAppUnicode');
-
-use Test::WWW::Mechanize::Catalyst 'TestAppUnicode';
-my $mech = Test::WWW::Mechanize::Catalyst->new;
+use Catalyst::Test 'TestAppUnicode';
 
 {
     TestAppUnicode->encoding('UTF-8');
-    $mech->get_ok('http://localhost/unicode', 'encoding configured ok');
+    action_ok('/unicode', 'encoding configured ok');
 }
 
 done_testing;
index f3b5f90..b8e546b 100644 (file)
@@ -6,80 +6,79 @@ use Test::More;
 use FindBin qw($Bin);
 use lib "$Bin/lib";
 
-BEGIN {
-  if ( !eval { require Test::WWW::Mechanize::Catalyst; Test::WWW::Mechanize::Catalyst->VERSION('0.51') } ) {
-    plan skip_all => 'Need Test::WWW::Mechanize::Catalyst for this test';
-  }
-}
-
-# make sure testapp works
-use_ok('TestAppUnicode') or BAIL_OUT($@);
+use Catalyst::Test qw(TestAppUnicode);
 
-# a live test against TestAppUnicode, the test application
-use Test::WWW::Mechanize::Catalyst 'TestAppUnicode';
-my $mech = Test::WWW::Mechanize::Catalyst->new;
-$mech->get_ok('http://localhost/', 'get main page');
-$mech->content_like(qr/it works/i, 'see if it has our text');
-is ($mech->response->header('Content-Type'), 'text/html; charset=UTF-8',
-    'Content-Type with charset'
-);
+{
+    my $res = request('/');
+    ok($res->is_success, 'get main page');
+    like($res->decoded_content, qr/it works/i, 'see if it has our text');
+    is ($res->header('Content-Type'), 'text/html; charset=UTF-8',
+        'Content-Type with charset'
+    );
+}
 
 {
-    $mech->get_ok('http://localhost/unicode_no_enc', 'get unicode_no_enc');
+    my $res = request('/unicode_no_enc');
+    ok($res->is_success, 'get unicode_no_enc');
 
     my $exp = "\xE3\x81\xBB\xE3\x81\x92";
-    my $got = Encode::encode_utf8($mech->content);
+    my $got = Encode::encode_utf8($res->decoded_content);
 
-    is ($mech->response->header('Content-Type'), 'text/plain',
+    is ($res->header('Content-Type'), 'text/plain',
         'Content-Type with no charset');
 
     is($got, $exp, 'content contains hoge');
 }
 
 {
-    $mech->get_ok('http://localhost/unicode', 'get unicode');
+    my $res = request('/unicode');
+    ok( $res->is_success, 'get unicode');
 
-    is ($mech->response->header('Content-Type'), 'text/plain; charset=UTF-8',
+    is ($res->header('Content-Type'), 'text/plain; charset=UTF-8',
         'Content-Type with charset');
 
     my $exp = "\xE3\x81\xBB\xE3\x81\x92";
-    my $got = Encode::encode_utf8($mech->content);
+    my $got = Encode::encode_utf8($res->decoded_content);
 
     is($got, $exp, 'content contains hoge');
 }
 
 {
-    $mech->get_ok('http://localhost/not_unicode', 'get bytes');
+    my $res = request('/not_unicode');
+    ok($res->is_success, 'get bytes');
     my $exp = "\xE1\x88\xB4\xE5\x99\xB8";
-    my $got = Encode::encode_utf8($mech->content);
+    my $got = Encode::encode_utf8($res->decoded_content);
 
     is($got, $exp, 'got 1234 5678');
 }
 
 {
-    $mech->get_ok('http://localhost/file', 'get file');
-    $mech->content_like(qr/this is a test/, 'got filehandle contents');
+    my $res = request('/file');
+    ok($res->is_success, 'get file');
+    like($res->decoded_content, qr/this is a test/, 'got filehandle contents');
 }
 
 {
     # The latin 1 case is the one everyone forgets. I want to really make sure
     # its right, so lets check the damn bytes.
-    $mech->get_ok('http://localhost/latin1', 'get latin1');
-    is ($mech->response->header('Content-Type'), 'text/plain; charset=UTF-8',
+    my $res = request('/latin1');
+    ok($res->is_success, 'get latin1');
+    is ($res->header('Content-Type'), 'text/plain; charset=UTF-8',
         'Content-Type with charset');
 
 
     my $exp = "LATIN SMALL LETTER E WITH ACUTE: \xC3\xA9";
-    my $got = Encode::encode_utf8($mech->content);
+    my $got = Encode::encode_utf8($res->decoded_content);
 
     is ($got, $exp, 'content octets are UTF-8');
 }
 
 {
-    $mech->get_ok('http://localhost/shift_jis', 'get shift_jis');
-    is ($mech->response->header('Content-Type'), 'text/plain; charset=Shift_JIS', 'Content-Type with charset');
+    my $res = request('/shift_jis');
+    ok($res->is_success, 'get shift_jis');
+    is ($res->header('Content-Type'), 'text/plain; charset=Shift_JIS', 'Content-Type with charset');
     my $exp = "\xE3\x81\xBB\xE3\x81\x92";
-    my $got = Encode::encode_utf8($mech->content);
+    my $got = Encode::encode_utf8($res->decoded_content);
     is ($got, $exp, 'content octets are Shift_JIS');
 }
 
index 8667cad..ffd95c0 100644 (file)
@@ -9,34 +9,13 @@ use FindBin;
 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;
@@ -48,7 +27,7 @@ if ($pid) {
     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);
diff --git a/xt/author/unicode_plugin_nested_params.t b/xt/author/unicode_plugin_nested_params.t
deleted file mode 100644 (file)
index e2680d1..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-use strict;
-use warnings;
-use Test::More;
-use utf8;
-
-# setup library path
-use FindBin qw($Bin);
-use lib "$Bin/../../t/lib";
-
-BEGIN { eval { require Catalyst::Plugin::Params::Nested; 1; } ||
-    plan skip_all => 'Need Catalyst::Plugin::Params::Nested' }
-
-use Catalyst::Test 'TestApp2';
-use Encode;
-use HTTP::Request::Common;
-use URI::Escape qw/uri_escape_utf8/;
-use HTTP::Status 'is_server_error';
-
-my $encode_str = "\x{e3}\x{81}\x{82}"; # e38182 is japanese 'あ'
-my $decode_str = Encode::decode('utf-8' => $encode_str);
-my $escape_str = uri_escape_utf8($decode_str);
-
-BEGIN {
-    eval 'require Catalyst::Plugin::Params::Nested';
-    plan skip_all => 'Catalyst::Plugin::Params::Nested is required' if $@;
-}
-
-{
-    my ($res, $c) = ctx_request("/?foo.1=bar&foo.2=$escape_str");
-    is( $c->res->output, '<h1>It works</h1>', 'Content displayed' );
-
-    my $got = $c->request->parameters;
-    my $expected = {
-        'foo.1' => 'bar',
-        'foo.2' => $decode_str,
-        'foo'   => [undef, 'bar', $decode_str],
-    };
-
-    is( $got->{foo}->[0], undef, '{foo}->[0] is undef' );
-    is( $got->{foo}->[1], 'bar', '{foo}->[1] is bar' );
-    ok( utf8::is_utf8( $got->{'foo.2'}       ), '{foo.2} is utf8' );
-    ok( utf8::is_utf8( $got->{foo}->[2]      ), '{foo}->[2] is utf8' );
-    is_deeply($got, $expected, 'nested params' );
-}
-
-{
-    my ($res, $c) = ctx_request("/?foo.1=bar&foo.2=$escape_str&bar.baz=$escape_str&baz.bar.foo=$escape_str&&arr.0.1=$escape_str");
-
-    my $got = $c->request->parameters;
-    my $expected = {
-        'foo.1'       => 'bar',
-        'foo.2'       => $decode_str,
-        'bar.baz'     => $decode_str,
-        'baz.bar.foo' => $decode_str,
-        'arr.0.1'     => $decode_str,
-        'arr'         => [ [undef, $decode_str] ],
-        'foo'         => [undef, 'bar', $decode_str],
-        'bar'         => { baz => $decode_str },
-        'baz'         => { bar => { foo => $decode_str } },
-    };
-
-    is( ref $got->{arr}->[0], 'ARRAY', '{arr}->[0] is ARRAY' );
-    ok( utf8::is_utf8( $got->{arr}->[0]->[1] ), '{arr}->[0]->[1] is utf8' );
-    ok( utf8::is_utf8( $got->{bar}{baz}      ), '{bar}{baz} is utf8' );
-    ok( utf8::is_utf8( $got->{baz}{bar}{foo} ), '{baz}{bar}{foo} is utf8' );
-    is_deeply($got, $expected, 'nested params' );
-}
-
-done_testing();