Commit | Line | Data |
7b43481a |
1 | # Testing of Pod::Find |
2 | # Author: Marek Rouchal <marek@saftsack.fs.uni-bayreuth.de> |
3 | |
4 | $| = 1; |
5 | |
6 | use Test; |
7 | |
8 | BEGIN { plan tests => 4 } |
9 | |
10 | use Pod::Find qw(pod_find pod_where); |
11 | use File::Spec; |
12 | |
13 | # load successful |
14 | ok(1); |
15 | |
16 | require Cwd; |
17 | my $THISDIR = Cwd::cwd(); |
18 | my $VERBOSE = 0; |
16be52b8 |
19 | my $lib_dir = File::Spec->catdir($THISDIR,'lib'); |
20 | if ($^O eq 'VMS') { |
21 | $lib_dir = VMS::Filespec::unixify(File::Spec->catdir($THISDIR,'-','lib','pod')); |
22 | $Qlib_dir = $lib_dir; |
23 | $Qlib_dir =~ s#\/#::#g; |
24 | } |
25 | print "### searching $lib_dir\n"; |
26 | my %pods = pod_find("$lib_dir"); |
7b43481a |
27 | my $result = join(',', sort values %pods); |
16be52b8 |
28 | print "### found $result\n"; |
7b43481a |
29 | my $compare = join(',', qw( |
30 | Pod::Checker |
31 | Pod::Find |
32 | Pod::InputObjects |
33 | Pod::ParseUtils |
34 | Pod::Parser |
35 | Pod::PlainText |
36 | Pod::Select |
37 | Pod::Usage |
38 | )); |
16be52b8 |
39 | if ($^O eq 'VMS') { |
40 | $compare = lc($compare); |
051b35bf |
41 | $result = join(',', sort grep(/pod::/, values %pods)); |
16be52b8 |
42 | $result =~ s/$Qlib_dir/pod::/g; |
43 | my $count = 0; |
44 | my @result = split(/,/,$result); |
45 | my @compare = split(/,/,$compare); |
46 | foreach(@compare) { |
47 | $count += grep {/$_/} @result; |
48 | } |
49 | ok($count/($#result+1)-1,$#compare); |
50 | } |
51 | else { |
52 | ok($result,$compare); |
53 | } |
7b43481a |
54 | |
55 | # File::Find is located in this place since eons |
56 | # and on all platforms, hopefully |
57 | |
16be52b8 |
58 | print "### searching for File::Find\n"; |
7b43481a |
59 | $result = pod_where({ -inc => 1, -verbose => $VERBOSE }, 'File::Find') |
60 | || 'undef - pod not found!'; |
16be52b8 |
61 | print "### found $result\n"; |
7b43481a |
62 | |
63 | require Config; |
16be52b8 |
64 | if ($^O eq 'VMS') { # privlib is perl_root:[lib] OK but not under mms |
65 | $compare = "lib.File]Find.pm"; |
66 | $result =~ s/perl_root:\[\-?\.?//i; |
67 | $result =~ s/\[\-?\.?//i; # needed under `mms test` |
68 | ok($result,$compare); |
69 | } |
70 | else { |
71 | $compare = File::Spec->catfile($Config::Config{privlib},"File","Find.pm"); |
72 | ok(_canon($result),_canon($compare)); |
73 | } |
7b43481a |
74 | |
75 | # Search for a documentation pod rather than a module |
16be52b8 |
76 | print "### searching for perlfunc.pod\n"; |
7b43481a |
77 | $result = pod_where({ -inc => 1, -verbose => $VERBOSE }, 'perlfunc') |
78 | || 'undef - perlfunc.pod not found!'; |
16be52b8 |
79 | print "### found $result\n"; |
7b43481a |
80 | |
16be52b8 |
81 | if ($^O eq 'VMS') { # privlib is perl_root:[lib] unfortunately |
82 | $compare = "/lib/pod/perlfunc.pod"; |
83 | $result = VMS::Filespec::unixify($result); |
84 | $result =~ s/perl_root\///i; |
85 | $result =~ s/^\.\.//; # needed under `mms test` |
86 | ok($result,$compare); |
87 | } |
88 | else { |
89 | $compare = File::Spec->catfile($Config::Config{privlib},"perlfunc.pod"); |
90 | ok(_canon($result),_canon($compare)); |
91 | } |
7b43481a |
92 | |
93 | # make the path as generic as possible |
94 | sub _canon |
95 | { |
96 | my ($path) = @_; |
97 | $path = File::Spec->canonpath($path); |
98 | my @comp = File::Spec->splitpath($path); |
99 | my @dir = File::Spec->splitdir($comp[1]); |
100 | $comp[1] = File::Spec->catdir(@dir); |
101 | $path = File::Spec->catpath(@dir); |
102 | $path = uc($path) if File::Spec->case_tolerant; |
103 | $path; |
104 | } |
105 | |