Mark all .t and .pm files as non executable
[p5sagit/p5-mst-13.2.git] / lib / Pod / t / pod2html-lib.pl
index c3d96ae..db33f7d 100644 (file)
@@ -7,7 +7,7 @@ sub convert_n_test {
     my($podfile, $testname) = @_;
 
     my $cwd = Cwd::cwd();
-    my $base_dir = catdir $cwd, "..", "lib", "Pod";
+    my $base_dir = catdir $cwd, updir(), "lib", "Pod";
     my $new_dir  = catdir $base_dir, "t";
     my $infile   = catfile $new_dir, "$podfile.pod";
     my $outfile  = catfile $new_dir, "$podfile.html";
@@ -21,21 +21,42 @@ sub convert_n_test {
     );
 
 
-    local $/;
-    # expected
-    my $expect = <DATA>;
-    $expect =~ s/\[PERLADMIN\]/$Config::Config{perladmin}/;
-    if (ord("A") == 193) { # EBCDIC.
-       $expect =~ s/item_mat%3c%21%3e/item_mat%4c%5a%6e/;
+    my ($expect, $result);
+    {
+       local $/;
+       # expected
+       $expect = <DATA>;
+       $expect =~ s/\[PERLADMIN\]/$Config::Config{perladmin}/;
+       if (ord("A") == 193) { # EBCDIC.
+           $expect =~ s/item_mat_3c_21_3e/item_mat_4c_5a_6e/;
+       }
+
+       # result
+       open my $in, $outfile or die "cannot open $outfile: $!";
+       $result = <$in>;
+       close $in;
     }
 
-    # result
-    open my $in, $outfile or die "cannot open $outfile: $!";
-    my $result = <$in>;
-    close $in;
-
-    is($expect, $result, $testname);
-
+    ok($expect eq $result, $testname) or do {
+       my $diff = '/bin/diff';
+       -x $diff or $diff = '/usr/bin/diff';
+       if (-x $diff) {
+           my $expectfile = "pod2html-lib.tmp";
+           open my $tmpfile, ">", $expectfile or die $!;
+           print $tmpfile $expect;
+           close $tmpfile;
+           my $diffopt = $^O eq 'linux' ? 'u' : 'c';
+           open my $diff, "diff -$diffopt $expectfile $outfile |" or die $!;
+           print "# $_" while <$diff>;
+           close $diff;
+           unlink $expectfile;
+       }
+    };
+
+    # pod2html creates these
+    1 while unlink $outfile;
+    1 while unlink "pod2htmd.tmp";
+    1 while unlink "pod2htmi.tmp";
 }
 
 1;