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