- 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
- 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)
# 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
--- /dev/null
+[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
# 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'
'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',
},
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,
'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,
},
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 ###############################################################
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 { [] });
__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 ) = @_;
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;
}
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';
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
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
package Catalyst::Plugin::Unicode::Encoding;
-our $VERSION = '5.90125';
+our $VERSION = '5.90128';
+$VERSION =~ tr/_//d;
1;
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
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;
}
=cut
my $_term_width;
+my $_use_term_size_any;
sub term_width {
my $force_reset = shift;
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;
}
-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';
);
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' );
}
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');
};
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;
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/",
-#!/usr/bin/env perl
-
{
package MyApp;
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
-#!/usr/bin/env perl
-
use warnings;
use strict;
+# HARNESS-NO-PRELOAD
use strict;
use warnings;
use FindBin qw/$Bin/;
-#!/usr/bin/env perl
-
use warnings;
use strict;
+++ /dev/null
-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;
--- /dev/null
+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;
--- /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;
# 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;
+++ /dev/null
-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;
+++ /dev/null
-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;
+++ /dev/null
-package TestAppEncodingSetInConfig;
-use Moose;
-
-use Catalyst qw/ConfigLoader/;
-
-extends 'Catalyst';
-
-__PACKAGE__->setup;
-
-1;
+++ /dev/null
-{
- "encoding": "UTF-8"
-}
--- /dev/null
+package TestAppEncodingSetInPlugin;
+use Moose;
+
+use Catalyst qw/+TestAppEncodingSetInPlugin::SetEncoding/;
+
+extends 'Catalyst';
+
+__PACKAGE__->setup;
+
+1;
-package TestAppEncodingSetInConfig::Controller::Root;
+package TestAppEncodingSetInPlugin::Controller::Root;
use Moose;
-use namespace::clean -except => [ 'meta' ];
+use namespace::autoclean;
BEGIN { extends 'Catalyst::Controller'; }
--- /dev/null
+package TestAppEncodingSetInPlugin::SetEncoding;
+use strict;
+use warnings;
+
+sub setup {
+ my $c = shift;
+ $c->config(encoding => 'UTF-8');
+ $c->next::method(@_);
+}
+
+1;
-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;
-package TestMiddlewareFromConfig::Controller::Root;
+package TestMiddlewareFromPlugin::Controller::Root;
use Moose;
use MooseX::MethodAttributes;
-package TestMiddlewareFromConfig::Custom;
+package TestMiddlewareFromPlugin::Custom;
use strict;
use warnings;
--- /dev/null
+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;
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);
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;
-#!/usr/bin/env perl
-
use warnings;
use strict;
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 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;
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
"max-procs" => 1,
"idle-timeout" => 20,
"bin-environment" => (
- "PERL5LIB" => "$docroot/../../lib"
+ "PERL5LIB" => "$perl5lib"
)
)
)
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;
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
# catalyst app specific fcgi setup
fastcgi.server = (
- "" => (
+ "/" => (
"FastCgiTest" => (
"socket" => "$docroot/test.socket",
"check-local" => "disable",
"min-procs" => 1,
"max-procs" => 1,
"idle-timeout" => 20,
+ $fix_scriptname
"bin-environment" => (
- "PERL5LIB" => "$docroot/../../lib"
+ "PERL5LIB" => "$perl5lib"
)
)
)
}
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
{
-#!/usr/bin/env perl
-
use warnings;
use strict;
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('/');
-#!/usr/bin/env perl
-
use warnings;
use strict;
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;
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');
}
+# HARNESS-NO-PRELOAD
use strict;
use warnings;
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);
+++ /dev/null
-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();