This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to Getopt::Long 2.33
[perl5.git] / lib / Pod / t / pod2html-lib.pl
CommitLineData
78343be7
SB
1require Cwd;
2require Pod::Html;
3require Config;
4use File::Spec::Functions;
5
6sub 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
24 local $/;
25 # expected
26 my $expect = <DATA>;
27 $expect =~ s/\[PERLADMIN\]/$Config::Config{perladmin}/;
53f109d6
JH
28 if (ord("A") == 193) { # EBCDIC.
29 $expect =~ s/item_mat%3c%21%3e/item_mat%4c%5a%6e/;
30 }
78343be7
SB
31
32 # result
33 open my $in, $outfile or die "cannot open $outfile: $!";
34 my $result = <$in>;
35 close $in;
29d6d7d5 36 1 while unlink $outfile;
78343be7
SB
37
38 is($expect, $result, $testname);
29d6d7d5
SB
39 # pod2html creates these
40 1 while unlink "pod2htmd.x~~";
41 1 while unlink "pod2htmi.x~~";
78343be7
SB
42}
43
441;