From: matthewt Date: Sat, 15 Sep 2007 20:45:42 +0000 (+0000) Subject: redid test setup to be sane pod-wise X-Git-Tag: 1.006009~101 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=275c9dae98ec5028e4d1d74b7105937dafbc79ae;p=p5sagit%2Flocal-lib.git redid test setup to be sane pod-wise git-svn-id: http://dev.catalyst.perl.org/repos/bast/local-lib/1.000/trunk@3744 bd8105ee-0ff8-0310-8827-fb3f25b6796d --- diff --git a/lib/local/lib.pm b/lib/local/lib.pm index 36b2b34..8477833 100644 --- a/lib/local/lib.pm +++ b/lib/local/lib.pm @@ -38,7 +38,9 @@ sub pipeline { } } -=for test pipeline +=begin testing + +#:: test pipeline package local::lib; @@ -46,6 +48,8 @@ package local::lib; my $foo = bless({}, 'Foo'); Test::More::ok($foo->${pipeline qw(foo bar baz)}(10) == -15); +=end testing + =cut sub resolve_path { @@ -66,17 +70,23 @@ sub resolve_empty_path { } } -=for test classmethod setup +=begin testing + +#:: test classmethod setup my $c = 'local::lib'; -=cut +=end testing + +=begin testing -=for test classmethod +#:: test classmethod is($c->resolve_empty_path, '~/perl5'); is($c->resolve_empty_path('foo'), 'foo'); +=end testing + =cut sub resolve_home_path { @@ -120,11 +130,15 @@ sub resolve_relative_path { File::Spec->rel2abs($path); } -=for test classmethod +=begin testing + +#:: test classmethod local *File::Spec::rel2abs = sub { shift; 'FOO'.shift; }; is($c->resolve_relative_path('bar'),'FOObar'); +=end testing + =cut sub setup_local_lib_for { @@ -236,7 +250,9 @@ sub build_environment_vars_for { ) } -=for test classmethod +=begin testing + +#:: test classmethod File::Path::rmtree('t/var/splat'); @@ -246,6 +262,8 @@ ok(-d 't/var/splat'); ok(-f 't/var/splat/.modulebuildrc'); +=end testing + =head1 NAME local::lib - create and use a local lib/ for perl modules with PERL5LIB diff --git a/maint/gen-tests.pl b/maint/gen-tests.pl index 62044e7..c75a806 100755 --- a/maint/gen-tests.pl +++ b/maint/gen-tests.pl @@ -12,11 +12,25 @@ my ($test, $segment, $text); sub mode::outer { shift; - if (shift =~ /^=for test (\S+)(?:\s+(\S+))?/) { + my $line = $_[0]; + if ($line =~ /^=for test (\S+)(?:\s+(\S+))?/) { $mode = 'inner'; ($test, $segment) = ($1, $2); $segment ||= ''; $text = ''; + } elsif ($line =~ /^=begin testing/) { + $mode = 'find_comment'; + ($test, $segment, $text) = ('', '', ''); + } +} + +sub mode::find_comment { + shift; + my $line = $_[0]; + if ($line =~ /^\#\:\: test (\S+)(?:\s+(\S+))?/) { + $mode = 'inner'; + ($test, $segment) = ($1, $2); + $segment ||= ''; } }