File: 25-log.t

package info (click to toggle)
libhtml-mason-perl 1%3A1.58-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,796 kB
  • sloc: perl: 8,618; sh: 49; makefile: 2
file content (74 lines) | stat: -rw-r--r-- 2,115 bytes parent folder | download | duplicates (5)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
use strict;
use warnings;
use Test::More tests => 1;
use Log::Any::Test;
use Log::Any qw($log);
use Test::Deep;
use File::Temp qw(tempdir);
use File::Path;
use HTML::Mason::Interp;

sub write_file {
    my ( $file, $content ) = @_;
    open( my $fh, ">$file" );
    $fh->print($content);
}

my $comp_root = tempdir( 'mason-log-t-XXXX', TMPDIR => 1, CLEANUP => 1 );
mkpath( "$comp_root/bar", 0, 0775 );

my $interp = HTML::Mason::Interp->new( comp_root => $comp_root );
write_file( "$comp_root/foo", "% \$m->log->debug('in foo');\n<& /bar/baz &>" );
write_file( "$comp_root/bar/baz", "% \$m->log->error('in bar/baz')" );
$interp->exec('/foo');

cmp_deeply(
    $log->msgs,
    [
        {
            category => 'HTML::Mason::Request',
            level    => 'debug',
            message  => 'top path is \'/foo\''
        },
        {
            category => 'HTML::Mason::Request',
            level    => 'debug',
            message  => 'starting request for \'/foo\''
        },
        {
            category => 'HTML::Mason::Request',
            level    => 'debug',
            message  => 'entering component \'/foo\' [depth 0]'
        },
        {
            category => 'HTML::Mason::Component::foo',
            level    => 'debug',
            message  => 'in foo'
        },
        {
            category => 'HTML::Mason::Request',
            level    => 'debug',
            message  => 'entering component \'/bar/baz\' [depth 1]'
        },
        {
            category => 'HTML::Mason::Component::bar::baz',
            level    => 'error',
            message  => 'in bar/baz'
        },
        {
            category => 'HTML::Mason::Request',
            level    => 'debug',
            message  => 'exiting component \'/bar/baz\' [depth 1]'
        },
        {
            category => 'HTML::Mason::Request',
            level    => 'debug',
            message  => 'exiting component \'/foo\' [depth 0]'
        },
        {
            category => 'HTML::Mason::Request',
            level    => 'debug',
            message  => 'finishing request for \'/foo\''
        }
    ]
);