This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[patch] blead@25282 - VMS specific fixes. [2nd try]
[perl5.git] / t / pod / find.t
index 3a0b274..2058601 100644 (file)
@@ -1,64 +1,71 @@
 # Testing of Pod::Find
 # Author: Marek Rouchal <marek@saftsack.fs.uni-bayreuth.de>
 
+BEGIN {
+  if($ENV{PERL_CORE}) {
+    chdir 't' if -d 't';
+    # The ../../../../../lib is for finding lib/utf8.pm
+    # when running under all-utf8 settings (pod/find.t)
+    # does not directly require lib/utf8.pm but regular
+    # expressions will need that.
+    @INC = qw(../lib ../../../../../lib);
+  }
+}
+
 $| = 1;
 
 use Test;
 
-BEGIN { 
-  plan tests => 4; 
+BEGIN {
+  plan tests => 4;
   use File::Spec;
-  if ($^O eq 'VMS') {
-     # This magick is needed to make the VMS I/O system to believe
-     # that there's life after eight directory levels (this makes
-     # it believe there's life until sixteen levels).  The filesystem
-     # has no limitation as such.
-     $DEFAULT_DIR = $ENV{'DEFAULT'};
-     my $here = $DEFAULT_DIR;
-     my ($dev,$dir) = File::Spec->splitpath($here);
-     $dev =~ s/:$//;
-     $dev = $ENV{$dev} if exists($ENV{$dev});
-     $dev .= ':' if $dev !~ /:/;
-     $here = File::Spec->canonpath($dev.$dir);
-     $here =~ s/\]$/.]/;
-     system "define/nolog/job/trans=conceal temp_perl_base $here";
-     chdir('temp_perl_base:[000000]');
-  }
-}
-
-END {
-    chdir($DEFAULT_DIR) if $^O eq 'VMS';
-    system "deassign/job temp_perl_base";
 }
 
 use Pod::Find qw(pod_find pod_where);
+use File::Spec;
 
 # load successful
 ok(1);
 
 require Cwd;
-my $VERBOSE = 0;
-my $lib_dir = File::Spec->catdir('pod', 'testpods', 'lib');
+my $THISDIR = Cwd::cwd();
+my $VERBOSE = $ENV{PERL_CORE} ? 0 : ($ENV{TEST_VERBOSE} || 0);
+my $lib_dir = $ENV{PERL_CORE} ? 
+  File::Spec->catdir('pod', 'testpods', 'lib')
+  : File::Spec->catdir($THISDIR,'lib');
 if ($^O eq 'VMS') {
-    $lib_dir = VMS::Filespec::unixify(File::Spec->catdir('pod', 'testpods', 'lib'));
+    $lib_dir = $ENV{PERL_CORE} ?
+      VMS::Filespec::unixify(File::Spec->catdir('pod', 'testpods', 'lib'))
+      : VMS::Filespec::unixify(File::Spec->catdir($THISDIR,'-','lib','pod'));
     $Qlib_dir = $lib_dir;
     $Qlib_dir =~ s#\/#::#g;
 }
+
 print "### searching $lib_dir\n";
 my %pods = pod_find($lib_dir);
 my $result = join(',', sort values %pods);
-my $compare = join(',', sort qw(
+print "### found $result\n";
+my $compare = $ENV{PERL_CORE} ? 
+  join(',', sort qw(
     Pod::Stuff
-    Pod::Rhubarb
-    Like::And::Yeah
+))
+  : join(',', sort qw(
+    Pod::Checker
+    Pod::Find
+    Pod::InputObjects
+    Pod::ParseUtils
+    Pod::Parser
+    Pod::PlainText
+    Pod::Select
+    Pod::Usage
 ));
 if ($^O eq 'VMS') {
     $compare = lc($compare);
-    $result = join(',', sort values %pods);
     my $undollared = $Qlib_dir;
     $undollared =~ s/\$/\\\$/g;
     $undollared =~ s/\-/\\\-/g;
     $result =~ s/$undollared/pod::/g;
+    $result =~ s/\$//g;
     my $count = 0;
     my @result = split(/,/,$result);
     my @compare = split(/,/,$compare);
@@ -67,11 +74,13 @@ if ($^O eq 'VMS') {
     }
     ok($count/($#result+1)-1,$#compare);
 }
+elsif (File::Spec->case_tolerant || $^O eq 'dos') {
+    ok(lc $result,lc $compare);
+}
 else {
     ok($result,$compare);
 }
 
-
 print "### searching for File::Find\n";
 $result = pod_where({ -inc => 1, -verbose => $VERBOSE }, 'File::Find')
   || 'undef - pod not found!';
@@ -79,25 +88,45 @@ print "### found $result\n";
 
 require Config;
 if ($^O eq 'VMS') { # privlib is perl_root:[lib] OK but not under mms
+    $result = VMS::Filespec::vmsify($result); #if you want VMS you need to force it.
     $compare = "lib.File]Find.pm";
     $result =~ s/perl_root:\[\-?\.?//i;
     $result =~ s/\[\-?\.?//i; # needed under `mms test`
     ok($result,$compare);
 }
 else {
-    $compare = File::Spec->catfile(File::Spec->updir, 'lib','File','Find.pm');
+    $compare = $ENV{PERL_CORE} ?
+      File::Spec->catfile(File::Spec->updir, 'lib','File','Find.pm')
+      : File::Spec->catfile($Config::Config{privlib},"File","Find.pm");
     ok(_canon($result),_canon($compare));
 }
 
 # Search for a documentation pod rather than a module
-print "### searching for Stuff.pod\n";
-my $search = File::Spec->catdir('pod', 'testpods', 'lib', 'Pod');
-$result = pod_where({ -dirs => [$search], -verbose => $VERBOSE }, 'Stuff')
-  || 'undef - Stuff.pod not found!';
+my $searchpod = $ENV{PERL_CORE} ? 'Stuff' : 'perlfunc';
+print "### searching for $searchpod.pod\n";
+$result = pod_where($ENV{PERL_CORE} ?
+  { -dirs => [ File::Spec->catdir('pod', 'testpods', 'lib', 'Pod') ],
+    -verbose => $VERBOSE }
+  : { -inc => 1, -verbose => $VERBOSE }, $searchpod)
+  || "undef - $searchpod.pod not found!";
 print "### found $result\n";
 
-$compare = File::Spec->catfile('pod', 'testpods', 'lib', 'Pod' ,'Stuff.pod');
-ok(_canon($result),_canon($compare));
+if($ENV{PERL_CORE}) {
+    $compare = File::Spec->catfile('pod', 'testpods', 'lib', 'Pod' ,'Stuff.pm');
+    ok(_canon($result),_canon($compare));
+}
+elsif ($^O eq 'VMS') { # privlib is perl_root:[lib] unfortunately
+    $compare = "/lib/pod/perlfunc.pod";
+    $result = VMS::Filespec::unixify($result);
+    $result =~ s/perl_root\///i;
+    $result =~ s/^\.\.//;  # needed under `mms test`
+    ok($result,$compare);
+}
+else {
+    $compare = File::Spec->catfile($Config::Config{privlib},
+      ($^O =~ /macos|darwin|cygwin/i ? 'pods' : 'pod'),"perlfunc.pod");
+    ok(_canon($result),_canon($compare));
+}
 
 # make the path as generic as possible
 sub _canon
@@ -107,8 +136,9 @@ sub _canon
   my @comp = File::Spec->splitpath($path);
   my @dir = File::Spec->splitdir($comp[1]);
   $comp[1] = File::Spec->catdir(@dir);
-  $path = File::Spec->catpath(@dir);
+  $path = File::Spec->catpath(@comp);
   $path = uc($path) if File::Spec->case_tolerant;
+  print "### general path: $path\n" if $VERBOSE;
   $path;
 }