update distar url master
Graham Knop [Wed, 28 Apr 2021 09:11:46 +0000 (11:11 +0200)]
62 files changed:
.travis.yml
.yath.rc [new file with mode: 0644]
Changes
Makefile.PL
lib/Catalyst.pm
lib/Catalyst/Delta.pod [changed mode: 0755->0644]
lib/Catalyst/Exception/Basic.pm
lib/Catalyst/Exception/Interface.pm
lib/Catalyst/Plugin/Unicode/Encoding.pm
lib/Catalyst/Runtime.pm
lib/Catalyst/Stats.pm
lib/Catalyst/Utils.pm
maint/Makefile.PL.include
t/aggregate/live_engine_request_body.t
t/aggregate/live_engine_request_prepare_parameters.t [changed mode: 0755->0644]
t/aggregate/psgi_file.t
t/aggregate/unit_controller_config.t [changed mode: 0755->0644]
t/aggregate/unit_core_log.t [changed mode: 0755->0644]
t/aggregate/unit_core_log_autoflush.t [changed mode: 0755->0644]
t/aggregate/unit_core_uri_for_action.t
t/bad_middleware_error.t
t/class_traits_CAR_bug.t
t/content_negotiation.t
t/custom_exception_class_simple.t
t/data_handler.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/more-psgi-compat.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/optional_threads.t
t/plack-middleware-plugin.t [moved from t/plack-middleware-config.t with 86% similarity]
t/plack-middleware.t
t/unicode_plugin_config.t
t/unicode_plugin_live.t
t/unit_stats.t
xt/author/http-server.t
xt/author/unicode_plugin_nested_params.t [deleted file]

index ead64fb..4fbb56f 100644 (file)
@@ -20,11 +20,15 @@ matrix:
     - perl: dev
 
 before_install:
-   - eval $(curl https://travis-perl.github.io/init)
+   - eval $(curl https://travis-perl.github.io/init) --perl
    - $HELPERS_ROOT/bin/cpan-config
 install:
-   - cpanm --notest --metacpan --skip-satisfied --with-develop --installdeps .
-   - perl Makefile.PL
+   - build-dist
+   - cd $BUILD_DIR
+   - cpanm -q --showdeps --with-develop . | grep -v "^perl[~@]" | AUTHOR_TESTING=0 cpanm --notest --metacpan --skip-satisfied
+
+   - test_run='make test'
+   - AUTHOR_TESTING=0 cpanm --notest --metacpan --skip-satisfied Test2::Harness && test_run='yath test t xt' || true
 
    # enable various test options, including parallel testing
    - export AUTOMATED_TESTING=1 HARNESS_OPTIONS=j10:c HARNESS_TIMER=1
@@ -34,10 +38,8 @@ install:
    - export RELEASE_TESTING=1
    - export PERL_AUTOINSTALL=--skip
 
-   - make manifest
-
 script:
-   - make disttest
+   - make && $test_run
 
    # Test reverse deps (high-profile modules, taken from from Task::Catalyst):
    #  (note: currently skipping DBIC deps for speed)
@@ -48,10 +50,12 @@ script:
 
    # pure author deps (of reverse deps):
    - cpanm --notest --metacpan --skip-satisfied YAML::Syck
+   - cpanm --notest --metacpan Carp::Assert::More@1.16
+   - cpanm --notest --metacpan Test::WWW::Mechanize@1.50
 
    # both author deps & reverse deps:
-   - cpanm --metacpan --skip-satisfied Catalyst::View::TT
-   - cpanm --metacpan --skip-satisfied Catalyst::Plugin::Authentication
+   - cpanm --metacpan --skip-satisfied Catalyst::View::TT || ( cat ~/.cpanm/build.log; false )
+   - cpanm --metacpan --skip-satisfied Catalyst::Plugin::Authentication || ( cat ~/.cpanm/build.log; false )
 
    # pure reverse deps (call with --test-only):
    - cpanm --test-only --metacpan -v Catalyst::Devel
diff --git a/.yath.rc b/.yath.rc
new file mode 100644 (file)
index 0000000..8e772a1
--- /dev/null
+++ b/.yath.rc
@@ -0,0 +1,20 @@
+[test]
+-j 4
+-P Catalyst
+-P Catalyst::Action
+-P Catalyst::ActionRole::ConsumesContent
+-P Catalyst::ActionRole::HTTPMethods
+-P Catalyst::ActionRole::QueryMatching
+-P Catalyst::ActionRole::Scheme
+-P Catalyst::DispatchType::Chained
+-P Catalyst::DispatchType::Default
+-P Catalyst::DispatchType::Index
+-P Catalyst::DispatchType::Path
+-P Catalyst::Dispatcher
+-P Catalyst::Model
+-P Catalyst::Request
+-P Catalyst::Response
+-P Catalyst::Stats
+-P Catalyst::Test
+-P Catalyst::View
+-P HTML::HeadParser
diff --git a/Changes b/Changes
index 6eb0f29..95fa030 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,20 @@
 # This file documents the revision history for Perl extension Catalyst.
 
+5.90128 - 2020-09-11
+  - fix command to run psgi compile test if Catalyst not already installed
+  - improve debugging output on psgi compile test
+
+5.90_127 - 2020-07-27
+  - fix TODO tests for uri_for as a class method
+  - silence warnings in tests
+  - remove developer prerequisites on Catalyst plugins
+  - cleanups and fixes for optional tests
+  - bump Moose prereq to 2.1400, and drop MooseX::Role::WithOverloading prereq
+  - stop warning about missing Term::Size::Any when it isn't useful
+
+5.90126 - 2020-01-19
+  - fix for broken distribution
+
 5.90125 - 2020-01-18
   - Support samesite flag for cookies (mitchjacksontech++)
   - utility method on Catalyst::Action 'equals'
index 8b366c6..1f76be6 100644 (file)
@@ -26,9 +26,8 @@ my %META = (
         'namespace::clean'      => '0.23',
         'MooseX::Emulate::Class::Accessor::Fast' => '0.00903',
         'Class::Load'           => '0.12',
-        'Moose'                 => '1.03',
+        'Moose'                 => '2.1400',
         'MooseX::MethodAttributes::Role::AttrContainer::Inheritable' => '0.24',
-        'MooseX::Role::WithOverloading' => '0.09',
         'Carp'                  => '1.25',
         'Class::C3::Adopt::NEXT' => '0.07',
         'CGI::Simple::Cookie'   => '1.109',
@@ -84,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,
@@ -96,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,
       },
@@ -168,11 +161,6 @@ my $tests = 't/*.t t/aggregate/*.t';
 my %MM_ARGS = (
   test => { TESTS => $tests },
   EXE_FILES => [ glob 'script/*.pl' ],
-  PREREQ_PM => {
-    (eval { require Moose; Moose->VERSION('2.1300') } ? () : (
-      'MooseX::Role::WithOverloading' => '0.09'
-    )),
-  },
 );
 
 ## BOILERPLATE ###############################################################
index 5d6635d..de488a4 100644 (file)
@@ -53,6 +53,9 @@ use Class::Load 'load_class';
 use Encode 2.21 'decode_utf8', 'encode_utf8';
 use Scalar::Util;
 
+our $VERSION = '5.90128';
+$VERSION =~ tr/_//d;
+
 BEGIN { require 5.008003; }
 
 has stack => (is => 'ro', default => sub { [] });
@@ -206,10 +209,6 @@ sub composed_stats_class {
 
 __PACKAGE__->_encode_check(Encode::FB_CROAK | Encode::LEAVE_SRC);
 
-# Remember to update this in Catalyst::Runtime as well!
-our $VERSION = '5.90125';
-$VERSION = eval $VERSION if $VERSION =~ /_/; # numify for warning-free dev releases
-
 sub import {
     my ( $class, @arguments ) = @_;
 
@@ -1644,7 +1643,7 @@ sub uri_for {
         my $num_captures = $expanded_action->number_of_captures;
 
         # ->uri_for( $action, \@captures_and_args, \%query_values? )
-        if( !@args && $action->number_of_args ) {
+        if( !@args && $action->number_of_args && @$captures > $num_captures ) {
           unshift @args, splice @$captures, $num_captures;
         }
 
old mode 100755 (executable)
new mode 100644 (file)
index 253b6a8..3ac78e1 100644 (file)
@@ -1,8 +1,6 @@
 package Catalyst::Exception::Basic;
 
 use Moose::Role;
-use if !eval { require Moose; Moose->VERSION('2.1300') },
-    'MooseX::Role::WithOverloading';
 use Carp;
 use namespace::clean -except => 'meta';
 
index 73e4cc0..5f0dbd1 100644 (file)
@@ -1,8 +1,6 @@
 package Catalyst::Exception::Interface;
 
 use Moose::Role;
-use if !eval { require Moose; Moose->VERSION('2.1300') },
-    'MooseX::Role::WithOverloading';
 use namespace::clean -except => 'meta';
 
 use overload
@@ -40,9 +38,6 @@ It ensures that all exceptions follow the expected interface,
 and adds overloading for stringification when composed onto a
 class.
 
-Note that if you compose this role onto another role, that role
-must use L<MooseX::Role::WithOverloading>.
-
 =head1 REQUIRED METHODS
 
 =head2 as_string
index 76f277e..45ee480 100644 (file)
@@ -1,6 +1,7 @@
 package Catalyst::Plugin::Unicode::Encoding;
 
-our $VERSION = '5.90125';
+our $VERSION = '5.90128';
+$VERSION =~ tr/_//d;
 
 1;
 
index 1d3c75f..c8ba4fe 100644 (file)
@@ -5,10 +5,8 @@ use warnings;
 
 BEGIN { require 5.008003; }
 
-# Remember to update this in Catalyst as well!
-
-our $VERSION = '5.90125';
-$VERSION = eval $VERSION if $VERSION =~ /_/; # numify for warning-free dev releases
+our $VERSION = '5.90128';
+$VERSION =~ tr/_//d;
 
 =head1 NAME
 
index 1987205..7f6058e 100644 (file)
@@ -95,26 +95,35 @@ sub elapsed {
 sub report {
     my $self = shift;
 
-    my $column_width = Catalyst::Utils::term_width() - 9 - 13;
-    my $t = Text::SimpleTable->new( [ $column_width, 'Action' ], [ 9, 'Time' ] );
+    my $t;
     my @results;
-    $self->traverse(
-                sub {
-                my $action = shift;
-                my $stat   = $action->getNodeValue;
-                my @r = ( $action->getDepth,
-                      ($stat->{action} || "") .
-                      ($stat->{action} && $stat->{comment} ? " " : "") . ($stat->{comment} ? '- ' . $stat->{comment} : ""),
-                      $stat->{elapsed},
-                      $stat->{action} ? 1 : 0,
-                      );
-                # Trim down any times >= 10 to avoid ugly Text::Simple line wrapping
-                my $elapsed = substr(sprintf("%f", $stat->{elapsed}), 0, 8) . "s";
-                $t->row( ( q{ } x $r[0] ) . $r[1],
-                     defined $r[2] ? $elapsed : '??');
-                push(@results, \@r);
-                }
-            );
+
+    if (!wantarray) {
+        $t = Text::SimpleTable->new(
+            [ Catalyst::Utils::term_width() - 9 - 13, 'Action' ],
+            [ 9, 'Time' ],
+        );
+    }
+
+    $self->traverse(sub {
+        my $action = shift;
+        my $stat   = $action->getNodeValue;
+        my @r = ( $action->getDepth,
+              ($stat->{action} || "") .
+              ($stat->{action} && $stat->{comment} ? " " : "") . ($stat->{comment} ? '- ' . $stat->{comment} : ""),
+              $stat->{elapsed},
+              $stat->{action} ? 1 : 0,
+              );
+        # Trim down any times >= 10 to avoid ugly Text::Simple line wrapping
+        my $elapsed = substr(sprintf("%f", $stat->{elapsed}), 0, 8) . "s";
+        if ($t) {
+            $t->row( ( q{ } x $r[0] ) . $r[1],
+              defined $r[2] ? $elapsed : '??');
+        }
+        else {
+            push @results, \@r;
+        }
+    });
     return wantarray ? @results : $t->draw;
 }
 
index 30ca196..fabbb81 100644 (file)
@@ -394,6 +394,7 @@ this
 =cut
 
 my $_term_width;
+my $_use_term_size_any;
 
 sub term_width {
     my $force_reset = shift;
@@ -402,29 +403,41 @@ sub term_width {
 
     return $_term_width if $_term_width;
 
+    if ($ENV{COLUMNS} && $ENV{COLUMNS} =~ /\A\d+\z/) {
+        return $_term_width = $ENV{COLUMNS};
+    }
+
+    if (!-t STDOUT && !-t STDERR) {
+        return $_term_width = 80;
+    }
+
+    if (!defined $_use_term_size_any) {
+        eval {
+            require Term::Size::Any;
+            Term::Size::Any->import();
+            $_use_term_size_any = 1;
+            1;
+        } or do {
+            if ( $@ =~ m[Can't locate Term/Size/Any\.pm] ) {
+                warn "Term::Size::Any is not installed, can't autodetect terminal column width\n";
+            }
+            else {
+                warn "There was an error trying to detect your terminal size: $@\n";
+            }
+            $_use_term_size_any = 0;
+        };
+    }
+
     my $width;
-    eval '
-      use Term::Size::Any;
-      ($width) = Term::Size::Any::chars;
-      1;
-    ' or do {
-          if($@ =~m[Can't locate Term/Size/Any.pm]) {
-            warn "Term::Size::Any is not installed, can't autodetect terminal column width\n";
-          } else {
-            warn "There was an error trying to detect your terminal size: $@\n";
-          }
-    };
 
-    unless ($width) {
-        warn 'Trouble trying to detect your terminal size, looking at $ENV{COLUMNS}'."\n";
-        $width = $ENV{COLUMNS}
-            if exists($ENV{COLUMNS})
-            && $ENV{COLUMNS} =~ m/^\d+$/;
+    if ($_use_term_size_any) {
+        $width = Term::Size::Any::chars(*STDERR) || Term::Size::Any::chars(*STDOUT);
+    }
+
+    if (!$width || $width < 80) {
+        $width = 80;
     }
 
-    do {
-      warn "Cannot determine desired terminal width, using default of 80 columns\n";
-      $width = 80 } unless ($width && $width >= 80);
     return $_term_width = $width;
 }
 
index ef141e3..b3093e3 100644 (file)
@@ -1,17 +1,17 @@
-BEGIN { -e 'Distar' or system("git clone git://git.shadowcat.co.uk/p5sagit/Distar.git") }
+BEGIN { -e 'Distar' or system qw(git clone https://github.com/p5sagit/Distar.git) }
 use lib 'Distar/lib';
 use Distar 0.001;
 
 author 'Sebastian Riedel <sri@cpan.org>';
 
+manifest_include '' => '.yath.rc';
 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 0abe175..879ef14 100644 (file)
@@ -85,6 +85,10 @@ use HTTP::Request::Common;
     );
 
     ok( my $response = request($request), 'Request' );
+    my $server = $response->header('server') || '';
+    local $TODO = 'lighttpd refuses GET with body'
+        if $server =~ /lighttpd/;
+
     ok( $response->is_success, 'Response Successful 2xx' );
     ok( $response->header('X-Have-Request-Body'), 'X-Have-Request-Body set' );
 }
index 0e07d21..1f8f0c5 100644 (file)
@@ -7,6 +7,7 @@ use File::Temp qw/ tempdir /;
 use TestApp;
 use File::Spec;
 use Carp qw/croak/;
+use IPC::Open3 qw(open3);
 
 my $home = tempdir( CLEANUP => 1 );
 my $path = File::Spec->catfile($home, 'testapp.psgi');
@@ -21,24 +22,14 @@ TestApp->psgi_app;
 };
 close($psgi);
 
-my ($saved_stdout, $saved_stderr);
-my $stdout = !open( $saved_stdout, '>&'. STDOUT->fileno );
-my $stderr = !open( $saved_stderr, '>&'. STDERR->fileno );
-open( STDOUT, '+>', undef )
-            or croak("Can't reopen stdout to /dev/null");
-open( STDERR, '+>', undef )
-            or croak("Can't reopen stdout to /dev/null");
-# Check we wrote out something that compiles
-system($^X, '-I', "$FindBin::Bin/../lib", '-c', $path)
-    ? fail('.psgi does not compile')
-    : pass('.psgi compiles');
-
-if ($stdout) {
-    open( STDOUT, '>&'. fileno($saved_stdout) );
-}
-if ($stderr) {
-    open( STDERR, '>&'. fileno($saved_stderr) );
-}
+my @command = ($^X, '-I', "$FindBin::Bin/../lib", '-I', "$FindBin::Bin/../../lib", '-c', $path);
+open my $stdin, '<', File::Spec->devnull;
+my $pid = open3 $stdin, my $stdout, undef, @command;
+my $output = do { local $/; <$stdout> };
+waitpid $pid, 0;
+
+ok $? == 0, '.psgi compiles'
+  or diag $output;
 
 # NOTE - YOU *CANNOT* do something like:
 #my $psgi_ref = require $path;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index c6c7678..f9d3ba1 100644 (file)
@@ -77,45 +77,25 @@ my $context = TestApp->new( {
                 namespace => 'yada',
               } );
 
-
-
-
-# JNAP: I'm going to todo these tests, calling uri_for as a class method
-# should work, but its not really useful so I think theres not much harm
-# if someone needs this for a business case they are welcome to figure out
-# what is going
-
-TODO: {
-    local $TODO = "Need to fix using uri_for and uri_for_action as a class method";
-
-
-# this works, using $ctx
-is($context->uri_for($context->controller('Action::Chained')->action_for('endpoint')),
-   "http://127.0.0.1/foo/yada/chained/foo/end",
+is($context->uri_for($context->controller('Action::Chained')->action_for('endpoint'), [ 1 ]),
+   'http://127.0.0.1/foo/chained/foo/1/end',
    "uri_for a controller and action");
 
+is( $context->uri_for_action( '/action/chained/endpoint', [ 1 ] ),
+    'http://127.0.0.1/foo/chained/foo/1/end',
+    "uri_for a controller and action as string");
 
-# this fails, uri_for returns undef, why isn't this one working??
-  is( $context->uri_for_action( '/action/chained/endpoint' ),
-          'http://127.0.0.1/chained/foo/end',
-     "uri_for a controller and action as string");
-
-# this fails, uri_for returns undef
-  is(TestApp->uri_for_action($context->controller('Action::Chained')->action_for('endpoint')),
-     "/chained/foo/end",
-     "uri_for a controller and action, called with only class name");
+is(TestApp->uri_for_action($context->controller('Action::Chained')->action_for('endpoint'), [ 1 ]),
+    '/chained/foo/1/end',
+    "uri_for a controller and action, called with only class name");
 
-# this fails, uri_for returns undef
-  is(TestApp->uri_for_action('/action/chained/endpoint' ),
-     "/chained/foo/end",
-     "uri_for a controller and action as string, called with only class name");
-
-# this fails, uri_for returns undef
-  is(TestApp->uri_for_action(  $chained_action),
-     "/chained/foo/end",
-     "uri_for action via dispatcher, called with only class name");
-}
+is(TestApp->uri_for_action('/action/chained/endpoint', [ 1 ] ),
+    '/chained/foo/1/end',
+    "uri_for a controller and action as string, called with only class name");
 
+is(TestApp->uri_for_action(  $chained_action, [ 1 ]),
+    '/chained/foo/1/end',
+    "uri_for action via dispatcher, called with only class name");
 
 is($context->uri_for($context->controller('Action')),
    "http://127.0.0.1/foo/yada/action/",
index 7018ea9..f155aeb 100644 (file)
@@ -1,5 +1,3 @@
-#!/usr/bin/env perl
-
 {
   package MyApp;
 
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
index 559a370..ca4703b 100644 (file)
@@ -1,5 +1,3 @@
-#!/usr/bin/env perl
-
 use warnings;
 use strict;
 
index 27e4516..084ea11 100644 (file)
@@ -1,3 +1,4 @@
+# HARNESS-NO-PRELOAD
 use strict;
 use warnings;
 use FindBin qw/$Bin/;
index d51143d..eca273c 100644 (file)
@@ -1,5 +1,3 @@
-#!/usr/bin/env perl
-
 use warnings;
 use strict;
 
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 a176472..9798963 100644 (file)
@@ -1,5 +1,3 @@
-#!/usr/bin/env perl
-
 use warnings;
 use strict;
 
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..74e768d 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;
@@ -29,27 +32,26 @@ chomp $lighttpd_bin;
 plan skip_all => 'Please set LIGHTTPD_BIN to the path to lighttpd'
     unless $lighttpd_bin && -x $lighttpd_bin;
 
-plan tests => 1;
-
-# clean up
-rmtree "$FindBin::Bin/../t/tmp" if -d "$FindBin::Bin/../t/tmp";
+my $fix_scriptname = '';
+if (my ($vmajor, $vminor, $vpatch) = `"$lighttpd_bin" -v` =~ /\b(\d+)\.(\d+)\.(\d+)\b/) {
+    if ($vmajor > 1 || ($vmajor == 1 && ("$vminor.$vpatch" >= 4.23))) {
+        $fix_scriptname = '"fix-root-scriptname" => "enable",';
+    }
+}
 
-# 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' );
+plan tests => 1;
 
-# 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
@@ -69,7 +71,7 @@ server.port = $port
 
 # catalyst app specific fcgi setup
 fastcgi.server = (
-    "" => (
+    "/" => (
         "FastCgiTest" => (
             "socket"          => "$docroot/test.socket",
             "check-local"     => "disable",
@@ -77,8 +79,9 @@ fastcgi.server = (
             "min-procs"       => 1,
             "max-procs"       => 1,
             "idle-timeout"    => 20,
+            $fix_scriptname
             "bin-environment" => (
-                "PERL5LIB" => "$docroot/../../lib"
+                "PERL5LIB" => "$perl5lib"
             )
         )
     )
index b0a05c9..3d7dd8a 100644 (file)
@@ -28,13 +28,14 @@ else {
 }
 
 no warnings 'redefine';
-sub request {
+my $request_code = \&request;
+*request = sub {
     my $thr = threads->new(
-        sub { Catalyst::Test::local_request('TestApp',@_) },
+        sub { $request_code->(@_) },
         @_
     );
     $thr->join;
-}
+};
 
 # test that running inside a thread works ok
 {
similarity index 86%
rename from t/plack-middleware-config.t
rename to t/plack-middleware-plugin.t
index 728bff6..30caa37 100644 (file)
@@ -1,5 +1,3 @@
-#!/usr/bin/env perl
-
 use warnings;
 use strict;
 
@@ -7,11 +5,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 f6bf563..66ee2b4 100644 (file)
@@ -1,5 +1,3 @@
-#!/usr/bin/env perl
-
 use warnings;
 use strict;
 
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 5aced0a..3fc08d0 100644 (file)
@@ -1,3 +1,4 @@
+# HARNESS-NO-PRELOAD
 use strict;
 use warnings;
 
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();