Skip to content

Commit

Permalink
ext/Pod-Html/t/*.t: Have each file run in tempdir
Browse files Browse the repository at this point in the history
Until now, the tests for this library ran inside the ext/Pod-Html
directory in the core distribution.  Since the tests necessarily create
files while the harness runs, there was a possibility for race
conditions, which meant that we had to have a workaround in t/harness to
have the tests in this directory not run in parallel.

This commit restructures the testing process so that each test program
gets its own tempdir in which to create files and directories.

The test architecture is now found in t/lib/Testing.pm.
This module will export two functions on demand that are used in the
individual test files.  They guarantee that all files created when
running a test program will be created in a temporary directory rather
than underneath the core distribution.

t/pod2html-lib.pl is now superseded by t/lib/Testing.pm and can be
removed.  The workaround has been removed from t/harness.

Change directory name from testdir/ to corpus/.  So as to more precisely
describe what the directory's purpose is.

Keep porting tests happy. Update MANIFEST and known_pod_issues database.

This should help in the resolution of
#12271.
  • Loading branch information
jkeenan committed May 10, 2021
1 parent 1e43c13 commit f6e15d1
Show file tree
Hide file tree
Showing 23 changed files with 1,148 additions and 405 deletions.
6 changes: 3 additions & 3 deletions MANIFEST
Expand Up @@ -4317,6 +4317,8 @@ ext/Pod-Functions/Functions_pm.PL Writes Functions.pm
ext/Pod-Functions/Makefile.PL Makefile writer
ext/Pod-Functions/t/Functions.t See if Pod::Functions works
ext/Pod-Html/bin/pod2html Translator to turn pod into HTML
ext/Pod-Html/corpus/perlpodspec-copy.pod
ext/Pod-Html/corpus/perlvar-copy.pod
ext/Pod-Html/lib/Pod/Html.pm Convert POD data to HTML
ext/Pod-Html/t/anchorify.t
ext/Pod-Html/t/cache.pod
Expand Down Expand Up @@ -4346,13 +4348,11 @@ ext/Pod-Html/t/htmllink.pod pod2html link test input data
ext/Pod-Html/t/htmllink.t pod2html link test
ext/Pod-Html/t/htmlview.pod pod2html render test input data
ext/Pod-Html/t/htmlview.t pod2html render test
ext/Pod-Html/t/pod2html-lib.pl pod2html testing library
ext/Pod-Html/t/lib/Testing.pm Testing functions for Pod-Html
ext/Pod-Html/t/poderr.pod
ext/Pod-Html/t/poderr.t
ext/Pod-Html/t/podnoerr.pod
ext/Pod-Html/t/podnoerr.t
ext/Pod-Html/testdir/perlpodspec-copy.pod
ext/Pod-Html/testdir/perlvar-copy.pod
ext/POSIX/hints/bsdos.pl Hint for POSIX for named architecture
ext/POSIX/hints/dynixptx.pl Hint for POSIX for named architecture
ext/POSIX/hints/freebsd.pl Hint for POSIX for named architecture
Expand Down
File renamed without changes.
File renamed without changes.
29 changes: 19 additions & 10 deletions ext/Pod-Html/t/cache.t
@@ -1,23 +1,31 @@
#!/usr/bin/perl -w # -*- perl -*-
# -*- perl -*-

BEGIN {
die "Run me from outside the t/ directory, please" unless -d 't';
use File::Spec::Functions ':ALL';
@INC = map { rel2abs($_) }
(qw| ./lib ./t/lib ../../lib |);
}

# test the directory cache
# XXX test --flush and %Pages being loaded/used for cross references

use strict;
use Cwd;
use Pod::Html;
use Data::Dumper;
use warnings;
use Test::More tests => 10;
use Testing qw( setup_testing_dir xconvert );
use Cwd;

my $debug = 0;
my $startdir = cwd();
END { chdir($startdir) or die("Cannot change back to $startdir: $!"); }
my $args;

my $tdir = setup_testing_dir( {
debug => $debug,
} );

my $cwd = Pod::Html::_unixify(Cwd::cwd());
my $infile = "t/cache.pod";
my $infile = catfile('t', 'cache.pod');
my $outfile = "cacheout.html";
my $cachefile = "pod2htmd.tmp";
my $tcachefile = "t/pod2htmd.tmp";
my $tcachefile = catfile('t', 'pod2htmd.tmp');

unlink $cachefile, $tcachefile;
is(-f $cachefile, undef, "No cache file to start");
Expand Down Expand Up @@ -70,3 +78,4 @@ close $cache;
1 while unlink $tcachefile;
is(-f $cachefile, undef, "No cache file to end");
is(-f $tcachefile, undef, "No cache file to end");

57 changes: 34 additions & 23 deletions ext/Pod-Html/t/crossref.t
@@ -1,33 +1,44 @@
#!/usr/bin/perl -w # -*- perl -*-
# -*- perl -*-

BEGIN {
require "./t/pod2html-lib.pl";
}

END {
rem_test_dir();
use File::Spec::Functions ':ALL';
@INC = map { rel2abs($_) }
(qw| ./lib ./t/lib ../../lib |);
}

use strict;
use Cwd;
use File::Spec::Functions;
use warnings;
use Test::More tests => 1;
use Testing qw( setup_testing_dir xconvert );
use Cwd;

SKIP: {
my $output = make_test_dir();
skip "$output", 1 if $output;
my $debug = 0;
my $startdir = cwd();
END { chdir($startdir) or die("Cannot change back to $startdir: $!"); }
my ($expect_raw, $args);
{ local $/; $expect_raw = <DATA>; }

my $tdir = setup_testing_dir( {
debug => $debug,
} );

my ($v, $d) = splitpath(cwd(), 1);
my @dirs = splitdir($d);
shift @dirs if $dirs[0] eq '';
my $relcwd = join '/', @dirs;

my ($v, $d) = splitpath(cwd(), 1);
my @dirs = splitdir($d);
shift @dirs if $dirs[0] eq '';
my $relcwd = join '/', @dirs;

convert_n_test("crossref", "cross references", {
podpath => File::Spec::Unix->catdir($relcwd, 't') . ":" . File::Spec::Unix->catdir($relcwd, 'testdir/test.lib'),
$args = {
podstub => "crossref",
description => "cross references",
expect => $expect_raw,
p2h => {
podpath => File::Spec::Unix->catdir($relcwd, 't') . ":" . File::Spec::Unix->catdir($relcwd, 'corpus/test.lib'),
podroot => catpath($v, '/', ''),
quiet => 1,
} );
}
},
debug => $debug,
};
xconvert($args);

__DATA__
<?xml version="1.0" ?>
Expand Down Expand Up @@ -67,15 +78,15 @@ __DATA__
<p><a href="#non-existent-section">&quot;non existent section&quot;</a></p>
<p><a href="/[RELCURRENTWORKINGDIRECTORY]/testdir/test.lib/var-copy.html">var-copy</a></p>
<p><a href="/[RELCURRENTWORKINGDIRECTORY]/corpus/test.lib/var-copy.html">var-copy</a></p>
<p><a href="/[RELCURRENTWORKINGDIRECTORY]/testdir/test.lib/var-copy.html#pod">&quot;$&quot;&quot; in var-copy</a></p>
<p><a href="/[RELCURRENTWORKINGDIRECTORY]/corpus/test.lib/var-copy.html#pod">&quot;$&quot;&quot; in var-copy</a></p>
<p><code>var-copy</code></p>
<p><code>var-copy/$&quot;</code></p>
<p><a href="/[RELCURRENTWORKINGDIRECTORY]/testdir/test.lib/podspec-copy.html#First">&quot;First:&quot; in podspec-copy</a></p>
<p><a href="/[RELCURRENTWORKINGDIRECTORY]/corpus/test.lib/podspec-copy.html#First">&quot;First:&quot; in podspec-copy</a></p>
<p><code>podspec-copy/First:</code></p>
Expand Down
60 changes: 35 additions & 25 deletions ext/Pod-Html/t/crossref2.t
@@ -1,32 +1,42 @@
#!/usr/bin/perl -w # -*- perl -*-
# -*- perl -*-

BEGIN {
require "./t/pod2html-lib.pl";
}

END {
rem_test_dir();
use File::Spec::Functions ':ALL';
@INC = map { rel2abs($_) }
(qw| ./lib ./t/lib ../../lib |);
}

use strict;
use Cwd;
use warnings;
use Test::More tests => 1;
use Testing qw( setup_testing_dir xconvert );
use Cwd;

SKIP: {
my $output = make_test_dir();
skip "$output", 1 if $output;

my $cwd = Pod::Html::_unixify(cwd());

convert_n_test("crossref", "cross references",
{
podpath => 't:testdir/test.lib',
podroot => $cwd,
htmldir => $cwd,
quiet => 1,
}
);
}
my $debug = 0;
my $startdir = cwd();
END { chdir($startdir) or die("Cannot change back to $startdir: $!"); }
my ($expect_raw, $args);
{ local $/; $expect_raw = <DATA>; }

my $tdir = setup_testing_dir( {
debug => $debug,
} );

my $cwd = Pod::Html::_unixify(cwd());

$args = {
podstub => "crossref",
description => "cross references",
expect => $expect_raw,
p2h => {
podpath => 't:corpus/test.lib',
podroot => $cwd,
htmldir => $cwd,
quiet => 1,
},
debug => $debug,
};
xconvert($args);

__DATA__
<?xml version="1.0" ?>
Expand Down Expand Up @@ -66,15 +76,15 @@ __DATA__
<p><a href="#non-existent-section">&quot;non existent section&quot;</a></p>
<p><a href="../testdir/test.lib/var-copy.html">var-copy</a></p>
<p><a href="../corpus/test.lib/var-copy.html">var-copy</a></p>
<p><a href="../testdir/test.lib/var-copy.html#pod">&quot;$&quot;&quot; in var-copy</a></p>
<p><a href="../corpus/test.lib/var-copy.html#pod">&quot;$&quot;&quot; in var-copy</a></p>
<p><code>var-copy</code></p>
<p><code>var-copy/$&quot;</code></p>
<p><a href="../testdir/test.lib/podspec-copy.html#First">&quot;First:&quot; in podspec-copy</a></p>
<p><a href="../corpus/test.lib/podspec-copy.html#First">&quot;First:&quot; in podspec-copy</a></p>
<p><code>podspec-copy/First:</code></p>
Expand Down
58 changes: 35 additions & 23 deletions ext/Pod-Html/t/crossref3.t
@@ -1,30 +1,42 @@
#!/usr/bin/perl -w # -*- perl -*-
# -*- perl -*-

BEGIN {
require "./t/pod2html-lib.pl";
}

END {
rem_test_dir();
use File::Spec::Functions ':ALL';
@INC = map { rel2abs($_) }
(qw| ./lib ./t/lib ../../lib |);
}

use strict;
use Cwd;
use warnings;
use Test::More tests => 1;
use Testing qw( setup_testing_dir xconvert );
use Cwd;

SKIP: {
my $output = make_test_dir();
skip "$output", 1 if $output;

my $cwd = cwd();

convert_n_test("crossref", "cross references", {
podpath => 't:testdir/test.lib',
podroot => $cwd,
htmlroot => $cwd,
quiet => 1,
} );
}
my $debug = 0;
my $startdir = cwd();
END { chdir($startdir) or die("Cannot change back to $startdir: $!"); }
my ($expect_raw, $args);
{ local $/; $expect_raw = <DATA>; }

my $tdir = setup_testing_dir( {
debug => $debug,
} );

my $cwd = cwd();

$args = {
podstub => "crossref",
description => "cross references",
expect => $expect_raw,
p2h => {
podpath => 't:corpus/test.lib',
podroot => $cwd,
htmlroot => $cwd,
quiet => 1,
},
debug => $debug,
};
xconvert($args);

__DATA__
<?xml version="1.0" ?>
Expand Down Expand Up @@ -64,15 +76,15 @@ __DATA__
<p><a href="#non-existent-section">&quot;non existent section&quot;</a></p>
<p><a href="[ABSCURRENTWORKINGDIRECTORY]/testdir/test.lib/var-copy.html">var-copy</a></p>
<p><a href="[ABSCURRENTWORKINGDIRECTORY]/corpus/test.lib/var-copy.html">var-copy</a></p>
<p><a href="[ABSCURRENTWORKINGDIRECTORY]/testdir/test.lib/var-copy.html#pod">&quot;$&quot;&quot; in var-copy</a></p>
<p><a href="[ABSCURRENTWORKINGDIRECTORY]/corpus/test.lib/var-copy.html#pod">&quot;$&quot;&quot; in var-copy</a></p>
<p><code>var-copy</code></p>
<p><code>var-copy/$&quot;</code></p>
<p><a href="[ABSCURRENTWORKINGDIRECTORY]/testdir/test.lib/podspec-copy.html#First">&quot;First:&quot; in podspec-copy</a></p>
<p><a href="[ABSCURRENTWORKINGDIRECTORY]/corpus/test.lib/podspec-copy.html#First">&quot;First:&quot; in podspec-copy</a></p>
<p><code>podspec-copy/First:</code></p>
Expand Down
50 changes: 35 additions & 15 deletions ext/Pod-Html/t/feature.t
@@ -1,28 +1,48 @@
#!/usr/bin/perl -w # -*- perl -*-
# -*- perl -*-

BEGIN {
require "./t/pod2html-lib.pl";
use File::Spec::Functions ':ALL';
@INC = map { rel2abs($_) }
(qw| ./lib ./t/lib ../../lib |);
}

use strict;
use Cwd;
use File::Spec::Functions;
use warnings;
use Test::More tests => 1;
use Testing qw( setup_testing_dir xconvert );
use Cwd;

my $cwd = cwd();
my $debug = 0;
my $startdir = cwd();
END { chdir($startdir) or die("Cannot change back to $startdir: $!"); }
my ($expect_raw, $args);
{ local $/; $expect_raw = <DATA>; }

convert_n_test("feature", "misc pod-html features", {
backlink => 1,
css => 'style.css',
header => 1, # no styling b/c of --ccs
htmldir => catdir($cwd, 't'),
noindex => 1,
podpath => 't',
podroot => $cwd,
title => 'a title',
quiet => 1,
my $tdir = setup_testing_dir( {
debug => $debug,
} );

my $cwd = cwd();

$args = {
podstub => "feature",
description => "misc pod-html features",
expect => $expect_raw,
p2h => {
backlink => 1,
css => 'style.css',
header => 1, # no styling b/c of --ccs
htmldir => catdir($cwd, 't'),
noindex => 1,
podpath => 't',
podroot => $cwd,
title => 'a title',
quiet => 1,
},
debug => $debug,
};
xconvert($args);

__DATA__
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Expand Down

0 comments on commit f6e15d1

Please sign in to comment.