From 3582575f3637e9b0014442aab54dabed7c1fa2d7 Mon Sep 17 00:00:00 2001 From: Marc Green Date: Sat, 29 Oct 2011 00:39:52 -0400 Subject: [PATCH] Dynamically create and delete testdir/test.lib/ Due to the '.' in 'test.lib's name, t/filenames.t fails (because '.' is the path separator on VMS). To fix this, I create and delete the directory and its contents during each test that needs to access the directory. Said tests will be skipped if the directory cannot be created (e.g., on VMS). --- MANIFEST | 4 +- ext/Pod-Html/t/crossref.pod | 12 +++--- ext/Pod-Html/t/crossref.t | 37 +++++++++++------- ext/Pod-Html/t/htmldir1.pod | 2 +- ext/Pod-Html/t/htmldir1.t | 45 ++++++++++++++-------- ext/Pod-Html/t/htmldir3.pod | 2 +- ext/Pod-Html/t/htmldir3.t | 43 +++++++++++++-------- ext/Pod-Html/t/htmldir5.pod | 2 +- ext/Pod-Html/t/htmldir5.t | 31 ++++++++++----- ext/Pod-Html/t/pod2html-lib.pl | 24 ++++++++++++ .../{test.lib => testdir}/perlpodspec-copy.pod | 0 .../{test.lib => testdir}/perlvar-copy.pod | 0 t/porting/known_pod_issues.dat | 8 ++-- 13 files changed, 138 insertions(+), 72 deletions(-) rename ext/Pod-Html/{test.lib => testdir}/perlpodspec-copy.pod (100%) rename ext/Pod-Html/{test.lib => testdir}/perlvar-copy.pod (100%) diff --git a/MANIFEST b/MANIFEST index b69f6c0..e768396 100644 --- a/MANIFEST +++ b/MANIFEST @@ -3727,8 +3727,8 @@ ext/Pod-Html/bin/pod2html Translator to turn pod into HTML ext/Pod-Html/lib/Pod/Html.pm Convert POD data to HTML ext/Pod-Html/t/crossref.pod ext/Pod-Html/t/crossref.t -ext/Pod-Html/test.lib/perlpodspec-copy.pod -ext/Pod-Html/test.lib/perlvar-copy.pod +ext/Pod-Html/testdir/perlpodspec-copy.pod +ext/Pod-Html/testdir/perlvar-copy.pod ext/Pod-Html/t/feature2.pod ext/Pod-Html/t/feature2.t ext/Pod-Html/t/feature.pod diff --git a/ext/Pod-Html/t/crossref.pod b/ext/Pod-Html/t/crossref.pod index fe908d5..f6dddf1 100644 --- a/ext/Pod-Html/t/crossref.pod +++ b/ext/Pod-Html/t/crossref.pod @@ -12,17 +12,17 @@ L L -L +L -L +L -C +C -C +C -L +L -C +C L diff --git a/ext/Pod-Html/t/crossref.t b/ext/Pod-Html/t/crossref.t index 0a3ba63..ec178e0 100644 --- a/ext/Pod-Html/t/crossref.t +++ b/ext/Pod-Html/t/crossref.t @@ -4,20 +4,29 @@ BEGIN { require "t/pod2html-lib.pl"; } +END { + rem_test_dir(); +} + use strict; use Cwd; use File::Spec; use File::Spec::Functions; use Test::More tests => 1; -my ($v, $d) = splitpath(cwd(), 1); -my $relcwd = substr($d, length(File::Spec->rootdir())); - -convert_n_test("crossref", "cross references", - "--podpath=". catdir($relcwd, 't') . ":" . catdir($relcwd, 'test.lib'), - "--podroot=$v". File::Spec->rootdir, - "--quiet", -); +SKIP: { + my $output = make_test_dir(); + skip "$output", 1 if $output; + + my ($v, $d) = splitpath(cwd(), 1); + my $relcwd = substr($d, length(File::Spec->rootdir())); + + convert_n_test("crossref", "cross references", + "--podpath=". catdir($relcwd, 't') . ":" . catdir($relcwd, 'testdir/test.lib'), + "--podroot=$v". File::Spec->rootdir, + "--quiet", + ); +} __DATA__ @@ -57,17 +66,17 @@ __DATA__

"non existant section"

-

perlvar-copy

+

var-copy

-

"$"" in perlvar-copy

+

"$"" in var-copy

-

perlvar-copy

+

var-copy

-

perlvar-copy/$"

+

var-copy/$"

-

"First:" in perlpodspec-copy

+

"First:" in podspec-copy

-

perlpodspec-copy/First:

+

podspec-copy/First:

notperldoc

diff --git a/ext/Pod-Html/t/htmldir1.pod b/ext/Pod-Html/t/htmldir1.pod index 1c9e97b..e505caa 100644 --- a/ext/Pod-Html/t/htmldir1.pod +++ b/ext/Pod-Html/t/htmldir1.pod @@ -6,7 +6,7 @@ htmldir - Test --htmldir feature Normal text, a L to nowhere, -a link to L, +a link to L, L, diff --git a/ext/Pod-Html/t/htmldir1.t b/ext/Pod-Html/t/htmldir1.t index 3ce6c35..a0e747f 100644 --- a/ext/Pod-Html/t/htmldir1.t +++ b/ext/Pod-Html/t/htmldir1.t @@ -4,31 +4,44 @@ BEGIN { require "t/pod2html-lib.pl"; } +END { + rem_test_dir(); +} + use strict; use Cwd; use File::Spec; use File::Spec::Functions; use Test::More tests => 2; -my ($v, $d) = splitpath(cwd(), 1); -my $relcwd = substr($d, length(File::Spec->rootdir())); +# XXX Separate tests that rely on test.lib from the others so they are the only +# ones skipped (instead of all of them). This applies to htmldir{1,3,5}.t, and +# crossref.t (as of 10/29/11). +SKIP: { + my $output = make_test_dir(); + skip "$output", 2 if $output; + + my ($v, $d) = splitpath(cwd(), 1); + my $relcwd = substr($d, length(File::Spec->rootdir())); -my $data_pos = tell DATA; # to read twice + my $data_pos = tell DATA; # to read twice -convert_n_test("htmldir1", "test --htmldir and --htmlroot 1a", - "--podpath=". catdir($relcwd, 't') . ":" . catfile($relcwd, 'test.lib'), - "--podroot=$v". File::Spec->rootdir, - "--htmldir=t", -); -seek DATA, $data_pos, 0; # to read twice (expected output is the same) + convert_n_test("htmldir1", "test --htmldir and --htmlroot 1a", + "--podpath=". catdir($relcwd, 't') . ":" . catfile($relcwd, 'testdir/test.lib'), + "--podroot=$v". File::Spec->rootdir, + "--htmldir=t", + ); -convert_n_test("htmldir1", "test --htmldir and --htmlroot 1b", - "--podpath=$relcwd", - "--podroot=$v". File::Spec->rootdir, - "--htmldir=". catfile $relcwd, 't', - "--htmlroot=/", -); + seek DATA, $data_pos, 0; # to read twice (expected output is the same) + + convert_n_test("htmldir1", "test --htmldir and --htmlroot 1b", + "--podpath=$relcwd", + "--podroot=$v". File::Spec->rootdir, + "--htmldir=". catfile $relcwd, 't', + "--htmlroot=/", + ); +} __DATA__ @@ -57,7 +70,7 @@ __DATA__

Normal text, a link to nowhere,

-

a link to perlvar-copy,

+

a link to var-copy,

htmlescp,

diff --git a/ext/Pod-Html/t/htmldir3.pod b/ext/Pod-Html/t/htmldir3.pod index 1c9e97b..e505caa 100644 --- a/ext/Pod-Html/t/htmldir3.pod +++ b/ext/Pod-Html/t/htmldir3.pod @@ -6,7 +6,7 @@ htmldir - Test --htmldir feature Normal text, a L to nowhere, -a link to L, +a link to L, L, diff --git a/ext/Pod-Html/t/htmldir3.t b/ext/Pod-Html/t/htmldir3.t index c2f3af6..805c9d9 100644 --- a/ext/Pod-Html/t/htmldir3.t +++ b/ext/Pod-Html/t/htmldir3.t @@ -4,32 +4,41 @@ BEGIN { require "t/pod2html-lib.pl"; } +END { + rem_test_dir(); +} + use strict; use Cwd; use File::Spec; use File::Spec::Functions; use Test::More tests => 2; -my $cwd = cwd(); -my ($v, $d) = splitpath($cwd, 1); -my $relcwd = substr($d, length(File::Spec->rootdir())); +SKIP: { + my $output = make_test_dir(); + skip "$output", 2 if $output; -my $data_pos = tell DATA; # to read twice + my $cwd = cwd(); + my ($v, $d) = splitpath($cwd, 1); + my $relcwd = substr($d, length(File::Spec->rootdir())); -convert_n_test("htmldir3", "test --htmldir and --htmlroot 3a", - "--podpath=$relcwd", - "--podroot=$v". File::Spec->rootdir, - "--htmldir=". catdir($cwd, 't', ''), # test removal trailing slash, -); + my $data_pos = tell DATA; # to read twice -seek DATA, $data_pos, 0; # to read twice (expected output is the same) + convert_n_test("htmldir3", "test --htmldir and --htmlroot 3a", + "--podpath=$relcwd", + "--podroot=$v". File::Spec->rootdir, + "--htmldir=". catdir($cwd, 't', ''), # test removal trailing slash, + ); -convert_n_test("htmldir3", "test --htmldir and --htmlroot 3b", - "--podpath=". catdir($relcwd, 't'), - "--podroot=$v". File::Spec->rootdir, - "--htmldir=t", - "--outfile=t/htmldir3.html", -); + seek DATA, $data_pos, 0; # to read twice (expected output is the same) + + convert_n_test("htmldir3", "test --htmldir and --htmlroot 3b", + "--podpath=". catdir($relcwd, 't'), + "--podroot=$v". File::Spec->rootdir, + "--htmldir=t", + "--outfile=t/htmldir3.html", + ); +} __DATA__ @@ -58,7 +67,7 @@ __DATA__

Normal text, a link to nowhere,

-

a link to perlvar-copy,

+

a link to var-copy,

htmlescp,

diff --git a/ext/Pod-Html/t/htmldir5.pod b/ext/Pod-Html/t/htmldir5.pod index 1c9e97b..e505caa 100644 --- a/ext/Pod-Html/t/htmldir5.pod +++ b/ext/Pod-Html/t/htmldir5.pod @@ -6,7 +6,7 @@ htmldir - Test --htmldir feature Normal text, a L to nowhere, -a link to L, +a link to L, L, diff --git a/ext/Pod-Html/t/htmldir5.t b/ext/Pod-Html/t/htmldir5.t index fa6fada..15a3901 100644 --- a/ext/Pod-Html/t/htmldir5.t +++ b/ext/Pod-Html/t/htmldir5.t @@ -4,21 +4,32 @@ BEGIN { require "t/pod2html-lib.pl"; } +END { + rem_test_dir(); +} + use strict; use Cwd; use File::Spec::Functions; use Test::More tests => 1; -my $cwd = catdir cwd(); # catdir converts path separators to that of the OS - # running the test - # XXX but why don't the other tests complain about this? +SKIP: { + my $output = make_test_dir(); + skip "$output", 1 if $output; + -convert_n_test("htmldir5", "test --htmldir and --htmlroot 5", - "--podpath=t:test.lib", - "--podroot=$cwd", - "--htmldir=$cwd", - "--htmlroot=/", -); + my $cwd = catdir cwd(); # catdir converts path separators to that of the OS + # running the test + # XXX but why don't the other tests complain about + # this? + + convert_n_test("htmldir5", "test --htmldir and --htmlroot 5", + "--podpath=t:testdir/test.lib", + "--podroot=$cwd", + "--htmldir=$cwd", + "--htmlroot=/", + ); +} __DATA__ @@ -47,7 +58,7 @@ __DATA__

Normal text, a link to nowhere,

-

a link to perlvar-copy,

+

a link to var-copy,

htmlescp,

diff --git a/ext/Pod-Html/t/pod2html-lib.pl b/ext/Pod-Html/t/pod2html-lib.pl index f10747f..7a71e4c 100644 --- a/ext/Pod-Html/t/pod2html-lib.pl +++ b/ext/Pod-Html/t/pod2html-lib.pl @@ -2,6 +2,30 @@ require Cwd; require Pod::Html; require Config; use File::Spec::Functions ':ALL'; +use File::Path 'remove_tree'; +use File::Copy; + +# make_test_dir and rem_test_dir dynamically create and remove testdir/test.lib. +# it is created dynamically to pass t/filenames.t, which does not allow '.'s in +# filenames as '.' is the directory separator on VMS. All tests that require +# testdir/test.lib to be present are skipped if test.lib cannot be created. +sub make_test_dir { + if (-d 'testdir/test.lib') { + warn "Directory 'test.lib' exists (it shouldn't yet) - removing it"; + rem_test_dir(); + } + mkdir('testdir/test.lib') or return "Could not make test.lib directory: $!\n"; + copy('testdir/perlpodspec-copy.pod', 'testdir/test.lib/podspec-copy.pod') + or return "Could not copy perlpodspec-copy: $!"; + copy('testdir/perlvar-copy.pod', 'testdir/test.lib/var-copy.pod') + or return "Could not copy perlvar-copy: $!"; + return 0; +} + +sub rem_test_dir { + remove_tree('testdir/test.lib') + or warn "Error removing temporary directory 'testdir/test.lib'"; +} sub convert_n_test { my($podfile, $testname, @p2h_args) = @_; diff --git a/ext/Pod-Html/test.lib/perlpodspec-copy.pod b/ext/Pod-Html/testdir/perlpodspec-copy.pod similarity index 100% rename from ext/Pod-Html/test.lib/perlpodspec-copy.pod rename to ext/Pod-Html/testdir/perlpodspec-copy.pod diff --git a/ext/Pod-Html/test.lib/perlvar-copy.pod b/ext/Pod-Html/testdir/perlvar-copy.pod similarity index 100% rename from ext/Pod-Html/test.lib/perlvar-copy.pod rename to ext/Pod-Html/testdir/perlvar-copy.pod diff --git a/t/porting/known_pod_issues.dat b/t/porting/known_pod_issues.dat index f4a53c5..2ba19a1 100644 --- a/t/porting/known_pod_issues.dat +++ b/t/porting/known_pod_issues.dat @@ -177,10 +177,10 @@ ext/hash-util-fieldhash/lib/hash/util/fieldhash.pm Verbatim line length includin ext/i18n-langinfo/langinfo.pm Verbatim line length including indents exceeds 79 by 1 ext/opcode/opcode.pm Verbatim line length including indents exceeds 79 by 10 ext/pod-html/bin/pod2html Pod NAME already used 1 -ext/pod-html/test.lib/perlpodspec-copy.pod Verbatim line length including indents exceeds 79 by 8 -ext/pod-html/test.lib/perlvar-copy.pod ? Should you be using L<...> instead of 3 -ext/pod-html/test.lib/perlvar-copy.pod Apparent broken link 2 -ext/pod-html/test.lib/perlvar-copy.pod Verbatim line length including indents exceeds 79 by 6 +ext/pod-html/testdir/perlpodspec-copy.pod Verbatim line length including indents exceeds 79 by 8 +ext/pod-html/testdir/perlvar-copy.pod ? Should you be using L<...> instead of 3 +ext/pod-html/testdir/perlvar-copy.pod Apparent broken link 2 +ext/pod-html/testdir/perlvar-copy.pod Verbatim line length including indents exceeds 79 by 6 ext/posix/lib/posix.pod Verbatim line length including indents exceeds 79 by 29 ext/re/re.pm Verbatim line length including indents exceeds 79 by 6 ext/vms-dclsym/dclsym.pm ? Should you be using L<...> instead of 1 -- 1.8.3.1