Add MIME::Base 2.12 from Gisle Aas, version number bumped to 2.13.
[p5sagit/p5-mst-13.2.git] / t / pod / find.t
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 { 
9   plan tests => 4; 
10   use File::Spec;
11 }
12
13 use Pod::Find qw(pod_find pod_where);
14
15 # load successful
16 ok(1);
17
18 require Cwd;
19 my $VERBOSE = 0;
20 my $lib_dir = File::Spec->catdir('pod', 'testpods', 'lib');
21 if ($^O eq 'VMS') {
22     $lib_dir = VMS::Filespec::unixify(File::Spec->catdir('pod', 'testpods', 'lib'));
23     $Qlib_dir = $lib_dir;
24     $Qlib_dir =~ s#\/#::#g;
25 }
26 print "### searching $lib_dir\n";
27 my %pods = pod_find($lib_dir);
28 my $result = join(',', sort values %pods);
29 my $compare = join(',', sort qw(
30     Pod::Stuff
31 ));
32 if ($^O eq 'VMS') {
33     $compare = lc($compare);
34     $result = join(',', sort values %pods);
35     my $undollared = $Qlib_dir;
36     $undollared =~ s/\$/\\\$/g;
37     $undollared =~ s/\-/\\\-/g;
38     $result =~ s/$undollared/pod::/g;
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 }
47 else {
48     ok($result,$compare);
49 }
50
51
52 print "### searching for File::Find\n";
53 $result = pod_where({ -inc => 1, -verbose => $VERBOSE }, 'File::Find')
54   || 'undef - pod not found!';
55 print "### found $result\n";
56
57 require Config;
58 if ($^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 }
64 else {
65     $compare = File::Spec->catfile(File::Spec->updir, 'lib','File','Find.pm');
66     ok(_canon($result),_canon($compare));
67 }
68
69 # Search for a documentation pod rather than a module
70 print "### searching for Stuff.pod\n";
71 my $search = File::Spec->catdir('pod', 'testpods', 'lib', 'Pod');
72 $result = pod_where({ -dirs => [$search], -verbose => $VERBOSE }, 'Stuff')
73   || 'undef - Stuff.pod not found!';
74 print "### found $result\n";
75
76 $compare = File::Spec->catfile('pod', 'testpods', 'lib', 'Pod' ,'Stuff.pod');
77 ok(_canon($result),_canon($compare));
78
79 # make the path as generic as possible
80 sub _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