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);
17 use Test::More tests => 4;
21 use_ok('Pod::Find', qw(pod_find pod_where));
27 my $THISDIR = Cwd::cwd();
28 my $VERBOSE = $ENV{PERL_CORE} ? 0 : ($ENV{TEST_VERBOSE} || 0);
29 my $lib_dir = $ENV{PERL_CORE} ?
30 File::Spec->catdir('pod', 'testpods', 'lib')
31 : File::Spec->catdir($THISDIR,'lib');
38 $lib_dir = $ENV{PERL_CORE} ?
39 VMS::Filespec::unixify(File::Spec->catdir('pod', 'testpods', 'lib'))
40 : VMS::Filespec::unixify(File::Spec->catdir($THISDIR,'-','lib','pod'));
42 $Qlib_dir =~ s#\/#::#g;
45 if (eval 'require VMS::Feature') {
46 $vms_unix_rpt = VMS::Feature::current("filename_unix_report");
47 $vms_efs = VMS::Feature::current("efs_charset");
49 my $unix_rpt = $ENV{'DECC$FILENAME_UNIX_REPORT'} || '';
50 my $efs_charset = $ENV{'DECC$EFS_CHARSET'} || '';
51 $vms_unix_rpt = $unix_rpt =~ /^[ET1]/i;
52 $vms_efs = $efs_charset =~ /^[ET1]/i;
55 # Traditional VMS mode only if VMS is not in UNIX compatible mode.
56 $unix_mode = ($vms_efs && $vms_unix_rpt);
59 print "### 2. searching $lib_dir\n";
60 my %pods = pod_find($lib_dir);
61 my $result = join(',', sort values %pods);
62 print "### found $result\n";
63 my $compare = $ENV{PERL_CORE} ?
78 $compare = lc($compare);
79 my $undollared = $Qlib_dir;
80 $undollared =~ s/\$/\\\$/g;
81 $undollared =~ s/\-/\\\-/g;
82 $result =~ s/$undollared/pod::/g;
85 my @result = split(/,/,$result);
86 my @compare = split(/,/,$compare);
88 $count += grep {/$_/} @result;
90 is($count/($#result+1)-1,$#compare);
92 elsif (File::Spec->case_tolerant || $^O eq 'dos') {
93 is(lc $result,lc $compare);
99 print "### 3. searching for File::Find\n";
100 $result = pod_where({ -inc => 1, -verbose => $VERBOSE }, 'File::Find')
101 || 'undef - pod not found!';
102 print "### found $result\n";
105 if ($^O eq 'VMS') { # privlib is perl_root:[lib] OK but not under mms
107 $compare = "../lib/File/Find.pm";
109 $compare = "lib.File]Find.pm";
111 $result =~ s/perl_root:\[\-?\.?//i;
112 $result =~ s/\[\-?\.?//i; # needed under `mms test`
113 is($result,$compare);
116 $compare = $ENV{PERL_CORE} ?
117 File::Spec->catfile(File::Spec->updir, 'lib','File','Find.pm')
118 : File::Spec->catfile($Config::Config{privlibexp},"File","Find.pm");
119 my $resfile = _canon($result);
120 my $cmpfile = _canon($compare);
121 if($^O =~ /dos|win32/i && $resfile =~ /~\d(?=\\|$)/) {
122 # we have ~1 short filenames
123 $resfile = quotemeta($resfile);
124 $resfile =~ s/\\~\d(?=\\|$)/[^\\\\]+/g;
125 ok($cmpfile =~ /^$resfile$/, "pod_where found File::Find (with long filename matching)") ||
126 diag("'$cmpfile' does not match /^$resfile\$/");
128 is($resfile,$cmpfile,"pod_where found File::Find");
132 # Search for a documentation pod rather than a module
133 my $searchpod = 'Stuff';
134 print "### 4. searching for $searchpod.pod\n";
136 { -dirs => [ File::Spec->catdir(
137 $ENV{PERL_CORE} ? () : qw(t), 'pod', 'testpods', 'lib', 'Pod') ],
138 -verbose => $VERBOSE }, $searchpod)
139 || "undef - $searchpod.pod not found!";
140 print "### found $result\n";
142 $compare = File::Spec->catfile(
143 $ENV{PERL_CORE} ? () : qw(t),
144 'pod', 'testpods', 'lib', 'Pod' ,'Stuff.pm');
145 is(_canon($result),_canon($compare));
148 # make the path as generic as possible
152 $path = File::Spec->canonpath($path);
153 my @comp = File::Spec->splitpath($path);
154 my @dir = File::Spec->splitdir($comp[1]);
155 $comp[1] = File::Spec->catdir(@dir);
156 $path = File::Spec->catpath(@comp);
157 $path = uc($path) if File::Spec->case_tolerant;
158 print "### general path: $path\n" if $VERBOSE;