This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
t/pod/find.t on VMS
[perl5.git] / t / pod / find.t
CommitLineData
7b43481a
JH
1# Testing of Pod::Find
2# Author: Marek Rouchal <marek@saftsack.fs.uni-bayreuth.de>
3
4$| = 1;
5
6use Test;
7
8ac1de08
MS
8BEGIN {
9 plan tests => 4;
10 use File::Spec;
8ac1de08 11}
7b43481a
JH
12
13use Pod::Find qw(pod_find pod_where);
7b43481a
JH
14
15# load successful
16ok(1);
17
18require Cwd;
7b43481a 19my $VERBOSE = 0;
8ac1de08 20my $lib_dir = File::Spec->catdir('pod', 'testpods', 'lib');
16be52b8 21if ($^O eq 'VMS') {
8ac1de08 22 $lib_dir = VMS::Filespec::unixify(File::Spec->catdir('pod', 'testpods', 'lib'));
16be52b8
PP
23 $Qlib_dir = $lib_dir;
24 $Qlib_dir =~ s#\/#::#g;
25}
26print "### searching $lib_dir\n";
8ac1de08
MS
27my %pods = pod_find($lib_dir);
28my $result = join(',', sort values %pods);
29my $compare = join(',', sort qw(
30 Pod::Stuff
7b43481a 31));
16be52b8
PP
32if ($^O eq 'VMS') {
33 $compare = lc($compare);
8ac1de08 34 $result = join(',', sort values %pods);
e4dfc136
CL
35 my $undollared = $Qlib_dir;
36 $undollared =~ s/\$/\\\$/g;
37 $undollared =~ s/\-/\\\-/g;
38 $result =~ s/$undollared/pod::/g;
16be52b8
PP
39 my $count = 0;
40 my @result = split(/,/,$result);
41 my @compare = split(/,/,$compare);
42 foreach(@compare) {
43 $count += grep {/$_/} @result;
44 }
45 ok($count/($#result+1)-1,$#compare);
46}
47else {
48 ok($result,$compare);
49}
7b43481a 50
7b43481a 51
16be52b8 52print "### searching for File::Find\n";
7b43481a
JH
53$result = pod_where({ -inc => 1, -verbose => $VERBOSE }, 'File::Find')
54 || 'undef - pod not found!';
16be52b8 55print "### found $result\n";
7b43481a
JH
56
57require Config;
16be52b8
PP
58if ($^O eq 'VMS') { # privlib is perl_root:[lib] OK but not under mms
59 $compare = "lib.File]Find.pm";
60 $result =~ s/perl_root:\[\-?\.?//i;
61 $result =~ s/\[\-?\.?//i; # needed under `mms test`
62 ok($result,$compare);
63}
64else {
8ac1de08 65 $compare = File::Spec->catfile(File::Spec->updir, 'lib','File','Find.pm');
16be52b8
PP
66 ok(_canon($result),_canon($compare));
67}
7b43481a
JH
68
69# Search for a documentation pod rather than a module
8ac1de08
MS
70print "### searching for Stuff.pod\n";
71my $search = File::Spec->catdir('pod', 'testpods', 'lib', 'Pod');
72$result = pod_where({ -dirs => [$search], -verbose => $VERBOSE }, 'Stuff')
73 || 'undef - Stuff.pod not found!';
16be52b8 74print "### found $result\n";
7b43481a 75
8ac1de08
MS
76$compare = File::Spec->catfile('pod', 'testpods', 'lib', 'Pod' ,'Stuff.pod');
77ok(_canon($result),_canon($compare));
7b43481a
JH
78
79# make the path as generic as possible
80sub _canon
81{
82 my ($path) = @_;
83 $path = File::Spec->canonpath($path);
84 my @comp = File::Spec->splitpath($path);
85 my @dir = File::Spec->splitdir($comp[1]);
86 $comp[1] = File::Spec->catdir(@dir);
87 $path = File::Spec->catpath(@dir);
88 $path = uc($path) if File::Spec->case_tolerant;
89 $path;
90}
91