]> git.vpit.fr Git - perl/modules/indirect.git/blob - t/50-external.t
Rename I_CHECK_MUTEX_* to I_CHECK_*
[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 my $run_perl_failed = 'Could not execute perl subprocess';
16
17 SKIP: {
18  my $status = run_perl 'no indirect; qq{a\x{100}b} =~ /\A[\x00-\x7f]*\z/;';
19  skip $run_perl_failed => 1 unless defined $status;
20  is $status, 0, 'RT #47866';
21 }
22
23 SKIP: {
24  skip 'Fixed in core only since 5.12' => 1 unless "$]" >= 5.012;
25
26  my $status = run_perl 'no indirect hook => sub { exit 2 }; new X';
27  skip $run_perl_failed => 1 unless defined $status;
28  is $status, 2 << 8, 'no semicolon at the end of -e';
29 }
30
31 SKIP: {
32  load_or_skip('Devel::CallParser', undef, undef, 1);
33
34  my $status = run_perl "use Devel::CallParser (); no indirect; sub ok { } ok 1";
35  skip $run_perl_failed => 1 unless defined $status;
36  is $status, 0, 'indirect is not getting upset by Devel::CallParser';
37 }
38
39 SKIP: {
40  my $has_package_empty = do {
41   local $@;
42   eval 'no warnings "deprecated"; package; 1'
43  };
44  skip 'Empty package only available on perl 5.8.x and below' => 1
45                                                       unless $has_package_empty;
46
47  my $status = run_perl 'no indirect hook => sub { }; exit 0; package; new X;';
48  skip $run_perl_failed => 1 unless defined $status;
49  is $status, 0, 'indirect does not croak while package empty is in use';
50 }
51
52 my $fork_status;
53 if ($Config::Config{d_fork} or $Config::Config{d_pseudofork}) {
54  $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 }';
55 }
56
57 SKIP: {
58  my $tests = 2;
59  skip 'fork() or pseudo-forks are required to check END blocks in subprocesses'
60                                           => $tests unless defined $fork_status;
61  skip "Could not even fork a simple process (sample returned $fork_status)"
62                                           => $tests unless $fork_status == 0;
63
64  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 }';
65  skip $run_perl_failed => $tests unless defined $status;
66  is $status, 0, 'indirect and global END blocks executed at the end of a forked process (RT #99083)';
67
68  $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 }';
69  skip $run_perl_failed => ($tests - 1) unless defined $status;
70  is $status, 0, 'indirect and local END blocks executed at the end of a forked process';
71 }