1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
use warnings;
use strict;
use Test::More;
use Test::Mojo;
use Mojolicious;
plan skip_all => 't/cgi-bin/errlog' unless -x 't/cgi-bin/errlog';
unlink 't/err.log';
{
my $app = Mojolicious->new;
my $t = Test::Mojo->new($app);
my @err;
$app->plugin(CGI => {route => '/err', script => 't/cgi-bin/errlog'});
$app->log->on(
message => sub {
my ($log, $level, $message) = @_;
push @err, $message if $level eq 'warn';
}
);
$t->get_ok('/err');
like $err[0], qr{\[CGI:errlog:\d+\] yikes! at .*errlog line 2}, 'logged stderr';
}
{
my $app = Mojolicious->new;
my $t = Test::Mojo->new($app);
my $s;
$app->plugin(CGI => {route => '/err', script => 't/cgi-bin/errlog', errlog => 't/err.log'});
$t->get_ok('/err');
$s = -s 't/err.log';
ok $s, 't/err.log has data';
$t->get_ok('/err');
ok -s 't/err.log' >= $s * 2, 't/err.log has more data';
}
unlink 't/err.log';
done_testing;
|