Commit | Line | Data |
---|---|---|
78343be7 SB |
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 SB |
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 SB |
14 | |
15 | Pod::Html::pod2html( | |
d8022526 SB |
16 | "--podpath=t", |
17 | "--podroot=$base_dir", | |
78343be7 SB |
18 | "--htmlroot=/", |
19 | "--infile=$infile", | |
20 | "--outfile=$outfile" | |
21 | ); | |
22 | ||
23 | ||
66f3f260 RGS |
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. | |
cf0d1c66 | 31 | $expect =~ s/item_mat_3c_21_3e/item_mat_4c_5a_6e/; |
66f3f260 RGS |
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 RGS |
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; |
33869856 MS |
58 | 1 while unlink "pod2htmd.tmp"; |
59 | 1 while unlink "pod2htmi.tmp"; | |
78343be7 SB |
60 | } |
61 | ||
62 | 1; |