This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix Pod::Simple tests that use catdir on non-directories.
[perl5.git] / cpan / Pod-Simple / t / search20.t
1 BEGIN {
2     if($ENV{PERL_CORE}) {
3         chdir 't';
4         @INC = '../lib';
5     }
6 }
7
8 use strict;
9 use Pod::Simple::Search;
10 use Test;
11 BEGIN { plan tests => 11 }
12
13 print "# ", __FILE__,
14  ": Testing the scanning of several (well, two) docroots...\n";
15
16 my $x = Pod::Simple::Search->new;
17 die "Couldn't make an object!?" unless ok defined $x;
18
19 $x->inc(0);
20
21 $x->callback(sub {
22   print "#  ", join("  ", map "{$_}", @_), "\n";
23   return;
24 });
25
26 use File::Spec;
27 use Cwd;
28 my $cwd = cwd();
29 print "# CWD: $cwd\n";
30
31 sub source_path {
32     my $file = shift;
33     if ($ENV{PERL_CORE}) {
34         return "../lib/Pod/Simple/t/$file";
35     } else {
36         return $file;
37     }
38 }
39
40 my($here1, $here2);
41 if(        -e ($here1 = source_path('testlib1'))) {
42   die "But where's $here2?"
43     unless -e ($here2 = source_path('testlib2'));
44 } elsif(   -e ($here1 = File::Spec->catdir($cwd, 't', 'testlib1'      ))) {
45   die "But where's $here2?"
46     unless -e ($here2 = File::Spec->catdir($cwd, 't', 'testlib2'));
47 } else {
48   die "Can't find the test corpora";
49 }
50 print "# OK, found the test corpora\n#  as $here1\n# and $here2\n";
51 ok 1;
52
53 print $x->_state_as_string;
54 #$x->verbose(12);
55
56 use Pod::Simple;
57 *pretty = \&Pod::Simple::BlackBox::pretty;
58
59 print "# OK, starting run...\n# [[\n";
60 my($name2where, $where2name) = $x->survey($here1, $here2);
61 print "# ]]\n#OK, run done.\n";
62
63 my $p = pretty( $where2name, $name2where )."\n";
64 $p =~ s/, +/,\n/g;
65 $p =~ s/^/#  /mg;
66 print $p;
67
68 my $ascii_order;
69 if(     -e ($ascii_order = source_path('ascii_order.pl'))) {
70   #
71 } elsif(-e ($ascii_order = File::Spec->catfile($cwd, 't', 'ascii_order.pl'))) {
72   #
73 } else {
74   die "Can't find ascii_order.pl";
75 }
76
77 require $ascii_order;
78
79 {
80 my $names = join "|", sort ascii_order values %$where2name;
81 skip $^O eq 'VMS' ? '-- case may or may not be preserved' : 0, 
82      $names, 
83      "Blorm|Suzzle|Zonk::Pronk|hinkhonk::Glunk|hinkhonk::Vliff|perlflif|perlthng|perlzuk|squaa|squaa::Glunk|squaa::Vliff|squaa::Wowo|zikzik";
84 }
85
86 {
87 my $names = join "|", sort ascii_order keys %$name2where;
88 skip $^O eq 'VMS' ? '-- case may or may not be preserved' : 0, 
89      $names, 
90      "Blorm|Suzzle|Zonk::Pronk|hinkhonk::Glunk|hinkhonk::Vliff|perlflif|perlthng|perlzuk|squaa|squaa::Glunk|squaa::Vliff|squaa::Wowo|zikzik";
91 }
92
93 ok( ($name2where->{'squaa'} || 'huh???'), '/squaa\.pm$/');
94
95 ok grep( m/squaa\.pm/, keys %$where2name ), 1;
96
97 ###### Now with recurse(0)
98
99 $x->recurse(0);
100
101 print "# OK, starting run without recurse...\n# [[\n";
102 ($name2where, $where2name) = $x->survey($here1, $here2);
103 print "# ]]\n#OK, run without recurse done.\n";
104
105 $p = pretty( $where2name, $name2where )."\n";
106 $p =~ s/, +/,\n/g;
107 $p =~ s/^/#  /mg;
108 print $p;
109
110 {
111 my $names = join "|", sort ascii_order values %$where2name;
112 skip $^O eq 'VMS' ? '-- case may or may not be preserved' : 0, 
113      $names, 
114      "Blorm|Suzzle|squaa|zikzik";
115 }
116
117 {
118 my $names = join "|", sort ascii_order keys %$name2where;
119 skip $^O eq 'VMS' ? '-- case may or may not be preserved' : 0, 
120      $names, 
121      "Blorm|Suzzle|squaa|zikzik";
122 }
123
124 ok( ($name2where->{'squaa'} || 'huh???'), '/squaa\.pm$/');
125
126 ok grep( m/squaa\.pm/, keys %$where2name ), 1;
127
128 ok 1;
129
130 __END__
131