Test-Pod-Content-v0.0.6000755001750001750 011651603423 14722 5ustar00martinmartin000000000000Test-Pod-Content-v0.0.6/MANIFEST000444001750001750 34311651603423 16170 0ustar00martinmartin000000000000Build.PL Changes HACKING lib/Test/Pod/Content.pm Makefile.PL MANIFEST This list of files META.yml README t/096_characters.t t/097_kwalitee.t t/098_pod.t t/099_pod_coverage.t t/critic.t t/license.t t/perlcriticrc t/synopsis.t Test-Pod-Content-v0.0.6/Build.PL000444001750001750 105611651603423 16355 0ustar00martinmartin000000000000use strict; use warnings; use Module::Build; Module::Build->new( dist_author => 'Martin Kutter ', create_makefile_pl => 'small', dist_abstract => 'Test Pod content', dist_name => 'Test-Pod-Content', version_from => 'Test::Pod::Content', module_name => 'Test::Pod::Content', license => 'perl', requires => { 'version' => 0, 'Test::More' => 0, 'Pod::Simple' => 0, } )->create_build_script; Test-Pod-Content-v0.0.6/HACKING000444001750001750 257211651603423 16054 0ustar00martinmartin000000000000HACKING Test::Pod::Content -------------------------- VCS --- Test::Pod::Content uses a Subversion repository at http://svn.hyper-framework.org/Hyper/Test-Pod-Content/ Developer (commit) SVN access is restricted, but you may use the SVN version for generating patches. Patches should be generated as unified diff (svn can do this for you - try svn help diff or just say 'svn diff --old .' in your Test::Pod::Content working dir. You'll have to say 'svn add FILENAME' for new files before, and 'svn revert FILENAME' afterwards). CODING STYLE ------------ Test modules require a high quality coding style, so Test::Pod::Content does it's best to comply to the style laid out in Perl Best Practices by Damian Conway. As always, there's a few exceptions: * The use of $@ is allowed for simplicity "use English" can induce subtle misbehaviours, and $@ really is a well-known variable. * The use of "die" is allowed, because Test::Pod::Content never dies to signal errors, but only to (reliably) terminate a Pod Parser run. It's pretty useless to croak on an exception that get's caught anyway. There are some die statements which might not get caught, but these are just re-throwing previously-throwed exceptions. The exceptions are configured in t/perlcriticrc. The module may be criticised via perlcritic -profile t/perlcriticrc lib December 2007 Martin Kutter Test-Pod-Content-v0.0.6/META.yml000444001750001750 77711651603423 16323 0ustar00martinmartin000000000000--- abstract: 'Test Pod content' author: - 'Martin Kutter ' configure_requires: Module::Build: 0.36 generated_by: 'Module::Build version 0.3603' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Test-Pod-Content provides: Test::Pod::Content: file: lib/Test/Pod/Content.pm version: v0.0.6 requires: Pod::Simple: 0 Test::More: 0 version: 0 resources: license: http://dev.perl.org/licenses/ version: v0.0.6 Test-Pod-Content-v0.0.6/Makefile.PL000444001750001750 42511651603423 17012 0ustar00martinmartin000000000000# Note: this file was auto-generated by Module::Build::Compat version 0.3603 use Module::Build::Compat 0.02; Module::Build::Compat->run_build_pl(args => \@ARGV); require Module::Build; Module::Build::Compat->write_makefile(build_class => 'Module::Build'); Test-Pod-Content-v0.0.6/Changes000444001750001750 54411651603423 16335 0ustar00martinmartin0000000000000.0.5 - added kwalitee tests to MANIFEST - fixed version string error 0.0.4 - added kwalitee tests - fixed a POD error 0.0.3 - added "version" to prereqs - added .perlcriticrc - updated docs and code to allow perlcritic -1 to pass (with .perlcriticrc) 0.0.2 - Dec 25 2007 - updated tests - updated docs 0.0.1 - Dec 22 2007 - first (unreleased) version Test-Pod-Content-v0.0.6/README000444001750001750 75011651603423 15721 0ustar00martinmartin000000000000Test::Pod::Content readme ------------------------- Test::Pod::Content is a simple test module for testing a pod's content. INSTALLING ---------- perl Build.PL perl Build perl Build test perl Build install EXAMPLES -------- For examples on Test::Pod::Content's usage, see the test files provided. They test Test::Pod::Content's own Pod using Test::Pod::Content. LICENSE ------- This library is free software - you may distribute/modify it under the same terms as perl itself. Test-Pod-Content-v0.0.6/lib000755001750001750 011651603423 15470 5ustar00martinmartin000000000000Test-Pod-Content-v0.0.6/lib/Test000755001750001750 011651603423 16407 5ustar00martinmartin000000000000Test-Pod-Content-v0.0.6/lib/Test/Pod000755001750001750 011651603423 17131 5ustar00martinmartin000000000000Test-Pod-Content-v0.0.6/lib/Test/Pod/Content.pm000444001750001750 1526511651603423 21267 0ustar00martinmartin000000000000package Test::Pod::Content; use strict; use warnings; use base qw(Pod::Simple Test::More); use Exporter; use version; our $VERSION = qv('0.0.6'); our @EXPORT = qw(pod_section_is pod_section_like); # Globals for running a simple state machine my $_state = q{}; my $_section = q{}; my $_content = q{}; my $_test_content_sub; # cleanup everything once we've run our test sub _reset { my $parser = shift; $_state = q{}; $_section = q{}; $_content = q{}; # source_dead is not reliable - just die to force terminating the # parser run $parser->source_dead(1); die "OK\n"; } sub pod_section_is { my ($name, $section, $content, $comment ) = @_; my $found = 0; $_test_content_sub = sub { my ($parser, $section_name, $test_content) = @_; if ($section_name eq $section) { $found++; Test::More::is($test_content, $content, $comment); _reset($parser); } }; eval { Test::Pod::Content->filter( _find_file($name) ) }; if ($@) { die $@ if ($@ !~m{^OK\n$}xm) }; if (not $found) { Test::More::fail $comment; } return; } sub pod_section_like { my ($name, $section, $regex, $comment ) = @_; my $found = 0; $_test_content_sub = sub { my ($parser, $section_name, $test_content) = @_; if ($section_name eq $section) { $found++; Test::More::like($test_content, $regex, $comment); _reset($parser); } }; eval { Test::Pod::Content->filter( _find_file($name) ) }; if ($@) { die $@ if ($@ !~m{^OK\n$}xm) }; if (not $found) { Test::More::fail $comment; } return; } sub _find_file { my $name = shift; return $name if (-e $name); for my $path (@INC) { return "$path/$name" if -e "$path/$name"; } $name =~s{::}{/}xmg; $name .= '.pm'; for my $path (@INC) { return "$path/$name" if -e "$path/$name"; } return; } sub _handle_element_start { my($parser, $element_name, $attr_hash_r) = @_; # print "START $element_name\n"; if ($element_name =~m{^head\d$}xm) { # Test last section's content on every new section $_test_content_sub->($parser, $_section, $_content); $_state = 'section'; $_content = q{}; } return; } sub _handle_element_end { my($parser, $element_name) = @_; # print "END $element_name\n"; if ($element_name =~m{^Document$}xm) { $_test_content_sub->($parser, $_section, $_content); } return; } sub _handle_text { my($parser, $text) = @_; # print "TEXT $text\n"; if ($_state eq 'section') { $_section = $text; $_state = 'section_content_start'; return; } if ($_state eq 'section_content_start') { $_content .= $text; } return; } 1; __END__ =pod =head1 NAME Test::Pod::Content - Test a Pod's content =head1 SYNOPSIS use Test::Pod::Content tests => 3; pod_section_is 'Test::Pod::Content' , 'NAME', "Test::Pod::Content - Test a Pod's content", 'NAME section'; pod_section_like 'Test/Pod/Content.pm', 'SYNOPSIS', qr{ use \s Test::Pod::Content; }xm, 'SYNOPSIS section'; pod_section_like 'Test/Pod/Content.pm', 'DESCRIPTION', qr{ Test::Pod::Content \s provides \s the }xm, 'DESCRIPTION section'; =head1 DESCRIPTION This is a very simple module for testing a Pod's content. It is mainly intended for testing the content of generated Pod - that is, the Pod included in perl modules generated by some mechanism. Another usage example is to test whether all files contain the same copyright notice: =for test plan tests => scalar @filelist; for my $file (sort @filelist) { pod_section_like( $file, 'LICENSE AND COPYRIGHT', qr{ This \s library \s is \s free \s software\. \s You \s may \s distribute/modify \s it \s under \s the \s same \s terms \s as \s perl \s itself }xms, "$file License notice"); } See the files in the t/ directory for live examples. Test::Pod::Content has a very simple concept of Pods: To Test::Pod::Content, a Pod is separated into section. Each section starts with a =head(1|2|3|4) directive, and ends with the next =head, or with the end of the document (=cut). This is a very drastic simplification of Pod's document object model, and only allows for coarse-grained tests. Test::Pod::Content provides the following subroutines for testing a Pod's content: =head1 SUBROUTINES/METHODS =head2 pod_section_is pod_section_is $file, $section, $content, $comment; Tests whether a Pod section contains exactly the text given. Most useful for testing the NAME section. You probably want to use pod_section_like for all other sections. $file may either be a filename (including path) or a module name. Test::Pod::Content will search in @INC for the file/module given. =head2 pod_section_like pod_section_like $file, $section, qr{ use \s Test::Pod::Content\s }xm, $comment; Tests whether the text in a Pod section matches the given regex. Be sure to include the m / s regex qualifier if you expect your Pod section to span multiple lines. $file may either be a filename (including path) or a module name. Test::Pod::Content will search in @INC for the file/module given. =head1 BUGS AND LIMITATIONS =over =item * Performance Every call to a pod_section_* method searches for the file in question in @INC and parses it from its start. This means that every test requires a Pod parser run, which is quite inefficient if you conduct a big number of tests. =item * Pod Syntax Test::Pod::Coverage may report wrong test results if your pod is not syntactically correct. You should use L to check your Pod's syntax. =back =head1 DEPENDENCIES L L L =head1 INCOMPATIBILITIES None known =head1 SEE ALSO L for testing your POD's validity L for checking wether your pod is complete L, L and L for extracting and executing tests from a POD (If you plan doing so, here's a little brain-train: Which of the tests in this module's L section would fail if you extracted and executed it?). =head1 LICENSE AND COPYRIGHT Copyright 2007 Martin Kutter. This library is free software. You may distribute/modify it under the same terms as perl itself =head1 AUTHOR Martin Kutter Emartin.kutter fen-net.deE =head1 REPOSITORY INFORMATION $Id: Content.pm 505 2008-06-22 09:54:54Z kutterma $ $Revision: 505 $ $Source: a $ $Date: 2008-06-22 11:54:54 +0200 (So, 22 Jun 2008) $ $HeadURL: http://svn.hyper-framework.org/Hyper/Test-Pod-Content/trunk/lib/Test/Pod/Content.pm $ =cut Test-Pod-Content-v0.0.6/t000755001750001750 011651603423 15165 5ustar00martinmartin000000000000Test-Pod-Content-v0.0.6/t/098_pod.t000444001750001750 106111651603423 16667 0ustar00martinmartin000000000000use Test::More; if ( not $ENV{RELEASE_TESTING} ) { my $msg = 'Author test. Set $ENV{RELEASE_TESTING} to a true value to run.'; plan( skip_all => $msg ); } eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; my @dir_from = (); if (!$ENV{HARNESS_ACTIVE}) { # perl Build test or make test run from top-level dir. if ( -d '../t/' ) { @dir_from = ('../lib/'); } } my @files = all_pod_files(@dir_from); plan tests => scalar(@files); foreach my $module (@files){ pod_file_ok( $module ) } Test-Pod-Content-v0.0.6/t/097_kwalitee.t000444001750001750 62711651603423 17700 0ustar00martinmartin000000000000#!/usr/bin/perl use strict; use warnings; use Test::More; use English qw(-no_match_vars); if ( not $ENV{RELEASE_TESTING} ) { my $msg = 'Author test. Set $ENV{RELEASE_TESTING} to a true value to run.'; plan( skip_all => $msg ); } chdir '..' if -d ('../t'); eval 'use Test::Kwalitee'; if ( $EVAL_ERROR ) { my $msg = 'Test::Kwalitee not installed; skipping'; plan( skip_all => $msg ); } Test-Pod-Content-v0.0.6/t/096_characters.t000444001750001750 341711651603423 20231 0ustar00martinmartin000000000000#!/usr/bin/perl use strict; use warnings; use Test::More; use English qw(-no_match_vars); use File::Find; use IO::File; if ( not $ENV{RELEASE_TESTING} ) { my $msg = 'Author test. Set $ENV{RELEASE_TESTING} to a true value to run.'; plan( skip_all => $msg ); } my $dir = 'blib/lib'; if (-d '../t') { $dir = '../lib'; } my @filelist = (); find( \&filelist, $dir); sub filelist { my $name = $_; return if -d $name; return if $File::Find::name =~ m{\.(?:c|o|svn)$}x; push @filelist, $File::Find::name; } plan tests => scalar @filelist; for my $file (sort @filelist) { check_file($file); } sub check_file { my $file = shift; my $fh = IO::File->new($file, O_RDONLY) or die "Cannot open $file"; my $line_nr = 0; my $error_count = 0; while (my $line = $fh->getline() ) { # check for trailing whitespace # allow single whitespace on line to allow # pod source blocks with empty lines # $line_nr++; if ($line =~m{ (:?[^\s]+|\s)\s\r?\n$ }x) { $error_count++; print "# trailing whitespace in $file line $line_nr at end of line\n" } # check for tabs and report their position my @tab_pos_from = (); my $pos = -1; while (1) { $pos = index($line, "\t", $pos + 1); last if $pos <0; push @tab_pos_from, $pos + 1; } if (@tab_pos_from) { print "# tab found in $file line $line_nr cols ${ \join(', ', @tab_pos_from) }\n"; $error_count += scalar(@tab_pos_from); } if ($line=~m{\r}) { print "# CR (\\r) found in $file line $line_nr. Convert to LF only.\n"; $error_count++; } } is $error_count, 0 , "$file characters"; } Test-Pod-Content-v0.0.6/t/perlcriticrc000444001750001750 110011651603423 17722 0ustar00martinmartin000000000000# Disable checking for automatic exports, as it is part of # Test:: module's API... [-Perl::Critic::Policy::Modules::ProhibitAutomaticExportation] # Disable requiring to croak, as we always catch, or re-throw [-ErrorHandling::RequireCarping] # allow_messages_ending_with_newlines = 0 [Variables::ProhibitPunctuationVars] allow = $@ [Documentation::RequirePodSections] lib_sections = NAME | SYNOPSIS | DESCRIPTION | SUBROUTINES/METHODS | DEPENDENCIES | BUGS AND LIMITATIONS | LICENSE AND COPYRIGHT | AUTHOR script_sections = NAME | USAGE | OPTIONS | EXIT STATUS | AUTHOR Test-Pod-Content-v0.0.6/t/099_pod_coverage.t000444001750001750 140111651603423 20541 0ustar00martinmartin000000000000use Test::More; if ( not $ENV{RELEASE_TESTING} ) { my $msg = 'Author test. Set $ENV{RELEASE_TESTING} to a true value to run.'; plan( skip_all => $msg ); } eval "use Test::Pod::Coverage 1.00"; plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD" if $@; my @dirs = ( 'lib' ); if (-d '../t/') { # we are inside t/ @dirs = ('../lib'); } else { # we are outside t/ # add ./lib to include path if blib/lib is not there (e.g. we're not # run from Build test or the like) push @INC, './lib' if not grep { $_ eq 'blib/lib' } @INC; } my @files = all_modules( @dirs ); plan tests => scalar @files; foreach (@files) { pod_coverage_ok( $_ , { private => [ qr/^_/, ] }); } Test-Pod-Content-v0.0.6/t/critic.t000444001750001750 123511651603423 16765 0ustar00martinmartin000000000000use strict; use warnings; use Test::More; if ( not $ENV{RELEASE_TESTING} ) { my $msg = 'Author test. Set $ENV{RELEASE_TESTING} to a true value to run.'; plan( skip_all => $msg ); exit 0; } eval { require Test::Perl::Critic; Test::Perl::Critic::import('Test::Perl::Critic', -profile => 't/perlcriticrc', -serverity => 1 ); }; if ($@) { Test::More::plan( skip_all => 'Test::Critic required for testing criticism' ); } if (-d 't/') { all_critic_ok(); } else { # chdir .. is stupid, but the profile has to be given # as argument to import and is loaded in all_critic_ok... chdir '..'; all_critic_ok('lib'); } Test-Pod-Content-v0.0.6/t/license.t000444001750001750 67011651603423 17114 0ustar00martinmartin000000000000use strict; use warnings; use Test::More; use Test::Pod::Content; my @filelist = qw( Test::Pod::Content ); plan( tests => scalar @filelist); for my $file (sort @filelist) { pod_section_like( $file, 'LICENSE AND COPYRIGHT', qr{ This \s library \s is \s free \s software\. \s You \s may \s distribute/modify \s it \s under \s the \s same \s terms \s as \s perl \s itself }xms, "$file License notice"); } Test-Pod-Content-v0.0.6/t/synopsis.t000444001750001750 64211651603423 17360 0ustar00martinmartin000000000000use strict; use warnings; use lib '../lib'; use Test::Pod::Content tests => 3; pod_section_is 'Test::Pod::Content' , 'NAME', "Test::Pod::Content - Test a Pod's content", 'NAME section'; pod_section_like 'Test/Pod/Content.pm', 'SYNOPSIS', qr{ use \s Test::Pod::Content }xm, 'SYNOPSIS section'; pod_section_like 'Test/Pod/Content.pm', 'DESCRIPTION', qr{ Test::Pod::Content \s provides \s the }xm, 'DESCRIPTION section';