2 # Author: Marek Rouchal <marek@saftsack.fs.uni-bayreuth.de>
7 # The ../../../../../lib is for finding lib/utf8.pm
8 # when running under all-utf8 settings (pod/find.t)
9 # does not directly require lib/utf8.pm but regular
10 # expressions will need that.
11 @INC = qw(../lib ../../../../../lib);
24 use Pod::Find qw(pod_find pod_where);
31 my $THISDIR = Cwd::cwd();
32 my $VERBOSE = $ENV{PERL_CORE} ? 0 : ($ENV{TEST_VERBOSE} || 0);
33 my $lib_dir = $ENV{PERL_CORE} ?
34 File::Spec->catdir('pod', 'testpods', 'lib')
35 : File::Spec->catdir($THISDIR,'lib');
37 $lib_dir = $ENV{PERL_CORE} ?
38 VMS::Filespec::unixify(File::Spec->catdir('pod', 'testpods', 'lib'))
39 : VMS::Filespec::unixify(File::Spec->catdir($THISDIR,'-','lib','pod'));
41 $Qlib_dir =~ s#\/#::#g;
44 print "### searching $lib_dir\n";
45 my %pods = pod_find($lib_dir);
46 my $result = join(',', sort values %pods);
47 print "### found $result\n";
48 my $compare = $ENV{PERL_CORE} ?
63 $compare = lc($compare);
64 my $undollared = $Qlib_dir;
65 $undollared =~ s/\$/\\\$/g;
66 $undollared =~ s/\-/\\\-/g;
67 $result =~ s/$undollared/pod::/g;
70 my @result = split(/,/,$result);
71 my @compare = split(/,/,$compare);
73 $count += grep {/$_/} @result;
75 ok($count/($#result+1)-1,$#compare);
77 elsif (File::Spec->case_tolerant || $^O eq 'dos') {
78 ok(lc $result,lc $compare);
84 print "### searching for File::Find\n";
85 $result = pod_where({ -inc => 1, -verbose => $VERBOSE }, 'File::Find')
86 || 'undef - pod not found!';
87 print "### found $result\n";
90 if ($^O eq 'VMS') { # privlib is perl_root:[lib] OK but not under mms
91 $compare = "lib.File]Find.pm";
92 $result =~ s/perl_root:\[\-?\.?//i;
93 $result =~ s/\[\-?\.?//i; # needed under `mms test`
97 $compare = $ENV{PERL_CORE} ?
98 File::Spec->catfile(File::Spec->updir, 'lib','File','Find.pm')
99 : File::Spec->catfile($Config::Config{privlib},"File","Find.pm");
100 ok(_canon($result),_canon($compare));
103 # Search for a documentation pod rather than a module
104 my $searchpod = $ENV{PERL_CORE} ? 'Stuff' : 'perlfunc';
105 print "### searching for $searchpod.pod\n";
106 $result = pod_where($ENV{PERL_CORE} ?
107 { -dirs => [ File::Spec->catdir('pod', 'testpods', 'lib', 'Pod') ],
108 -verbose => $VERBOSE }
109 : { -inc => 1, -verbose => $VERBOSE }, $searchpod)
110 || "undef - $searchpod.pod not found!";
111 print "### found $result\n";
113 if($ENV{PERL_CORE}) {
114 $compare = File::Spec->catfile('pod', 'testpods', 'lib', 'Pod' ,'Stuff.pm');
115 ok(_canon($result),_canon($compare));
117 elsif ($^O eq 'VMS') { # privlib is perl_root:[lib] unfortunately
118 $compare = "/lib/pod/perlfunc.pod";
119 $result = VMS::Filespec::unixify($result);
120 $result =~ s/perl_root\///i;
121 $result =~ s/^\.\.//; # needed under `mms test`
122 ok($result,$compare);
125 $compare = File::Spec->catfile($Config::Config{privlib},
126 ($^O =~ /macos|darwin|cygwin/i ? 'pods' : 'pod'),"perlfunc.pod");
127 ok(_canon($result),_canon($compare));
130 # make the path as generic as possible
134 $path = File::Spec->canonpath($path);
135 my @comp = File::Spec->splitpath($path);
136 my @dir = File::Spec->splitdir($comp[1]);
137 $comp[1] = File::Spec->catdir(@dir);
138 $path = File::Spec->catpath(@comp);
139 $path = uc($path) if File::Spec->case_tolerant;
140 print "### general path: $path\n" if $VERBOSE;