Bring Pod::Simple up to 3.09 as on CPAN.
[p5sagit/p5-mst-13.2.git] / cpan / Pod-Simple / t / htmlbat.t
CommitLineData
9b134129 1# Testing HTMLBatch
351625bd 2BEGIN {
3 if($ENV{PERL_CORE}) {
4 chdir 't';
5 @INC = '../lib';
6 }
7}
8
9# Time-stamp: "2004-05-24 02:07:47 ADT"
10use strict;
9d65762f 11my $DEBUG = 0;
351625bd 12
13#sub Pod::Simple::HTMLBatch::DEBUG () {5};
14
15use Test;
9d65762f 16BEGIN { plan tests => 9 }
351625bd 17
18require Pod::Simple::HTMLBatch;;
19
20use File::Spec;
21use Cwd;
22my $cwd = cwd();
9d65762f 23print "# CWD: $cwd\n" if $DEBUG;
351625bd 24
25my $t_dir;
26my $corpus_dir;
27
28foreach my $t_maybe (
29 File::Spec->catdir( File::Spec->updir(), 'lib','Pod','Simple','t'),
30 File::Spec->catdir( $cwd ),
31 File::Spec->catdir( $cwd, 't' ),
32 'OHSNAP'
33) {
34 die "Can't find the test corpus" if $t_maybe eq 'OHSNAP';
35 next unless -e $t_maybe;
36
37 $t_dir = $t_maybe;
9b134129 38 $corpus_dir = File::Spec->catdir( $t_maybe, 'testlib1' );
351625bd 39 next unless -e $corpus_dir;
40 last;
41}
9d65762f 42print "# OK, found the test corpus as $corpus_dir\n" if $DEBUG;
351625bd 43ok 1;
44
45my $outdir;
46while(1) {
47 my $rand = sprintf "%05x", rand( 0x100000 );
48 $outdir = File::Spec->catdir( $t_dir, "delme-$rand-out" );
49 last unless -e $outdir;
50}
51
52END {
53 use File::Path;
54 rmtree $outdir, 0, 0;
55}
56
57ok 1;
9d65762f 58print "# Output dir: $outdir\n" if $DEBUG;
351625bd 59
60mkdir $outdir, 0777 or die "Can't mkdir $outdir: $!";
61
9d65762f 62print "# Converting $corpus_dir => $outdir\n" if $DEBUG;
351625bd 63my $conv = Pod::Simple::HTMLBatch->new;
64$conv->verbose(0);
65$conv->batch_convert( [$corpus_dir], $outdir );
66ok 1;
9d65762f 67print "# OK, back from converting.\n" if $DEBUG;
351625bd 68
69my @files;
70use File::Find;
71find( sub { push @files, $File::Find::name; return }, $outdir );
72
73{
74 my $long = ( grep m/zikzik\./i, @files )[0];
75 ok($long) or print "# How odd, no zikzik file in $outdir!?\n";
76 if($long) {
77 $long =~ s{zikzik\.html?$}{}s;
78 for(@files) { substr($_, 0, length($long)) = '' }
79 @files = grep length($_), @files;
80 }
81}
82
9d65762f 83if ($DEBUG) {
84 print "#Produced in $outdir ...\n";
85 foreach my $f (sort @files) {
86 print "# $f\n";
87 }
88 print "# (", scalar(@files), " items total)\n";
351625bd 89}
351625bd 90
91# Some minimal sanity checks:
92ok scalar(grep m/\.css/i, @files) > 5;
93ok scalar(grep m/\.html?/i, @files) > 5;
94ok scalar grep m{squaa\W+Glunk.html?}i, @files;
95
9d65762f 96if (my @long = grep { /^[^.]{9,}/ } map { s{^[^/]/}{} } @files) {
97 ok 0;
98 print "# File names too long:\n",
99 map { "# $_\n" } @long;
100} else {
101 ok 1;
102}
103
104
105
351625bd 106# use Pod::Simple;
107# *pretty = \&Pod::Simple::BlackBox::pretty;
108
9d65762f 109print "# Bye from ", __FILE__, "\n" if $DEBUG;
351625bd 110ok 1;