File: 93-eval-scopes.t

package info (click to toggle)
libdist-zilla-plugin-run-perl 0.050-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 444 kB
  • sloc: perl: 580; makefile: 2
file content (51 lines) | stat: -rw-r--r-- 1,217 bytes parent folder | download
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
use strict;
use warnings;

use Test::More 0.88;
use if $ENV{AUTHOR_TESTING}, 'Test::Warnings';
use Test::DZil;
use Test::Fatal;
use Test::Deep;
use Path::Tiny;

# protect from external environment
local $ENV{TRIAL};
local $ENV{RELEASE_STATUS};

my $tzil = Builder->from_config(
    { dist_root => 'does-not-exist' },
    {
        add_files => {
            path(qw(source dist.ini)) => simple_ini(
                [ GatherDir => ],
                [ 'Run::BeforeBuild' => {
                    fatal_errors => 0,
                    eval => [ "\$self" ],
                  },
                ],
            ),
            path(qw(source lib Foo.pm)) => "package Foo;\n1;\n",
        },
    },
);

$tzil->chrome->logger->set_debug(1);
is(
    exception { $tzil->build },
    undef,
    'build proceeds normally',
);

cmp_deeply(
    [ grep /^\[Run::[^]]+\]/, @{ $tzil->log_messages } ],
    [
        '[Run::BeforeBuild] evaluating: $self',
        re(qr/^\[Run::BeforeBuild\] evaluation died: Global symbol "\$self" requires explicit package name/),
    ],
    '$self is inaccessable to eval code',
);

diag 'got log messages: ', explain $tzil->log_messages
    if not Test::Builder->new->is_passing;

done_testing;