X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fpod%2Ftestp2pt.pl;h=2ff8aa427a359cb7f91f4146ceb9d22754f679b7;hb=7ed149c909e2812f62b12bd7d09f4ccfb79e0041;hp=140de05a3a1bff5c431a55b951b72f84910422cd;hpb=360aca433d51a01ddd748b8606c6c288bdb2f7fc;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/pod/testp2pt.pl b/t/pod/testp2pt.pl index 140de05..2ff8aa4 100644 --- a/t/pod/testp2pt.pl +++ b/t/pod/testp2pt.pl @@ -3,8 +3,9 @@ package TestPodIncPlainText; BEGIN { use File::Basename; use File::Spec; + use Cwd qw(abs_path); push @INC, '..'; - my $THISDIR = dirname $0; + my $THISDIR = abs_path(dirname $0); unshift @INC, $THISDIR; require "testcmp.pl"; import TestCompare; @@ -12,24 +13,45 @@ BEGIN { push @INC, map { File::Spec->catfile($_, 'lib') } ($PARENTDIR, $THISDIR); } -use Pod::PlainText; -use vars qw(@ISA @EXPORT $MYPKG); #use strict; #use diagnostics; use Carp; use Exporter; #use File::Compare; +#use Cwd qw(abs_path); -@ISA = qw(Pod::PlainText); -@EXPORT = qw(&testpodplaintext); +use vars qw($MYPKG @EXPORT @ISA); $MYPKG = eval { (caller)[0] }; +@EXPORT = qw(&testpodplaintext); +BEGIN { + if ( $] >= 5.005_58 ) { + require Pod::Text; + @ISA = qw( Pod::Text ); + } + else { + require Pod::PlainText; + @ISA = qw( Pod::PlainText ); + } + require VMS::Filespec if $^O eq 'VMS'; +} ## Hardcode settings for TERMCAP and COLUMNS so we can try to get ## reproducible results between environments -@ENV{qw(TERMCAP COLUMNS)} = ('co=72:do=^J', 72); +@ENV{qw(TERMCAP COLUMNS)} = ('co=76:do=^J', 76); sub catfile(@) { File::Spec->catfile(@_); } +my $INSTDIR = abs_path(dirname $0); +$INSTDIR = VMS::Filespec::unixpath($INSTDIR) if $^O eq 'VMS'; +$INSTDIR =~ s#/$## if $^O eq 'VMS'; +$INSTDIR = (dirname $INSTDIR) if (basename($INSTDIR) eq 'pod'); +$INSTDIR = (dirname $INSTDIR) if (basename($INSTDIR) eq 't'); +my @PODINCDIRS = ( catfile($INSTDIR, 'lib', 'Pod'), + catfile($INSTDIR, 'scripts'), + catfile($INSTDIR, 'pod'), + catfile($INSTDIR, 't', 'pod') + ); + ## Find the path to the file to =include sub findinclude { my $self = shift; @@ -42,19 +64,8 @@ sub findinclude { ## 1. the directory containing this pod file my $thispoddir = dirname $self->input_file; ## 2. the parent directory of the above - my $parentdir = ($thispoddir eq '.') ? '..' : dirname $thispoddir; - ## 3. any Pod/ or scripts/ subdirectory of these two - my @dirs = (); - for ($thispoddir, $parentdir) { - my $dir = $_; - for ( qw(scripts lib) ) { - push @dirs, $dir, catfile($dir, $_), - catfile($dir, 'Pod'), - catfile($dir, $_, 'Pod'); - } - } - my %dirs = (map { ($_ => 1) } @dirs); - my @podincdirs = (sort keys %dirs); + my $parentdir = dirname $thispoddir; + my @podincdirs = ($thispoddir, $parentdir, @PODINCDIRS); for (@podincdirs) { my $incfile = catfile($_, $incname); @@ -88,6 +99,10 @@ sub command { print $out_fh "###### end =include $incbase #####\n" if ($incdebug); } +sub begin_input { + $_[0]->{_INFILE} = VMS::Filespec::unixify($_[0]->{_INFILE}) if $^O eq 'VMS'; +} + sub podinc2plaintext( $ $ ) { my ($infile, $outfile) = @_; local $_; @@ -110,7 +125,7 @@ sub testpodinc2plaintext( @ ) { return $msg; } - print "+ Running testpodinc2plaintext for '$testname'...\n"; + print "# Running testpodinc2plaintext for '$testname'...\n"; ## Compare the output against the expected result podinc2plaintext($infile, $outfile); if ( testcmp($outfile, $cmpfile) ) { @@ -144,12 +159,12 @@ sub testpodplaintext( @ ) { if ($opts{'-xrgen'}) { if ($opts{'-force'} or ! -e $cmpfile) { ## Create the comparison file - print "+ Creating expected result for \"$testname\"" . + print "# Creating expected result for \"$testname\"" . " pod2plaintext test ...\n"; podinc2plaintext($podfile, $cmpfile); } else { - print "+ File $cmpfile already exists" . + print "# File $cmpfile already exists" . " (use '-force' to regenerate it).\n"; } next; @@ -161,13 +176,13 @@ sub testpodplaintext( @ ) { -Cmp => $cmpfile; if ($failmsg) { ++$failed; - print "+\tFAILED. ($failmsg)\n"; + print "#\tFAILED. ($failmsg)\n"; print "not ok ", $failed+$passes, "\n"; } else { ++$passes; unlink($outfile); - print "+\tPASSED.\n"; + print "#\tPASSED.\n"; print "ok ", $failed+$passes, "\n"; } }