r24189 - in /trunk/libtest-strict-perl: blib/ blib/lib/ blib/lib/Test/ blib/man3/ debian/

jeremiah-guest at users.alioth.debian.org jeremiah-guest at users.alioth.debian.org
Tue Aug 12 10:19:25 UTC 2008


Author: jeremiah-guest
Date: Tue Aug 12 10:19:22 2008
New Revision: 24189

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=24189
Log:
[svn-inject] Applying Debian modifications to trunk

Added:
    trunk/libtest-strict-perl/blib/
    trunk/libtest-strict-perl/blib/lib/
    trunk/libtest-strict-perl/blib/lib/Test/
    trunk/libtest-strict-perl/blib/lib/Test/Strict.pm
    trunk/libtest-strict-perl/blib/man3/
    trunk/libtest-strict-perl/blib/man3/Test::Strict.3pm
    trunk/libtest-strict-perl/debian/
    trunk/libtest-strict-perl/debian/changelog
    trunk/libtest-strict-perl/debian/compat
    trunk/libtest-strict-perl/debian/control
    trunk/libtest-strict-perl/debian/copyright
    trunk/libtest-strict-perl/debian/libtest-strict-perl.docs
    trunk/libtest-strict-perl/debian/rules   (with props)
    trunk/libtest-strict-perl/debian/watch

Added: trunk/libtest-strict-perl/blib/lib/Test/Strict.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtest-strict-perl/blib/lib/Test/Strict.pm?rev=24189&op=file
==============================================================================
--- trunk/libtest-strict-perl/blib/lib/Test/Strict.pm (added)
+++ trunk/libtest-strict-perl/blib/lib/Test/Strict.pm Tue Aug 12 10:19:22 2008
@@ -1,0 +1,434 @@
+package Test::Strict;
+
+=head1 NAME
+
+Test::Strict - Check syntax, presence of use strict; and test coverage
+
+=head1 SYNOPSIS
+
+C<Test::Strict> lets you check the syntax, presence of C<use strict;>
+and presence C<use warnings;>
+in your perl code.
+It report its results in standard C<Test::Simple> fashion:
+
+  use Test::Strict tests => 3;
+  syntax_ok( 'bin/myscript.pl' );
+  strict_ok( 'My::Module', "use strict; in My::Module" );
+  warnings_ok( 'lib/My/Module.pm' );
+
+Module authors can include the following in a t/strict.t
+and have C<Test::Strict> automatically find and check
+all perl files in a module distribution:
+
+  use Test::Strict;
+  all_perl_files_ok(); # Syntax ok and use strict;
+
+or
+
+  use Test::Strict;
+  all_perl_files_ok( @mydirs );
+
+C<Test::Strict> can also enforce a minimum test coverage
+the test suite should reach.
+Module authors can include the following in a t/cover.t
+and have C<Test::Strict> automatically check the test coverage:
+
+  use Test::Strict;
+  all_cover_ok( 80 );  # at least 80% coverage
+
+or
+
+  use Test::Strict;
+  all_cover_ok( 80, 't/' );
+
+=head1 DESCRIPTION
+
+The most basic test one can write is "does it compile ?".
+This module tests if the code compiles and play nice with C<Test::Simple> modules.
+
+Another good practice this module can test is to "use strict;" in all perl files.
+
+By setting a minimum test coverage through C<all_cover_ok()>, a code author
+can ensure his code is tested above a preset level of I<kwality> throughout the development cycle.
+
+Along with L<Test::Pod>, this module can provide the first tests to setup for a module author.
+
+This module should be able to run under the -T flag for perl >= 5.6.
+All paths are untainted with the following pattern: C<qr|^([-+@\w./:\\]+)$|>
+controlled by C<$Test::Strict::UNTAINT_PATTERN>.
+
+=cut
+
+use strict;
+use 5.004;
+use Test::Builder;
+use File::Spec;
+use FindBin qw($Bin);
+use File::Find;
+
+use vars qw( $VERSION $PERL $COVERAGE_THRESHOLD $COVER $UNTAINT_PATTERN $PERL_PATTERN $CAN_USE_WARNINGS $TEST_SYNTAX $TEST_STRICT $TEST_WARNINGS $DEVEL_COVER_OPTIONS );
+$VERSION = '0.09';
+$PERL    = $^X || 'perl';
+$COVERAGE_THRESHOLD = 50; # 50%
+$UNTAINT_PATTERN    = qr|^(.*)$|;
+$PERL_PATTERN       = qr/^#!.*perl/;
+$CAN_USE_WARNINGS   = ($] >= 5.006);
+$TEST_SYNTAX   = 1;
+$TEST_STRICT   = 1;
+$TEST_WARNINGS = 0;
+$DEVEL_COVER_OPTIONS = '+ignore,"/Test/Strict\b"';
+
+my $Test  = Test::Builder->new;
+my $updir = File::Spec->updir();
+my %file_find_arg = ($] <= 5.006) ? ()
+                                  : (
+                                      untaint         => 1,
+                                      untaint_pattern => $UNTAINT_PATTERN,
+                                      untaint_skip    => 1,
+                                    );
+
+
+sub import {
+  my $self   = shift;
+  my $caller = caller;
+  {
+    no strict 'refs';
+    *{$caller.'::strict_ok'}         = \&strict_ok;
+    *{$caller.'::warnings_ok'}       = \&warnings_ok;
+    *{$caller.'::syntax_ok'}         = \&syntax_ok;
+    *{$caller.'::all_perl_files_ok'} = \&all_perl_files_ok;
+    *{$caller.'::all_cover_ok'}      = \&all_cover_ok;
+  }
+  $Test->exported_to($caller);
+  $Test->plan(@_);
+}
+
+
+##
+## _all_perl_files( @dirs )
+## Returns a list of perl files in @dir
+## if @dir is not provided, it searches from one dir level above
+##
+sub _all_perl_files {
+  my @all_files = _all_files(@_);
+  return grep { _is_perl_module($_) || _is_perl_script($_) } @all_files;
+}
+
+sub _all_files {
+  my @base_dirs = @_ ? @_
+                     : File::Spec->catdir($Bin, $updir);
+  my @found;
+  my $want_sub = sub {
+    return if ($File::Find::dir =~ m![\\/]?CVS[\\/]|[\\/]?.svn[\\/]!); # Filter out cvs or subversion dirs/
+    return if ($File::Find::dir =~ m![\\/]?blib[\\/]libdoc$!); # Filter out pod doc in dist
+    return if ($File::Find::dir =~ m![\\/]?blib[\\/]man\d$!); # Filter out pod doc in dist
+    return unless (-f $File::Find::name && -r _);
+    push @found, File::Spec->no_upwards( $File::Find::name );
+  };
+  my $find_arg = {
+                    %file_find_arg,
+                    wanted   => $want_sub,
+                    no_chdir => 1,
+                 };
+  find( $find_arg, @base_dirs);
+  @found;
+}
+
+
+=head1 FUNCTIONS
+
+=head2 syntax_ok( $file [, $text] )
+
+Run a syntax check on C<$file> by running C<perl -c $file> with an external perl interpreter.
+The external perl interpreter path is stored in C<$Test::Strict::PERL> which can be modified.
+You may prefer C<use_ok()> from L<Test::More> to syntax test a module.
+For a module, the path (lib/My/Module.pm) or the name (My::Module) can be both used.
+
+=cut
+
+sub syntax_ok {
+  my $file     = shift;
+  my $test_txt = shift || "Syntax check $file";
+  $file = _module_to_path($file);
+  unless (-f $file && -r _) {
+    $Test->ok( 0, $test_txt );
+    $Test->diag( "File $file not found or not readable" );
+    return;
+  }
+  if (! _is_perl_module($file) and ! _is_perl_script($file)) {
+    $Test->ok( 0, $test_txt );
+    $Test->diag( "$file is not a perl module or a perl script" );
+    return;
+  }
+
+  my $inc = join(' -I ', @INC) || '';
+  $inc = "-I $inc" if $inc;
+  $file            = _untaint($file);
+  my $perl_bin     = _untaint($PERL);
+  local $ENV{PATH} = _untaint($ENV{PATH}) if $ENV{PATH};
+
+  my $eval = `$perl_bin $inc -c $file 2>&1`;
+  $file = quotemeta($file);
+  my $ok = $eval =~ qr!$file syntax OK!ms;
+  $Test->ok($ok, $test_txt);
+  unless ($ok) {
+    $Test->diag( $eval );
+  }
+  return $ok;
+}
+
+
+=head2 strict_ok( $file [, $text] )
+
+Check if C<$file> contains a C<use strict;> statement.
+
+This is a pretty naive test which may be fooled in some edge cases.
+For a module, the path (lib/My/Module.pm) or the name (My::Module) can be both used.
+
+=cut
+
+sub strict_ok {
+  my $file     = shift;
+  my $test_txt = shift || "use strict   $file";
+  $file = _module_to_path($file);
+  open my($fh), $file or do { $Test->ok(0, $test_txt); $Test->diag("Could not open $file: $!"); return; };
+  while (<$fh>) {
+    next if (/^\s*#/); # Skip comments
+    next if (/^\s*=.+/ .. /^\s*=(cut|back|end)/); # Skip pod
+    last if (/^\s*(__END__|__DATA__)/); # End of code
+    if ( /\buse\s+strict\s*;/ ) {
+      $Test->ok(1, $test_txt);
+      return 1;
+    }
+  }
+  $Test->ok(0, $test_txt);
+  return;
+}
+
+
+=head2 warnings_ok( $file [, $text] )
+
+Check if warnings have been turned on.
+
+If C<$file> is a module, check if it contains a C<use warnings;> or C<use warnings::...> statement.
+However, if the perl version is <= 5.6, this test is skipped (C<use warnings> appeared in perl 5.6).
+
+If C<$file> is a script, check if it starts with C<#!...perl -w>.
+If the -w is not found and perl is >= 5.6, check for a C<use warnings;> or C<use warnings::...> statement.
+
+This is a pretty naive test which may be fooled in some edge cases.
+For a module, the path (lib/My/Module.pm) or the name (My::Module) can be both used.
+
+=cut
+
+sub warnings_ok {
+  my $file = shift;
+  my $test_txt = shift || "use warnings $file";
+  $file = _module_to_path($file);
+  my $is_module = _is_perl_module( $file );
+  my $is_script = _is_perl_script( $file );
+  if (!$is_script and $is_module and ! $CAN_USE_WARNINGS) {
+    $Test->skip();
+    $Test->diag("This version of perl ($]) does not have use warnings - perl 5.6 or higher is required");
+    return;
+  }
+
+  open my($fh), $file or do { $Test->ok(0, $test_txt); $Test->diag("Could not open $file: $!"); return; };
+  while (<$fh>) {
+    if ($. == 1 and $is_script and $_ =~ $PERL_PATTERN) {
+      if (/perl\s+\-\w*[wW]/) {
+        $Test->ok(1, $test_txt);
+        return 1;
+      }
+    }
+    last unless $CAN_USE_WARNINGS;
+    next if (/^\s*#/); # Skip comments
+    next if (/^\s*=.+/ .. /^\s*=(cut|back|end)/); # Skip pod
+    last if (/^\s*(__END__|__DATA__)/); # End of code
+    if ( /\buse\s+warnings(\s|::|;)/ ) {
+      $Test->ok(1, $test_txt);
+      return 1;
+    }
+  }
+  $Test->ok(0, $test_txt);
+  return;
+}
+
+
+=head2 all_perl_files_ok( [ @directories ] )
+
+Applies C<strict_ok()> and C<syntax_ok()> to all perl files found in C<@directories> (and sub directories).
+If no <@directories> is given, the starting point is one level above the current running script,
+that should cover all the files of a typical CPAN distribution.
+A perl file is *.pl or *.pm or *.t or a file starting with C<#!...perl>
+
+If the test plan is defined:
+
+  use Test::Strict tests => 18;
+  all_perl_files_ok();
+
+the total number of files tested must be specified.
+
+You can control which tests are run on each perl site through:
+
+  $Test::Strict::TEST_SYNTAX   (default = 1)
+  $Test::Strict::TEST_STRICT   (default = 1)
+  $Test::Strict::TEST_WARNINGS (default = 0)
+
+=cut
+
+sub all_perl_files_ok {
+  my @files = _all_perl_files( @_ );
+
+  _make_plan();
+  foreach my $file ( @files ) {
+    syntax_ok( $file )   if $TEST_SYNTAX;
+    strict_ok( $file )   if $TEST_STRICT;
+    warnings_ok( $file ) if $TEST_WARNINGS;
+  }
+}
+
+
+=head2 all_cover_ok( [coverage_threshold [, @t_dirs]] )
+
+This will run all the tests in @t_dirs
+(or current script's directory if @t_dirs is undef)
+under L<Devel::Cover>
+and calculate the global test coverage of the code loaded by the tests.
+If the test coverage is greater or equal than C<coverage_threshold>, it is a pass,
+otherwise it's a fail. The default coverage threshold is 50
+(meaning 50% of the code loaded has been covered by test).
+
+The threshold can be modified through C<$Test::Strict::COVERAGE_THRESHOLD>.
+
+You may want to select which files are selected for code
+coverage through C<$Test::Strict::DEVEL_COVER_OPTIONS>,
+see L<Devel::Cover> for the list of available options.
+The default is '+ignore,"/Test/Strict\b"'. 
+
+The path to C<cover> utility can be modified through C<$Test::Strict::COVER>.
+
+The 50% threshold is a completely arbitrary value, which should not be considered
+as a good enough coverage.
+
+The total coverage is the return value of C<all_cover_ok()>.
+
+=cut
+
+sub all_cover_ok {
+  my $threshold = shift || $COVERAGE_THRESHOLD;
+  my @dirs = @_ ? @_
+                : (File::Spec->splitpath( $0 ))[1] || '.';
+  my @all_files = grep { ! /$0$/o && $0 !~ /$_$/ }
+                  grep { _is_perl_script($_)     }
+                       _all_files(@dirs);
+  _make_plan();
+
+  my $cover_bin    = _cover_path() or do{ $Test->skip(); $Test->diag("Cover binary not found"); return};
+  my $perl_bin     = _untaint($PERL);
+  local $ENV{PATH} = _untaint($ENV{PATH}) if $ENV{PATH};
+  `$cover_bin -delete`;
+  if ($?) {
+    $Test->skip();
+    $Test->diag("Cover binary $cover_bin not found");
+    return;
+  }
+  foreach my $file ( @all_files ) {
+    $file = _untaint($file);
+    `$perl_bin -MDevel::Cover=$DEVEL_COVER_OPTIONS $file 2>&1 > /dev/null`;
+    $Test->ok(! $?, "Coverage captured from $file" );
+  }
+  $Test->ok(my $cover = `$cover_bin 2>/dev/null`, "Got cover");
+
+  my ($total) = ($cover =~ /^\s*Total.+?([\d\.]+)\s*$/m);
+  $Test->ok( $total >= $threshold, "coverage = ${total}% > ${threshold}%");
+  return $total;
+}
+
+
+sub _is_perl_module {
+  $_[0] =~ /\.pm$/i
+  ||
+  $_[0] =~ /::/;
+}
+
+
+sub _is_perl_script {
+  my $file = shift;
+  return 1 if $file =~ /\.pl$/i;
+  return 1 if $file =~ /\.t$/;
+  open my($fh), $file or return;
+  my $first = <$fh>;
+  return 1 if defined $first && ($first =~ $PERL_PATTERN);
+  return;
+}
+
+
+##
+## Return the path of a module
+##
+sub _module_to_path {
+  my $file = shift;
+  return $file unless ($file =~ /::/);
+  my @parts = split /::/, $file;
+  my $module = File::Spec->catfile(@parts) . '.pm';
+  foreach my $dir (@INC) {
+    my $candidate = File::Spec->catfile($dir, $module);
+    next unless (-e $candidate && -f _ && -r _);
+    return $candidate;
+  }
+  return $file; # non existing file - error is catched elsewhere
+}
+
+
+sub _cover_path {
+  return $COVER if $COVER;
+  foreach my $path (split /:/, $ENV{PATH}) {
+    my $path_cover = File::Spec->catfile($path, 'cover');
+    next unless -x $path_cover;
+    return $COVER = _untaint($path_cover);
+  }
+  return;
+}
+
+
+sub _make_plan {
+  unless ($Test->has_plan) {
+    $Test->plan( no_plan => 1 );
+  }
+  $Test->expected_tests;
+}
+
+
+sub _untaint {
+  my @untainted = map {($_ =~ $UNTAINT_PATTERN)} @_;
+  wantarray ? @untainted
+            : $untainted[0];
+}
+
+
+=head1 CAVEATS
+
+For C<all_cover_ok()> to work properly, it is strongly advised to install the most recent version of L<Devel::Cover>
+and use perl 5.8.1 or above.
+In the case of a C<make test> scenario, C<all_perl_files_ok()> re-run all the tests in a separate perl interpreter,
+this may lead to some side effects.
+
+=head1 SEE ALSO
+
+L<Test::More>, L<Test::Pod>. L<Test::Distribution>, L<Test:NoWarnings>
+
+=head1 AUTHOR
+
+Pierre Denis, C<< <pierre at itrelease.net> >>.
+
+=head1 COPYRIGHT
+
+Copyright 2005, Pierre Denis, All Rights Reserved.
+
+You may use, modify, and distribute this package under the
+same terms as Perl itself.
+
+=cut
+
+1;

Added: trunk/libtest-strict-perl/blib/man3/Test::Strict.3pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtest-strict-perl/blib/man3/Test%3A%3AStrict.3pm?rev=24189&op=file
==============================================================================
--- trunk/libtest-strict-perl/blib/man3/Test::Strict.3pm (added)
+++ trunk/libtest-strict-perl/blib/man3/Test::Strict.3pm Tue Aug 12 10:19:22 2008
@@ -1,0 +1,297 @@
+.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05)
+.\"
+.\" Standard preamble:
+.\" ========================================================================
+.de Sh \" Subsection heading
+.br
+.if t .Sp
+.ne 5
+.PP
+\fB\\$1\fR
+.PP
+..
+.de Sp \" Vertical space (when we can't use .PP)
+.if t .sp .5v
+.if n .sp
+..
+.de Vb \" Begin verbatim text
+.ft CW
+.nf
+.ne \\$1
+..
+.de Ve \" End verbatim text
+.ft R
+.fi
+..
+.\" Set up some character translations and predefined strings.  \*(-- will
+.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
+.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
+.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
+.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
+.\" nothing in troff, for use with C<>.
+.tr \(*W-
+.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
+.ie n \{\
+.    ds -- \(*W-
+.    ds PI pi
+.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
+.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
+.    ds L" ""
+.    ds R" ""
+.    ds C` ""
+.    ds C' ""
+'br\}
+.el\{\
+.    ds -- \|\(em\|
+.    ds PI \(*p
+.    ds L" ``
+.    ds R" ''
+'br\}
+.\"
+.\" Escape single quotes in literal strings from groff's Unicode transform.
+.ie \n(.g .ds Aq \(aq
+.el       .ds Aq '
+.\"
+.\" If the F register is turned on, we'll generate index entries on stderr for
+.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
+.\" entries marked with X<> in POD.  Of course, you'll have to process the
+.\" output yourself in some meaningful fashion.
+.ie \nF \{\
+.    de IX
+.    tm Index:\\$1\t\\n%\t"\\$2"
+..
+.    nr % 0
+.    rr F
+.\}
+.el \{\
+.    de IX
+..
+.\}
+.\"
+.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
+.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
+.    \" fudge factors for nroff and troff
+.if n \{\
+.    ds #H 0
+.    ds #V .8m
+.    ds #F .3m
+.    ds #[ \f1
+.    ds #] \fP
+.\}
+.if t \{\
+.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
+.    ds #V .6m
+.    ds #F 0
+.    ds #[ \&
+.    ds #] \&
+.\}
+.    \" simple accents for nroff and troff
+.if n \{\
+.    ds ' \&
+.    ds ` \&
+.    ds ^ \&
+.    ds , \&
+.    ds ~ ~
+.    ds /
+.\}
+.if t \{\
+.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
+.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
+.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
+.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
+.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
+.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
+.\}
+.    \" troff and (daisy-wheel) nroff accents
+.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
+.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
+.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
+.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
+.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
+.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
+.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
+.ds ae a\h'-(\w'a'u*4/10)'e
+.ds Ae A\h'-(\w'A'u*4/10)'E
+.    \" corrections for vroff
+.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
+.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
+.    \" for low resolution devices (crt and lpr)
+.if \n(.H>23 .if \n(.V>19 \
+\{\
+.    ds : e
+.    ds 8 ss
+.    ds o a
+.    ds d- d\h'-1'\(ga
+.    ds D- D\h'-1'\(hy
+.    ds th \o'bp'
+.    ds Th \o'LP'
+.    ds ae ae
+.    ds Ae AE
+.\}
+.rm #[ #] #H #V #F C
+.\" ========================================================================
+.\"
+.IX Title "Test::Strict 3pm"
+.TH Test::Strict 3pm "2008-02-24" "perl v5.10.0" "User Contributed Perl Documentation"
+.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
+.\" way too many mistakes in technical documents.
+.if n .ad l
+.nh
+.SH "NAME"
+Test::Strict \- Check syntax, presence of use strict; and test coverage
+.SH "SYNOPSIS"
+.IX Header "SYNOPSIS"
+\&\f(CW\*(C`Test::Strict\*(C'\fR lets you check the syntax, presence of \f(CW\*(C`use strict;\*(C'\fR
+and presence \f(CW\*(C`use warnings;\*(C'\fR
+in your perl code.
+It report its results in standard \f(CW\*(C`Test::Simple\*(C'\fR fashion:
+.PP
+.Vb 4
+\&  use Test::Strict tests => 3;
+\&  syntax_ok( \*(Aqbin/myscript.pl\*(Aq );
+\&  strict_ok( \*(AqMy::Module\*(Aq, "use strict; in My::Module" );
+\&  warnings_ok( \*(Aqlib/My/Module.pm\*(Aq );
+.Ve
+.PP
+Module authors can include the following in a t/strict.t
+and have \f(CW\*(C`Test::Strict\*(C'\fR automatically find and check
+all perl files in a module distribution:
+.PP
+.Vb 2
+\&  use Test::Strict;
+\&  all_perl_files_ok(); # Syntax ok and use strict;
+.Ve
+.PP
+or
+.PP
+.Vb 2
+\&  use Test::Strict;
+\&  all_perl_files_ok( @mydirs );
+.Ve
+.PP
+\&\f(CW\*(C`Test::Strict\*(C'\fR can also enforce a minimum test coverage
+the test suite should reach.
+Module authors can include the following in a t/cover.t
+and have \f(CW\*(C`Test::Strict\*(C'\fR automatically check the test coverage:
+.PP
+.Vb 2
+\&  use Test::Strict;
+\&  all_cover_ok( 80 );  # at least 80% coverage
+.Ve
+.PP
+or
+.PP
+.Vb 2
+\&  use Test::Strict;
+\&  all_cover_ok( 80, \*(Aqt/\*(Aq );
+.Ve
+.SH "DESCRIPTION"
+.IX Header "DESCRIPTION"
+The most basic test one can write is \*(L"does it compile ?\*(R".
+This module tests if the code compiles and play nice with \f(CW\*(C`Test::Simple\*(C'\fR modules.
+.PP
+Another good practice this module can test is to \*(L"use strict;\*(R" in all perl files.
+.PP
+By setting a minimum test coverage through \f(CW\*(C`all_cover_ok()\*(C'\fR, a code author
+can ensure his code is tested above a preset level of \fIkwality\fR throughout the development cycle.
+.PP
+Along with Test::Pod, this module can provide the first tests to setup for a module author.
+.PP
+This module should be able to run under the \-T flag for perl >= 5.6.
+All paths are untainted with the following pattern: \f(CW\*(C`qr|^([\-+@\ew./:\e\e]+)$|\*(C'\fR
+controlled by \f(CW$Test::Strict::UNTAINT_PATTERN\fR.
+.SH "FUNCTIONS"
+.IX Header "FUNCTIONS"
+.ie n .Sh "syntax_ok( $file\fP [, \f(CW$text] )"
+.el .Sh "syntax_ok( \f(CW$file\fP [, \f(CW$text\fP] )"
+.IX Subsection "syntax_ok( $file [, $text] )"
+Run a syntax check on \f(CW$file\fR by running \f(CW\*(C`perl \-c $file\*(C'\fR with an external perl interpreter.
+The external perl interpreter path is stored in \f(CW$Test::Strict::PERL\fR which can be modified.
+You may prefer \f(CW\*(C`use_ok()\*(C'\fR from Test::More to syntax test a module.
+For a module, the path (lib/My/Module.pm) or the name (My::Module) can be both used.
+.ie n .Sh "strict_ok( $file\fP [, \f(CW$text] )"
+.el .Sh "strict_ok( \f(CW$file\fP [, \f(CW$text\fP] )"
+.IX Subsection "strict_ok( $file [, $text] )"
+Check if \f(CW$file\fR contains a \f(CW\*(C`use strict;\*(C'\fR statement.
+.PP
+This is a pretty naive test which may be fooled in some edge cases.
+For a module, the path (lib/My/Module.pm) or the name (My::Module) can be both used.
+.ie n .Sh "warnings_ok( $file\fP [, \f(CW$text] )"
+.el .Sh "warnings_ok( \f(CW$file\fP [, \f(CW$text\fP] )"
+.IX Subsection "warnings_ok( $file [, $text] )"
+Check if warnings have been turned on.
+.PP
+If \f(CW$file\fR is a module, check if it contains a \f(CW\*(C`use warnings;\*(C'\fR or \f(CW\*(C`use warnings::...\*(C'\fR statement.
+However, if the perl version is <= 5.6, this test is skipped (\f(CW\*(C`use warnings\*(C'\fR appeared in perl 5.6).
+.PP
+If \f(CW$file\fR is a script, check if it starts with \f(CW\*(C`#!...perl \-w\*(C'\fR.
+If the \-w is not found and perl is >= 5.6, check for a \f(CW\*(C`use warnings;\*(C'\fR or \f(CW\*(C`use warnings::...\*(C'\fR statement.
+.PP
+This is a pretty naive test which may be fooled in some edge cases.
+For a module, the path (lib/My/Module.pm) or the name (My::Module) can be both used.
+.ie n .Sh "all_perl_files_ok( [ @directories ] )"
+.el .Sh "all_perl_files_ok( [ \f(CW at directories\fP ] )"
+.IX Subsection "all_perl_files_ok( [ @directories ] )"
+Applies \f(CW\*(C`strict_ok()\*(C'\fR and \f(CW\*(C`syntax_ok()\*(C'\fR to all perl files found in \f(CW at directories\fR (and sub directories).
+If no <@directories> is given, the starting point is one level above the current running script,
+that should cover all the files of a typical \s-1CPAN\s0 distribution.
+A perl file is *.pl or *.pm or *.t or a file starting with \f(CW\*(C`#!...perl\*(C'\fR
+.PP
+If the test plan is defined:
+.PP
+.Vb 2
+\&  use Test::Strict tests => 18;
+\&  all_perl_files_ok();
+.Ve
+.PP
+the total number of files tested must be specified.
+.PP
+You can control which tests are run on each perl site through:
+.PP
+.Vb 3
+\&  $Test::Strict::TEST_SYNTAX   (default = 1)
+\&  $Test::Strict::TEST_STRICT   (default = 1)
+\&  $Test::Strict::TEST_WARNINGS (default = 0)
+.Ve
+.ie n .Sh "all_cover_ok( [coverage_threshold [, @t_dirs]] )"
+.el .Sh "all_cover_ok( [coverage_threshold [, \f(CW at t_dirs\fP]] )"
+.IX Subsection "all_cover_ok( [coverage_threshold [, @t_dirs]] )"
+This will run all the tests in \f(CW at t_dirs\fR
+(or current script's directory if \f(CW at t_dirs\fR is undef)
+under Devel::Cover
+and calculate the global test coverage of the code loaded by the tests.
+If the test coverage is greater or equal than \f(CW\*(C`coverage_threshold\*(C'\fR, it is a pass,
+otherwise it's a fail. The default coverage threshold is 50
+(meaning 50% of the code loaded has been covered by test).
+.PP
+The threshold can be modified through \f(CW$Test::Strict::COVERAGE_THRESHOLD\fR.
+.PP
+You may want to select which files are selected for code
+coverage through \f(CW$Test::Strict::DEVEL_COVER_OPTIONS\fR,
+see Devel::Cover for the list of available options.
+The default is '+ignore,\*(L"/Test/Strict\eb\*(R"'.
+.PP
+The path to \f(CW\*(C`cover\*(C'\fR utility can be modified through \f(CW$Test::Strict::COVER\fR.
+.PP
+The 50% threshold is a completely arbitrary value, which should not be considered
+as a good enough coverage.
+.PP
+The total coverage is the return value of \f(CW\*(C`all_cover_ok()\*(C'\fR.
+.SH "CAVEATS"
+.IX Header "CAVEATS"
+For \f(CW\*(C`all_cover_ok()\*(C'\fR to work properly, it is strongly advised to install the most recent version of Devel::Cover
+and use perl 5.8.1 or above.
+In the case of a \f(CW\*(C`make test\*(C'\fR scenario, \f(CW\*(C`all_perl_files_ok()\*(C'\fR re-run all the tests in a separate perl interpreter,
+this may lead to some side effects.
+.SH "SEE ALSO"
+.IX Header "SEE ALSO"
+Test::More, Test::Pod. Test::Distribution, <Test:NoWarnings>
+.SH "AUTHOR"
+.IX Header "AUTHOR"
+Pierre Denis, \f(CW\*(C`<pierre at itrelease.net>\*(C'\fR.
+.SH "COPYRIGHT"
+.IX Header "COPYRIGHT"
+Copyright 2005, Pierre Denis, All Rights Reserved.
+.PP
+You may use, modify, and distribute this package under the
+same terms as Perl itself.

Added: trunk/libtest-strict-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtest-strict-perl/debian/changelog?rev=24189&op=file
==============================================================================
--- trunk/libtest-strict-perl/debian/changelog (added)
+++ trunk/libtest-strict-perl/debian/changelog Tue Aug 12 10:19:22 2008
@@ -1,0 +1,5 @@
+libtest-strict-perl (0.09-1) UNRELEASED; urgency=low
+
+  * Initial Release.
+
+ -- Jeremiah C. Foster <jeremiah at jeremiahfoster.com>  Tue, 12 Aug 2008 12:11:42 +0200

Added: trunk/libtest-strict-perl/debian/compat
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtest-strict-perl/debian/compat?rev=24189&op=file
==============================================================================
--- trunk/libtest-strict-perl/debian/compat (added)
+++ trunk/libtest-strict-perl/debian/compat Tue Aug 12 10:19:22 2008
@@ -1,0 +1,1 @@
+7

Added: trunk/libtest-strict-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtest-strict-perl/debian/control?rev=24189&op=file
==============================================================================
--- trunk/libtest-strict-perl/debian/control (added)
+++ trunk/libtest-strict-perl/debian/control Tue Aug 12 10:19:22 2008
@@ -1,0 +1,30 @@
+Source: libtest-strict-perl
+Section: perl
+Priority: optional
+Build-Depends: debhelper (>= 7), perl (>= 5.6.10-12)
+Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
+Uploaders: Jeremiah C. Foster <jeremiah at jeremiahfoster.com>
+Standards-Version: 3.8.0
+Homepage: http://search.cpan.org/dist/Test-Strict/
+Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libtest-strict-perl/
+Vcs-Browser: http://svn.debian.org/wsvn/pkg-perl/trunk/libtest-strict-perl/
+
+Package: libtest-strict-perl
+Architecture: any
+Depends: ${perl:Depends}, ${shlibs:Depends}, ${misc:Depends}, libdevel-cover-perl (>= 0.43)
+Description: Checks the syntax and presence of 'use strict'; and presence of 'use warnings'; in your perl code.
+ The most basic test one can write is "does it compile ?".
+ This module tests if the code compiles and play nice with Test::Simple modules.
+ .
+ Another good practice this module can test is to "use strict;" in all perl files.
+ .
+ By setting a minimum test coverage through all_cover_ok(), a code author
+ can ensure his code is tested above a preset level of kwality throughout the development cycle.
+ .
+ Along with Test::Pod, this module can provide the first tests to setup for a module author.
+ .
+ This module should be able to run under the -T flag for perl >= 5.6.
+ All paths are untainted with the following pattern: qr|^([-+@\w./:\\]+)$|
+ controlled by $Test::Strict::UNTAINT_PATTERN.
+ .
+ This description was automagically extracted from the module by dh-make-perl.

Added: trunk/libtest-strict-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtest-strict-perl/debian/copyright?rev=24189&op=file
==============================================================================
--- trunk/libtest-strict-perl/debian/copyright (added)
+++ trunk/libtest-strict-perl/debian/copyright Tue Aug 12 10:19:22 2008
@@ -1,0 +1,25 @@
+This is the debian package for the Test-Strict module.
+It was created by Jeremiah C. Foster <jeremiah at jeremiahfoster.com> using dh-make-perl.
+
+It was downloaded from http://search.cpan.org/dist/Test-Strict/
+
+This copyright info was automatically extracted from the perl module.
+It may not be accurate, so you better check the module sources
+if you don't want to get into legal troubles.
+
+The upstream author is: Pierre Denis, C<< <pierre at itrelease.net> >>..
+
+
+Copyright 2005, Pierre Denis, All Rights Reserved.
+
+You may use, modify, and distribute this package under the
+same terms as Perl itself.
+
+Perl is distributed under your choice of the GNU General Public License or
+the Artistic License.  On Debian GNU/Linux systems, the complete text of the
+GNU General Public License can be found in `/usr/share/common-licenses/GPL'
+and the Artistic Licence in `/usr/share/common-licenses/Artistic'.
+
+
+The Debian packaging is (C) 2008, Jeremiah C. Foster <jeremiah at jeremiahfoster.com> and
+is licensed under the same terms as the software itself (see above).

Added: trunk/libtest-strict-perl/debian/libtest-strict-perl.docs
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtest-strict-perl/debian/libtest-strict-perl.docs?rev=24189&op=file
==============================================================================
--- trunk/libtest-strict-perl/debian/libtest-strict-perl.docs (added)
+++ trunk/libtest-strict-perl/debian/libtest-strict-perl.docs Tue Aug 12 10:19:22 2008
@@ -1,0 +1,1 @@
+README

Added: trunk/libtest-strict-perl/debian/rules
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtest-strict-perl/debian/rules?rev=24189&op=file
==============================================================================
--- trunk/libtest-strict-perl/debian/rules (added)
+++ trunk/libtest-strict-perl/debian/rules Tue Aug 12 10:19:22 2008
@@ -1,0 +1,23 @@
+#!/usr/bin/make -f
+
+build: build-stamp
+build-stamp:
+	dh build
+	touch $@
+
+clean:
+	dh $@
+
+install: install-stamp
+install-stamp: build-stamp
+	dh install
+	touch $@
+
+binary-arch: install
+	dh $@
+
+binary-indep:
+
+binary: binary-arch binary-indep
+
+.PHONY: binary binary-arch binary-indep install clean build

Propchange: trunk/libtest-strict-perl/debian/rules
------------------------------------------------------------------------------
    svn:executable = *

Added: trunk/libtest-strict-perl/debian/watch
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libtest-strict-perl/debian/watch?rev=24189&op=file
==============================================================================
--- trunk/libtest-strict-perl/debian/watch (added)
+++ trunk/libtest-strict-perl/debian/watch Tue Aug 12 10:19:22 2008
@@ -1,0 +1,4 @@
+# format version number, currently 3; this line is compulsory!
+version=3
+# URL to the package page followed by a regex to search
+http://search.cpan.org/dist/Test-Strict/   .*/Test-Strict-v?(\d[\d_.-]+)\.(?:tar(?:\.gz|\.bz2)?|tgz|zip)$




More information about the Pkg-perl-cvs-commits mailing list