4 use File::Spec::Functions ':ALL';
5 use File::Path 'remove_tree';
8 # make_test_dir and rem_test_dir dynamically create and remove testdir/test.lib.
9 # it is created dynamically to pass t/filenames.t, which does not allow '.'s in
10 # filenames as '.' is the directory separator on VMS. All tests that require
11 # testdir/test.lib to be present are skipped if test.lib cannot be created.
13 if (-d 'testdir/test.lib') {
14 warn "Directory 'test.lib' exists (it shouldn't yet) - removing it";
17 mkdir('testdir/test.lib') or return "Could not make test.lib directory: $!\n";
18 copy('testdir/perlpodspec-copy.pod', 'testdir/test.lib/podspec-copy.pod')
19 or return "Could not copy perlpodspec-copy: $!";
20 copy('testdir/perlvar-copy.pod', 'testdir/test.lib/var-copy.pod')
21 or return "Could not copy perlvar-copy: $!";
26 remove_tree('testdir/test.lib')
27 or warn "Error removing temporary directory 'testdir/test.lib'";
31 my($podfile, $testname, @p2h_args) = @_;
34 my ($vol, $dir) = splitpath($cwd, 1);
35 my $relcwd = substr($dir, length(File::Spec->rootdir()));
37 my $new_dir = catdir $cwd, "t";
38 my $infile = catfile $new_dir, "$podfile.pod";
39 my $outfile = catfile $new_dir, "$podfile.html";
41 # To add/modify args to p2h, use @p2h_args
52 my ($expect, $result);
57 $expect =~ s/\[PERLADMIN\]/$Config::Config{perladmin}/;
58 $expect =~ s/\[RELCURRENTWORKINGDIRECTORY\]/$relcwd/g;
59 if (ord("A") == 193) { # EBCDIC.
60 $expect =~ s/item_mat_3c_21_3e/item_mat_4c_5a_6e/;
64 open my $in, $outfile or die "cannot open $outfile: $!";
69 ok($expect eq $result, $testname) or do {
70 my $diff = '/bin/diff';
71 -x $diff or $diff = '/usr/bin/diff';
73 my $expectfile = "pod2html-lib.tmp";
74 open my $tmpfile, ">", $expectfile or die $!;
75 print $tmpfile $expect;
77 my $diffopt = $^O eq 'linux' ? 'u' : 'c';
78 open my $diff, "diff -$diffopt $expectfile $outfile |" or die $!;
79 print "# $_" while <$diff>;
85 # pod2html creates these
86 1 while unlink $outfile;
87 1 while unlink "pod2htmd.tmp";