summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorCraig A. Berry <craigberry@mac.com>2013-01-04 17:41:17 -0600
committerCraig A. Berry <craigberry@mac.com>2013-01-06 16:30:03 -0600
commit30c56e34c6955d703838cc0ce41e8e17723f11ea (patch)
tree1d81c53ad24c9c0b5d16ea02e80535d96be85f13 /ext
parent83799784cb180c4b27a23e2ba1a77e8ec80ec76a (diff)
downloadperl-30c56e34c6955d703838cc0ce41e8e17723f11ea.tar.gz
Pod::Html test portability redux.
The flurry of activity to get these tests passing in the lead-up to 5.16.0 swept several issues under the rug. In particular, some of the tests had failures on VMS that became invisible once we started skipping them wherever dots are not allowed in directory names (which is true by default on VMS now, but is likely to change very shortly). The facts behind my changes, in no particular order: File::Spec->rootdir() returns, on VMS, a a special string that will not be found in any actual pathname, so taking the length of it and stripping that much off the front of an actual pathname produces garbage. File::Spec->rootdir(), on VMS, returns a string that contains a volume specification, so simply prepending a volume to it produces garbage. To portably produce a complete path, use catpath(). Windows appears not to care which direction the slashes are leaning, and VMS can handle pure-Unix paths as long as they aren't pasted onto components of native paths, so it's reasonbly safe to obtain directory components with splitdir, and join them together with forward slashes. The tests pass a value to --podpath that is not absolute, but nor is it relative in the usual sense. It's apparently intended to be relative to the filesystem root, which is an inherently non-portable concept as neither Windows nor VMS has such a thing. The best that can be done (without a complete rethink of the tests and perhaps the module) is to make it relative to the top-level directory on the current volume. This gets all tests passing on Windows, VMS, and OS X.
Diffstat (limited to 'ext')
-rw-r--r--ext/Pod-Html/t/crossref.t10
-rw-r--r--ext/Pod-Html/t/crossref2.t2
-rw-r--r--ext/Pod-Html/t/crossref3.t2
-rw-r--r--ext/Pod-Html/t/htmldir1.t12
-rw-r--r--ext/Pod-Html/t/htmldir3.t9
-rw-r--r--ext/Pod-Html/t/pod2html-lib.pl6
6 files changed, 23 insertions, 18 deletions
diff --git a/ext/Pod-Html/t/crossref.t b/ext/Pod-Html/t/crossref.t
index ec178e0024..e3f9480da8 100644
--- a/ext/Pod-Html/t/crossref.t
+++ b/ext/Pod-Html/t/crossref.t
@@ -10,7 +10,6 @@ END {
use strict;
use Cwd;
-use File::Spec;
use File::Spec::Functions;
use Test::More tests => 1;
@@ -19,11 +18,14 @@ SKIP: {
skip "$output", 1 if $output;
my ($v, $d) = splitpath(cwd(), 1);
- my $relcwd = substr($d, length(File::Spec->rootdir()));
+ my @dirs = splitdir($d);
+ shift @dirs if $dirs[0] eq '';
+ my $relcwd = join '/', @dirs;
convert_n_test("crossref", "cross references",
- "--podpath=". catdir($relcwd, 't') . ":" . catdir($relcwd, 'testdir/test.lib'),
- "--podroot=$v". File::Spec->rootdir,
+ "--podpath=". File::Spec::Unix->catdir($relcwd, 't') . ":"
+ . File::Spec::Unix->catdir($relcwd, 'testdir/test.lib'),
+ "--podroot=". catpath($v, '/', ''),
"--quiet",
);
}
diff --git a/ext/Pod-Html/t/crossref2.t b/ext/Pod-Html/t/crossref2.t
index ce8fd6f804..4d8b03f6ca 100644
--- a/ext/Pod-Html/t/crossref2.t
+++ b/ext/Pod-Html/t/crossref2.t
@@ -10,8 +10,6 @@ END {
use strict;
use Cwd;
-use File::Spec;
-use File::Spec::Functions;
use Test::More tests => 1;
SKIP: {
diff --git a/ext/Pod-Html/t/crossref3.t b/ext/Pod-Html/t/crossref3.t
index 309d5ed888..c6c7b0ef3f 100644
--- a/ext/Pod-Html/t/crossref3.t
+++ b/ext/Pod-Html/t/crossref3.t
@@ -10,8 +10,6 @@ END {
use strict;
use Cwd;
-use File::Spec;
-use File::Spec::Functions;
use Test::More tests => 1;
SKIP: {
diff --git a/ext/Pod-Html/t/htmldir1.t b/ext/Pod-Html/t/htmldir1.t
index 881e3d6dce..8dd285473f 100644
--- a/ext/Pod-Html/t/htmldir1.t
+++ b/ext/Pod-Html/t/htmldir1.t
@@ -10,7 +10,6 @@ END {
use strict;
use Cwd;
-use File::Spec;
use File::Spec::Functions;
use Test::More tests => 2;
@@ -22,14 +21,17 @@ SKIP: {
skip "$output", 2 if $output;
my ($v, $d) = splitpath(cwd(), 1);
- my $relcwd = substr($d, length(File::Spec->rootdir()));
+ my @dirs = splitdir($d);
+ shift @dirs if $dirs[0] eq '';
+ my $relcwd = join '/', @dirs;
my $data_pos = tell DATA; # to read <DATA> twice
convert_n_test("htmldir1", "test --htmldir and --htmlroot 1a",
- "--podpath=". catdir($relcwd, 't') . ":" . catfile($relcwd, 'testdir/test.lib'),
- "--podroot=$v". File::Spec->rootdir,
+ "--podpath=". File::Spec::Unix->catdir($relcwd, 't') . ":"
+ . File::Spec::Unix->catdir($relcwd, 'testdir/test.lib'),
+ "--podroot=". catpath($v, '/', ''),
"--htmldir=t",
"--quiet",
);
@@ -38,7 +40,7 @@ SKIP: {
convert_n_test("htmldir1", "test --htmldir and --htmlroot 1b",
"--podpath=$relcwd",
- "--podroot=$v". File::Spec->rootdir,
+ "--podroot=". catpath($v, '/', ''),
"--htmldir=". catdir($relcwd, 't'),
"--htmlroot=/",
"--quiet",
diff --git a/ext/Pod-Html/t/htmldir3.t b/ext/Pod-Html/t/htmldir3.t
index 555dc74862..184b5c60be 100644
--- a/ext/Pod-Html/t/htmldir3.t
+++ b/ext/Pod-Html/t/htmldir3.t
@@ -10,7 +10,6 @@ END {
use strict;
use Cwd;
-use File::Spec;
use File::Spec::Functions;
use Test::More tests => 2;
@@ -20,13 +19,15 @@ SKIP: {
my $cwd = cwd();
my ($v, $d) = splitpath($cwd, 1);
- my $relcwd = substr($d, length(File::Spec->rootdir()));
+ my @dirs = splitdir($d);
+ shift @dirs if $dirs[0] eq '';
+ my $relcwd = join '/', @dirs;
my $data_pos = tell DATA; # to read <DATA> twice
convert_n_test("htmldir3", "test --htmldir and --htmlroot 3a",
"--podpath=$relcwd",
- "--podroot=$v". File::Spec->rootdir,
+ "--podroot=". catpath($v, '/', ''),
"--htmldir=". catdir($cwd, 't', ''), # test removal trailing slash,
"--quiet",
);
@@ -35,7 +36,7 @@ SKIP: {
convert_n_test("htmldir3", "test --htmldir and --htmlroot 3b",
"--podpath=". catdir($relcwd, 't'),
- "--podroot=$v". File::Spec->rootdir,
+ "--podroot=". catpath($v, '/', ''),
"--htmldir=t",
"--outfile=t/htmldir3.html",
"--quiet",
diff --git a/ext/Pod-Html/t/pod2html-lib.pl b/ext/Pod-Html/t/pod2html-lib.pl
index c60cab6439..42cf1c97c4 100644
--- a/ext/Pod-Html/t/pod2html-lib.pl
+++ b/ext/Pod-Html/t/pod2html-lib.pl
@@ -23,6 +23,7 @@ sub make_test_dir {
}
sub rem_test_dir {
+ return unless -d 'testdir/test.lib';
remove_tree('testdir/test.lib')
or warn "Error removing temporary directory 'testdir/test.lib'";
}
@@ -32,7 +33,9 @@ sub convert_n_test {
my $cwd = Pod::Html::_unixify( Cwd::cwd() );
my ($vol, $dir) = splitpath($cwd, 1);
- my $relcwd = substr($dir, length(File::Spec->rootdir()));
+ my @dirs = splitdir($dir);
+ shift @dirs if $dirs[0] eq '';
+ my $relcwd = join '/', @dirs;
my $new_dir = catdir $dir, "t";
my $infile = catpath $vol, $new_dir, "$podfile.pod";
@@ -48,6 +51,7 @@ sub convert_n_test {
@p2h_args,
);
+ $cwd =~ s|\/$||;
my ($expect, $result);
{