1N/Arequire Cwd;
1N/Arequire Pod::Html;
1N/Arequire Config;
1N/Ause File::Spec::Functions;
1N/A
1N/Asub convert_n_test {
1N/A my($podfile, $testname) = @_;
1N/A
1N/A my $cwd = Cwd::cwd();
1N/A my $base_dir = catdir $cwd, updir(), "lib", "Pod";
1N/A my $new_dir = catdir $base_dir, "t";
1N/A my $infile = catfile $new_dir, "$podfile.pod";
1N/A my $outfile = catfile $new_dir, "$podfile.html";
1N/A
1N/A Pod::Html::pod2html(
1N/A "--podpath=t",
1N/A "--podroot=$base_dir",
1N/A "--htmlroot=/",
1N/A "--infile=$infile",
1N/A "--outfile=$outfile"
1N/A );
1N/A
1N/A
1N/A my ($expect, $result);
1N/A {
1N/A local $/;
1N/A # expected
1N/A $expect = <DATA>;
1N/A $expect =~ s/\[PERLADMIN\]/$Config::Config{perladmin}/;
1N/A if (ord("A") == 193) { # EBCDIC.
1N/A $expect =~ s/item_mat%3c%21%3e/item_mat%4c%5a%6e/;
1N/A }
1N/A
1N/A # result
1N/A open my $in, $outfile or die "cannot open $outfile: $!";
1N/A $result = <$in>;
1N/A close $in;
1N/A }
1N/A
1N/A ok($expect eq $result, $testname) or do {
1N/A my $diff = '/bin/diff';
1N/A -x $diff or $diff = '/usr/bin/diff';
1N/A if (-x $diff) {
1N/A my $expectfile = "pod2html-lib.tmp";
1N/A open my $tmpfile, ">", $expectfile or die $!;
1N/A print $tmpfile $expect;
1N/A close $tmpfile;
1N/A my $diffopt = $^O eq 'linux' ? 'u' : 'c';
1N/A open my $diff, "diff -$diffopt $expectfile $outfile |" or die $!;
1N/A print "# $_" while <$diff>;
1N/A close $diff;
1N/A unlink $expectfile;
1N/A }
1N/A };
1N/A
1N/A # pod2html creates these
1N/A 1 while unlink $outfile;
1N/A 1 while unlink "pod2htmd.tmp";
1N/A 1 while unlink "pod2htmi.tmp";
1N/A}
1N/A
1N/A1;