Commit | Line | Data |
9b134129 |
1 | # Testing HTMLBatch |
351625bd |
2 | BEGIN { |
3 | if($ENV{PERL_CORE}) { |
4 | chdir 't'; |
5 | @INC = '../lib'; |
6 | } |
7 | } |
8 | |
9 | # Time-stamp: "2004-05-24 02:07:47 ADT" |
10 | use strict; |
9d65762f |
11 | my $DEBUG = 0; |
351625bd |
12 | |
13 | #sub Pod::Simple::HTMLBatch::DEBUG () {5}; |
14 | |
15 | use Test; |
9d65762f |
16 | BEGIN { plan tests => 9 } |
351625bd |
17 | |
18 | require Pod::Simple::HTMLBatch;; |
19 | |
20 | use File::Spec; |
21 | use Cwd; |
22 | my $cwd = cwd(); |
9d65762f |
23 | print "# CWD: $cwd\n" if $DEBUG; |
351625bd |
24 | |
25 | my $t_dir; |
26 | my $corpus_dir; |
27 | |
28 | foreach 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 |
42 | print "# OK, found the test corpus as $corpus_dir\n" if $DEBUG; |
351625bd |
43 | ok 1; |
44 | |
45 | my $outdir; |
46 | while(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 | |
52 | END { |
53 | use File::Path; |
54 | rmtree $outdir, 0, 0; |
55 | } |
56 | |
57 | ok 1; |
9d65762f |
58 | print "# Output dir: $outdir\n" if $DEBUG; |
351625bd |
59 | |
60 | mkdir $outdir, 0777 or die "Can't mkdir $outdir: $!"; |
61 | |
9d65762f |
62 | print "# Converting $corpus_dir => $outdir\n" if $DEBUG; |
351625bd |
63 | my $conv = Pod::Simple::HTMLBatch->new; |
64 | $conv->verbose(0); |
65 | $conv->batch_convert( [$corpus_dir], $outdir ); |
66 | ok 1; |
9d65762f |
67 | print "# OK, back from converting.\n" if $DEBUG; |
351625bd |
68 | |
69 | my @files; |
70 | use File::Find; |
71 | find( 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 |
83 | if ($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: |
92 | ok scalar(grep m/\.css/i, @files) > 5; |
93 | ok scalar(grep m/\.html?/i, @files) > 5; |
94 | ok scalar grep m{squaa\W+Glunk.html?}i, @files; |
95 | |
9d65762f |
96 | if (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 |
109 | print "# Bye from ", __FILE__, "\n" if $DEBUG; |
351625bd |
110 | ok 1; |