I'm writing a test which does basic checks on all the code in a repository. It checks that all scripts and modules compile without warnings. I also want to check that all the POD has no errors or warnings. However, a lot of the code has no POD. I don't want to write all the POD right now, but I do want to test what POD there is. Ideally, it would look something like:
if( has_pod( $file ) ) { pod_ok($file, POD_OK); } else { TODO: { local $TODO = "$file needs docs"; fail("$fail has no docs"); } } Since I don't have a has_pod(), I figured this would work: pod_ok($file, NO_POD|POD_OK); using the Test::Pod flags as a bitmask. It doesn't. It would be nice if it did. Also, pod_ok($INC{"Test/Pod.pm"}) fails. I've added dogfood.t to check that. :) Patch attached.
--- Test-Pod-0.90/MANIFEST 2002-09-06 06:06:12.000000000 +0200 +++ Test-Pod-0.90.new/MANIFEST 2003-02-28 17:17:37.000000000 +0100 @@ -3,6 +3,7 @@ Makefile.PL lib/Pod.pm t/check_pod.t +t/dogfood.t t/load.t t/pod_ok.t t/pod/bad.pod --- Test-Pod-0.90/lib/Pod.pm 2002-12-04 02:07:25.000000000 +0100 +++ Test-Pod-0.90.new/lib/Pod.pm 2003-02-28 17:18:24.000000000 +0100 @@ -35,19 +35,11 @@ my $Test = Test::Builder->new; -use constant OK => 0; -use constant NO_FILE => -2; -use constant NO_POD => -1; -use constant WARNINGS => 1; -use constant ERRORS => 2; - -my %Constants = qw( - 0 POD_OK - -2 NO_FILE - -1 NO_POD - 1 POD_WARNINGS - 2 POD_ERRORS - ); +use constant OK => 1; +use constant NO_FILE => 2; +use constant NO_POD => 4; +use constant WARNINGS => 8; +use constant ERRORS => 16; sub import { @@ -105,7 +97,7 @@ my $status = $hash->{result}; - if( defined $expected and $expected eq $status ) + if( defined $expected and $expected & $status ) { $Test->ok( 1, $name ); } @@ -178,6 +170,8 @@ return \%hash; } +=back + =head1 SOURCE AVAILABILITY This source is part of a SourceForge project which always has the --- Test-Pod-0.90/t/pod_ok.t 2002-11-15 03:12:33.000000000 +0100 +++ Test-Pod-0.90.new/t/pod_ok.t 2003-02-28 17:20:20.000000000 +0100 @@ -6,7 +6,7 @@ { my $name = 'test ok'; -test_out( map "ok $_ - $name", 1 .. 9 ); +test_out( map "ok $_ - $name", 1 .. 11 ); pod_ok( "t/pod/good.pod", undef, , $name ); pod_ok( "t/pod/good.pod", POD_OK , $name ); pod_ok( "t/pod/good.pod", POD_WARNINGS , $name ); @@ -16,8 +16,10 @@ pod_ok( "t/pod/warning.pod", POD_WARNINGS , $name ); pod_ok( "t/pod/warning.pod", POD_ERRORS , $name ); +pod_ok( "t/pod/warning.pod", POD_WARNINGS|POD_ERRORS , $name ); pod_ok( "t/pod/no_pod.pod", NO_POD , $name ); +pod_ok( "t/pod/no_pod.pod", NO_POD|POD_OK, $name ); pod_ok( "t/pod/doesnt_exist.pod", NO_FILE , $name ); test_test( 'All files okay with explicit expectations' ); --- Test-Pod-0.90/t/test_manifest 2002-08-19 07:26:35.000000000 +0200 +++ Test-Pod-0.90.new/t/test_manifest 2003-02-28 17:17:46.000000000 +0100 @@ -1,3 +1,4 @@ load.t check_pod.t pod_ok.t +dogfood.t --- /dev/null 2003-02-28 16:51:20.000000000 +0100 +++ Test-Pod-0.90.new/t/dogfood.t 2003-02-28 17:17:52.000000000 +0100 @@ -0,0 +1,8 @@ +#!/usr/bin/perl -w + +# $Id$ + +use strict; +use Test::Pod tests => 1; + +pod_ok($INC{'Test/Pod.pm'}, undef, "Test::Pod's POD is ok");