Commit | Line | Data |
78343be7 |
1 | require Cwd; |
2 | require Pod::Html; |
3 | require Config; |
4 | use File::Spec::Functions; |
5 | |
6 | sub convert_n_test { |
7 | my($podfile, $testname) = @_; |
8 | |
9 | my $cwd = Cwd::cwd(); |
e69a2255 |
10 | my $base_dir = catdir $cwd, updir(), "lib", "Pod"; |
d8022526 |
11 | my $new_dir = catdir $base_dir, "t"; |
12 | my $infile = catfile $new_dir, "$podfile.pod"; |
13 | my $outfile = catfile $new_dir, "$podfile.html"; |
78343be7 |
14 | |
15 | Pod::Html::pod2html( |
d8022526 |
16 | "--podpath=t", |
17 | "--podroot=$base_dir", |
78343be7 |
18 | "--htmlroot=/", |
19 | "--infile=$infile", |
20 | "--outfile=$outfile" |
21 | ); |
22 | |
23 | |
66f3f260 |
24 | my ($expect, $result); |
25 | { |
26 | local $/; |
27 | # expected |
28 | $expect = <DATA>; |
29 | $expect =~ s/\[PERLADMIN\]/$Config::Config{perladmin}/; |
30 | if (ord("A") == 193) { # EBCDIC. |
31 | $expect =~ s/item_mat%3c%21%3e/item_mat%4c%5a%6e/; |
32 | } |
33 | |
34 | # result |
35 | open my $in, $outfile or die "cannot open $outfile: $!"; |
36 | $result = <$in>; |
37 | close $in; |
53f109d6 |
38 | } |
78343be7 |
39 | |
66f3f260 |
40 | ok($expect eq $result, $testname) or do { |
41 | my $diff = '/bin/diff'; |
42 | -x $diff or $diff = '/usr/bin/diff'; |
43 | if (-x $diff) { |
44 | my $expectfile = "pod2html-lib.tmp"; |
45 | open my $tmpfile, ">", $expectfile or die $!; |
46 | print $tmpfile $expect; |
47 | close $tmpfile; |
48 | my $diffopt = $^O eq 'linux' ? 'u' : 'c'; |
49 | open my $diff, "diff -$diffopt $expectfile $outfile |" or die $!; |
50 | print "# $_" while <$diff>; |
51 | close $diff; |
52 | unlink $expectfile; |
53 | } |
54 | }; |
78343be7 |
55 | |
29d6d7d5 |
56 | # pod2html creates these |
66f3f260 |
57 | 1 while unlink $outfile; |
383e43c7 |
58 | my $cache_ext = $^O eq 'VMS' ? ".tmp" : ".x~~"; |
59 | 1 while unlink "pod2htmd$cache_ext"; |
60 | 1 while unlink "pod2htmi$cache_ext"; |
78343be7 |
61 | } |
62 | |
63 | 1; |