1N/A# Testing of Pod::Find
1N/A# Author: Marek Rouchal <marek@saftsack.fs.uni-bayreuth.de>
1N/A if($ENV{PERL_CORE}) {
1N/A chdir 't' if -d 't';
1N/A # expressions will need that.
1N/A @INC = qw(../lib ../../../../../lib);
1N/Ause Pod::Find qw(pod_find pod_where);
1N/Amy $THISDIR = Cwd::cwd();
1N/Amy $VERBOSE = $ENV{PERL_CORE} ? 0 : ($ENV{TEST_VERBOSE} || 0);
1N/Amy $lib_dir = $ENV{PERL_CORE} ?
1N/A File::Spec->catdir('pod', 'testpods', 'lib')
1N/A : File::Spec->catdir($THISDIR,'lib');
1N/A $lib_dir = $ENV{PERL_CORE} ?
1N/A VMS::Filespec::unixify(File::Spec->catdir('pod', 'testpods', 'lib'))
1N/A : VMS::Filespec::unixify(File::Spec->catdir($THISDIR,'-','lib','pod'));
1N/A $Qlib_dir = $lib_dir;
1N/A $Qlib_dir =~ s#\/#::#g;
1N/Aprint "### searching $lib_dir\n";
1N/Amy %pods = pod_find($lib_dir);
1N/Amy $result = join(',', sort values %pods);
1N/Aprint "### found $result\n";
1N/Amy $compare = $ENV{PERL_CORE} ?
1N/A $compare = lc($compare);
1N/A my $undollared = $Qlib_dir;
1N/A $undollared =~ s/\$/\\\$/g;
1N/A $undollared =~ s/\-/\\\-/g;
1N/A my @result = split(/,/,$result);
1N/A my @compare = split(/,/,$compare);
1N/A $count += grep {/$_/} @result;
1N/A ok($count/($#result+1)-1,$#compare);
1N/Aelsif (File::Spec->case_tolerant || $^O eq 'dos') {
1N/A ok(lc $result,lc $compare);
1N/A ok($result,$compare);
1N/Aprint "### searching for File::Find\n";
1N/A$result = pod_where({ -inc => 1, -verbose => $VERBOSE }, 'File::Find')
1N/A || 'undef - pod not found!';
1N/Aprint "### found $result\n";
1N/Aif ($^O eq 'VMS') { # privlib is perl_root:[lib] OK but not under mms
1N/A $result =~ s/\[\-?\.?//i; # needed under `mms test`
1N/A ok($result,$compare);
1N/A $compare = $ENV{PERL_CORE} ?
1N/A File::Spec->catfile(File::Spec->updir, 'lib','File','
Find.pm')
1N/A : File::Spec->catfile($Config::Config{privlib},"File","
Find.pm");
1N/A ok(_canon($result),_canon($compare));
1N/A# Search for a documentation pod rather than a module
1N/Amy $searchpod = $ENV{PERL_CORE} ? 'Stuff' : 'perlfunc';
1N/A$result = pod_where($ENV{PERL_CORE} ?
1N/A { -dirs => [ File::Spec->catdir('pod', 'testpods', 'lib', 'Pod') ],
1N/A -verbose => $VERBOSE }
1N/A : { -inc => 1, -verbose => $VERBOSE }, $searchpod)
1N/Aprint "### found $result\n";
1N/Aif($ENV{PERL_CORE}) {
1N/A $compare = File::Spec->catfile('pod', 'testpods', 'lib', 'Pod' ,'
Stuff.pm');
1N/A ok(_canon($result),_canon($compare));
1N/Aelsif ($^O eq 'VMS') { # privlib is perl_root:[lib] unfortunately
1N/A $result = VMS::Filespec::unixify($result);
1N/A $result =~ s/^\.\.//; # needed under `mms test`
1N/A ok($result,$compare);
1N/A $compare = File::Spec->catfile($Config::Config{privlib},
1N/A ok(_canon($result),_canon($compare));
1N/A# make the path as generic as possible
1N/A $path = File::Spec->canonpath($path);
1N/A my @comp = File::Spec->splitpath($path);
1N/A my @dir = File::Spec->splitdir($comp[1]);
1N/A $comp[1] = File::Spec->catdir(@dir);
1N/A $path = File::Spec->catpath(@comp);
1N/A $path = uc($path) if File::Spec->case_tolerant;
1N/A print "### general path: $path\n" if $VERBOSE;