Skip to content

Commit b00daa2

Browse files
authored
Merge pull request #11 from atoomic/test-fixup
Avoid wait forever from t/pod/pod2usage2.t
2 parents a11ba16 + 9bc8cea commit b00daa2

File tree

6 files changed

+95
-31
lines changed

6 files changed

+95
-31
lines changed

.github/workflows/testsuite.yml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,41 @@ jobs:
1818

1919
runs-on: ubuntu-latest
2020

21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: install perl-doc
24+
run: |
25+
sudo apt-get clean
26+
sudo apt-get install -y perl-doc perl-doc-html
27+
- name: perl -V
28+
run: perl -V
29+
- name: Install dependencies
30+
uses: perl-actions/install-with-cpm@v1
31+
with:
32+
cpanfile: "cpanfile"
33+
- run: perl Makefile.PL
34+
- run: make
35+
- run: make test
36+
- name: remove pod2usage
37+
run: |
38+
POD=$(which pod2usage)
39+
echo "pod2usage: $POD"
40+
sudo rm -f $POD ||:
41+
- run: sudo make install
42+
- run: which pod2usage
43+
44+
# ------------------------------------------------------------------------
45+
46+
no-perl-doc:
47+
needs: [ubuntu]
48+
env:
49+
PERL_USE_UNSAFE_INC: 0
50+
AUTHOR_TESTING: 1
51+
AUTOMATED_TESTING: 1
52+
RELEASE_TESTING: 1
53+
54+
runs-on: ubuntu-latest
55+
2156
steps:
2257
- uses: actions/checkout@v2
2358
- name: perl -V
@@ -111,7 +146,7 @@ jobs:
111146
- name: Set up Perl
112147
run: |
113148
choco install strawberryperl
114-
echo "##[add-path]C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin"
149+
echo "C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin" >> $GITHUB_PATH
115150
- name: perl -V
116151
run: perl -V
117152
- name: Install dependencies

META.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
"Cwd" : "0",
5454
"File::Basename" : "0",
5555
"File::Spec" : "0.82",
56+
"Pod::Perldoc" : "3.28",
57+
"Pod::Simple" : "3.40",
5658
"Pod::Text" : "4.00",
5759
"perl" : "5.006"
5860
}

Makefile.PL

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ my %WriteMakefileArgs = (
2020
"Cwd" => 0,
2121
"File::Basename" => 0,
2222
"File::Spec" => "0.82",
23+
"Pod::Perldoc" => "3.28",
24+
"Pod::Simple" => "3.40",
2325
"Pod::Text" => "4.00"
2426
},
2527
"TEST_REQUIRES" => {
@@ -47,6 +49,8 @@ my %FallbackPrereqs = (
4749
"ExtUtils::MakeMaker" => 0,
4850
"File::Basename" => 0,
4951
"File::Spec" => "0.82",
52+
"Pod::Perldoc" => "3.28",
53+
"Pod::Simple" => "3.40",
5054
"Pod::Text" => "4.00",
5155
"Test::More" => "0.60",
5256
"blib" => 0

cpanfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use warnings;
33

44
on 'runtime' => sub {
55
requires 'Pod::Text' => '4.00'; # to avoid issues with wrong test results
6+
requires 'Pod::Simple' => '3.40'; # to avoid issues with wrong test results
7+
requires 'Pod::Perldoc' => '3.28'; # to avoid issues with wrong test results
68
requires 'Cwd';
79
requires 'File::Basename';
810
requires 'File::Spec' => '0.82';

t/00-report-prereqs.dd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ do { my $x = {
2828
'Cwd' => '0',
2929
'File::Basename' => '0',
3030
'File::Spec' => '0.82',
31+
'Pod::Perldoc' => '3.28',
32+
'Pod::Simple' => '3.40',
3133
'Pod::Text' => '4.00',
3234
'perl' => '5.006'
3335
}

t/pod/pod2usage2.t

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,32 @@ BEGIN {
1919
sub getoutput
2020
{
2121
my ($code) = @_;
22-
my $pid = open(TEST_IN, "-|");
23-
unless(defined $pid) {
24-
die "Cannot fork: $!";
25-
}
26-
if($pid) {
22+
my $pid = open(my $in, "-|");
23+
die "Cannot fork: $!" unless defined $pid;
24+
if ($pid) {
2725
# parent
28-
my @out = <TEST_IN>;
29-
close(TEST_IN);
26+
my @out = <$in>;
27+
close($in);
28+
3029
my $exit = $?>>8;
3130
s/^/#/ for @out;
31+
3232
local $" = "";
33+
3334
print "#EXIT=$exit OUTPUT=+++#@out#+++\n";
34-
return($exit, join("",@out));
35+
waitpid( $pid, 1 );
36+
37+
return ($exit, join("", @out) );
3538
}
3639
# child
37-
open(STDERR, ">&STDOUT");
40+
open (STDERR, ">&STDOUT");
41+
3842
Test::More->builder->no_ending(1);
39-
&$code;
43+
local $SIG{ALRM} = sub { die "Alarm reached" };
44+
alarm(600);
45+
46+
# this could hang
47+
$code->();
4048
print "--NORMAL-RETURN--\n";
4149
exit 0;
4250
}
@@ -72,17 +80,17 @@ ok (compare ($text, <<'EOT'), "Output test pod2usage (-message => '...', -verbos
7280
#You naughty person, what did you say?
7381
# Usage:
7482
# frobnicate [ -r | --recursive ] [ -f | --force ] file ...
75-
#
83+
#
7684
# Options:
7785
# -r | --recursive
7886
# Run recursively.
79-
#
87+
#
8088
# -f | --force
8189
# Just do it!
82-
#
90+
#
8391
# -n number
8492
# Specify number of frobs, default is 42.
85-
#
93+
#
8694
EOT
8795

8896
($exit, $text) = getoutput( sub { pod2usage(
@@ -217,7 +225,7 @@ is ($exit, 0, "Exit status pod2usage with USAGE and verbose=99")
217225
ok (compare ($text, <<'EOT'), "Output test pod2usage with USAGE and verbose=99") or diag "Got:\n$text\n";
218226
#Usage:
219227
# This is a test for CPAN#33020
220-
#
228+
#
221229
EOT
222230

223231
# test with self
@@ -241,13 +249,13 @@ ok (compare ($text, <<'EOT'), "Output test pod2usage with self") or diag "Got:\n
241249
# pod2usage($exit_status);
242250
#
243251
# pod2usage( { -message => $message_text ,
244-
# -exitval => $exit_status ,
245-
# -verbose => $verbose_level,
252+
# -exitval => $exit_status ,
253+
# -verbose => $verbose_level,
246254
# -output => $filehandle } );
247255
#
248256
# pod2usage( -msg => $message_text ,
249-
# -exitval => $exit_status ,
250-
# -verbose => $verbose_level,
257+
# -exitval => $exit_status ,
258+
# -verbose => $verbose_level,
251259
# -output => $filehandle );
252260
#
253261
# pod2usage( -verbose => 2,
@@ -352,19 +360,30 @@ like ($text, qr/frobnicate - do what I mean/, "Output test pod2usage with relati
352360
{ no warnings;
353361
*Pod::Usage::initialize = sub { 1; };
354362
}
355-
($exit, $text) = getoutput( sub {
356-
my $devnull = File::Spec->devnull();
357-
open(SAVE_STDOUT, '>&', \*STDOUT);
358-
open(STDOUT, '>', $devnull);
359-
pod2usage({ -verbose => 2, -input => $0, -output => \*STDOUT, -exit => 0, -message => 'Special perldoc case', -perldocopt => '-i' });
360-
open(STDOUT, '>&', \*SAVE_STDOUT);
361-
} );
362-
is ($exit, 0, "Exit status pod2usage with special perldoc case");
363-
# output went to devnull
364-
like ($text, qr/^\s*$/s, "Output test pod2usage with special perldoc case") or diag "Got:\n$text\n";
363+
364+
SKIP: {
365+
my $perldoc = $^X . 'doc';
366+
skip "Missing perldoc binary", 2 unless -x $perldoc;
367+
368+
my $out = qx[$perldoc 2>&1] || '';
369+
skip "Need perl-doc package", 2 if $out =~ qr[You need to install the perl-doc package to use this program];
370+
371+
($exit, $text) = getoutput( sub {
372+
require Pod::Perldoc;
373+
my $devnull = File::Spec->devnull();
374+
open(SAVE_STDOUT, '>&', \*STDOUT);
375+
open(STDOUT, '>', $devnull);
376+
pod2usage({ -verbose => 2, -input => $0, -output => \*STDOUT, -exit => 0, -message => 'Special perldoc case', -perldocopt => '-i' });
377+
open(STDOUT, '>&', \*SAVE_STDOUT);
378+
} );
379+
is ($exit, 0, "Exit status pod2usage with special perldoc case");
380+
# output went to devnull
381+
like ($text, qr/^\s*$/s, "Output test pod2usage with special perldoc case") or diag "Got:\n$text\n";
382+
383+
}
365384

366385
# bad regexp syntax
367-
($exit, $text) = getoutput( sub { pod2usage(-verbose => 99, -sections => 'DESCRIPTION{BLAH') } );
386+
($exit, $text) = getoutput( sub { pod2usage( -verbose => 99, -sections => 'DESCRIPTION{BLAH') } );
368387
like ($text, qr/Bad regular expression/, "Output test pod2usage with bad section regexp");
369388

370389
} # end SKIP

0 commit comments

Comments
 (0)