1N/A# Testing of Pod::Find
1N/A# Author: Marek Rouchal <marek@saftsack.fs.uni-bayreuth.de>
1N/A
1N/ABEGIN {
1N/A if($ENV{PERL_CORE}) {
1N/A chdir 't' if -d 't';
1N/A # The ../../../../../lib is for finding lib/utf8.pm
1N/A # when running under all-utf8 settings (pod/find.t)
1N/A # does not directly require lib/utf8.pm but regular
1N/A # expressions will need that.
1N/A @INC = qw(../lib ../../../../../lib);
1N/A }
1N/A}
1N/A
1N/A$| = 1;
1N/A
1N/Ause Test;
1N/A
1N/ABEGIN {
1N/A plan tests => 4;
1N/A use File::Spec;
1N/A}
1N/A
1N/Ause Pod::Find qw(pod_find pod_where);
1N/Ause File::Spec;
1N/A
1N/A# load successful
1N/Aok(1);
1N/A
1N/Arequire Cwd;
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/Aif ($^O eq 'VMS') {
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/A}
1N/A
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 join(',', sort qw(
1N/A Pod::Stuff
1N/A))
1N/A : join(',', qw(
1N/A Pod::Checker
1N/A Pod::Find
1N/A Pod::InputObjects
1N/A Pod::ParseUtils
1N/A Pod::Parser
1N/A Pod::PlainText
1N/A Pod::Select
1N/A Pod::Usage
1N/A));
1N/Aif ($^O eq 'VMS') {
1N/A $compare = lc($compare);
1N/A my $undollared = $Qlib_dir;
1N/A $undollared =~ s/\$/\\\$/g;
1N/A $undollared =~ s/\-/\\\-/g;
1N/A $result =~ s/$undollared/pod::/g;
1N/A $result =~ s/\$//g;
1N/A my $count = 0;
1N/A my @result = split(/,/,$result);
1N/A my @compare = split(/,/,$compare);
1N/A foreach(@compare) {
1N/A $count += grep {/$_/} @result;
1N/A }
1N/A ok($count/($#result+1)-1,$#compare);
1N/A}
1N/Aelsif (File::Spec->case_tolerant || $^O eq 'dos') {
1N/A ok(lc $result,lc $compare);
1N/A}
1N/Aelse {
1N/A ok($result,$compare);
1N/A}
1N/A
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/A
1N/Arequire Config;
1N/Aif ($^O eq 'VMS') { # privlib is perl_root:[lib] OK but not under mms
1N/A $compare = "lib.File]Find.pm";
1N/A $result =~ s/perl_root:\[\-?\.?//i;
1N/A $result =~ s/\[\-?\.?//i; # needed under `mms test`
1N/A ok($result,$compare);
1N/A}
1N/Aelse {
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}
1N/A
1N/A# Search for a documentation pod rather than a module
1N/Amy $searchpod = $ENV{PERL_CORE} ? 'Stuff' : 'perlfunc';
1N/Aprint "### searching for $searchpod.pod\n";
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/A || "undef - $searchpod.pod not found!";
1N/Aprint "### found $result\n";
1N/A
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/A}
1N/Aelsif ($^O eq 'VMS') { # privlib is perl_root:[lib] unfortunately
1N/A $compare = "/lib/pod/perlfunc.pod";
1N/A $result = VMS::Filespec::unixify($result);
1N/A $result =~ s/perl_root\///i;
1N/A $result =~ s/^\.\.//; # needed under `mms test`
1N/A ok($result,$compare);
1N/A}
1N/Aelse {
1N/A $compare = File::Spec->catfile($Config::Config{privlib},
1N/A ($^O =~ /macos|darwin|cygwin/i ? 'pods' : 'pod'),"perlfunc.pod");
1N/A ok(_canon($result),_canon($compare));
1N/A}
1N/A
1N/A# make the path as generic as possible
1N/Asub _canon
1N/A{
1N/A my ($path) = @_;
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;
1N/A $path;
1N/A}
1N/A