]> git.vpit.fr Git - perl/modules/indirect.git/blob - t/50-external.t
Don't cleanup thread local storage before END blocks are executed
[perl/modules/indirect.git] / t / 50-external.t
1 #!perl
2
3 use strict;
4 use warnings;
5
6 use Config;
7
8 use Test::More tests => 6;
9
10 use lib 't/lib';
11 use VPIT::TestHelpers;
12
13 BEGIN { delete $ENV{PERL_INDIRECT_PM_DISABLE} }
14
15 {
16  my $status = run_perl 'no indirect; qq{a\x{100}b} =~ /\A[\x00-\x7f]*\z/;';
17  is $status, 0, 'RT #47866';
18 }
19
20 SKIP:
21 {
22  skip 'Fixed in core only since 5.12' => 1 unless "$]" >= 5.012;
23  my $status = run_perl 'no indirect hook => sub { exit 2 }; new X';
24  is $status, 2 << 8, 'no semicolon at the end of -e';
25 }
26
27 SKIP:
28 {
29  load_or_skip('Devel::CallParser', undef, undef, 1);
30  my $status = run_perl "use Devel::CallParser (); no indirect; sub ok { } ok 1";
31  is $status, 0, 'indirect is not getting upset by Devel::CallParser';
32 }
33
34 SKIP:
35 {
36  my $has_package_empty = do {
37   local $@;
38   eval 'no warnings "deprecated"; package; 1'
39  };
40  skip 'Empty package only available on perl 5.8.x and below' => 1
41                                                       unless $has_package_empty;
42  my $status = run_perl 'no indirect hook => sub { }; exit 0; package; new X;';
43  is $status, 0, 'indirect does not croak while package empty is in use';
44 }
45
46 my $fork_status;
47 if ($Config::Config{d_fork} or $Config::Config{d_pseudofork}) {
48  $fork_status = run_perl 'my $pid = fork; exit 1 unless defined $pid; if ($pid) { waitpid $pid, 0; my $status = $?; exit(($status >> 8) || $status) } else { exit 0 }';
49 }
50
51 SKIP:
52 {
53  my $tests = 2;
54  skip 'fork() or pseudo-forks are required to check END blocks in subprocesses'
55                                           => $tests unless defined $fork_status;
56  skip "Could not even fork a simple process (sample returned $fork_status)"
57                                           => $tests unless $fork_status == 0;
58
59  my $status = run_perl 'require indirect; END { eval q[1] } my $pid = fork; exit 0 unless defined $pid; if ($pid) { waitpid $pid, 0; my $status = $?; exit(($status >> 8) || $status) } else { exit 0 }';
60  is $status, 0, 'indirect and global END blocks executed at the end of a forked process (RT #99083)';
61
62  $status = run_perl 'require indirect; my $pid = fork; exit 0 unless defined $pid; if ($pid) { waitpid $pid, 0; my $status = $?; exit(($status >> 8) || $status) } else { eval q[END { eval q(1) }]; exit 0 }';
63  is $status, 0, 'indirect and local END blocks executed at the end of a forked process';
64 }