[Rt-commit] r5450 - in Test-Dependencies: . branches trunk/lib
trunk/lib/Test trunk/t
zev at bestpractical.com
zev at bestpractical.com
Fri Jun 23 17:47:34 EDT 2006
Author: zev
Date: Fri Jun 23 17:47:33 2006
New Revision: 5450
Added:
Test-Dependencies/branches/
Test-Dependencies/trunk/
Test-Dependencies/trunk/Changes
Test-Dependencies/trunk/MANIFEST
Test-Dependencies/trunk/META.yml
Test-Dependencies/trunk/Makefile.PL
Test-Dependencies/trunk/README
Test-Dependencies/trunk/lib/
Test-Dependencies/trunk/lib/Test/
Test-Dependencies/trunk/lib/Test/Dependencies.pm
Test-Dependencies/trunk/t/
Test-Dependencies/trunk/t/00-load-basic.t
Test-Dependencies/trunk/t/01-load-with-exclude.t
Test-Dependencies/trunk/t/boilerplate.t
Test-Dependencies/trunk/t/pod-coverage.t
Test-Dependencies/trunk/t/pod.t
Modified:
Test-Dependencies/ (props changed)
Log:
r4201 at galvatron (orig r1): zev | 2006-06-21 12:46:41 -0400
r4200 at galvatron: zev | 2006-06-21 12:46:34 -0400
initial checkin
Added: Test-Dependencies/trunk/Changes
==============================================================================
--- (empty file)
+++ Test-Dependencies/trunk/Changes Fri Jun 23 17:47:33 2006
@@ -0,0 +1,5 @@
+Revision history for Test-Dependencies
+
+0.01 Wed Jun 21 12:29:39 EDT 2006
+ First release, based on Jifty's 00-dependencies.t
+
Added: Test-Dependencies/trunk/MANIFEST
==============================================================================
--- (empty file)
+++ Test-Dependencies/trunk/MANIFEST Fri Jun 23 17:47:33 2006
@@ -0,0 +1,11 @@
+Changes
+MANIFEST
+META.yml # Will be created by "make dist"
+Makefile.PL
+README
+lib/Test/Dependencies.pm
+t/00-load-basic.t
+t/01-load-with-excludes.t
+t/boilerplate.t
+t/pod-coverage.t
+t/pod.t
Added: Test-Dependencies/trunk/META.yml
==============================================================================
--- (empty file)
+++ Test-Dependencies/trunk/META.yml Fri Jun 23 17:47:33 2006
@@ -0,0 +1,11 @@
+abstract: Ensure that your Makefile.PL specifies all module dependencies
+author: Zev Benjamin, C<< <zev at cpan.org> >>
+distribution_type: module
+generated_by: Module::Install version 0.62
+license: perl
+name: Test-Dependencies
+no_index:
+ directory:
+ - inc
+ - t
+version: 0.01
Added: Test-Dependencies/trunk/Makefile.PL
==============================================================================
--- (empty file)
+++ Test-Dependencies/trunk/Makefile.PL Fri Jun 23 17:47:33 2006
@@ -0,0 +1,9 @@
+use inc::Module::Install;
+
+name 'Test-Dependencies';
+all_from 'lib/Test/Dependencies.pm';
+
+#requires('');
+
+auto_install;
+WriteAll;
Added: Test-Dependencies/trunk/README
==============================================================================
--- (empty file)
+++ Test-Dependencies/trunk/README Fri Jun 23 17:47:33 2006
@@ -0,0 +1,42 @@
+Test-Dependencies
+
+Makes sure that all of the modules that are 'use'd are listed in the
+Makefile.PL as dependencies.
+
+
+INSTALLATION
+
+To install this module, run the following commands:
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+
+SUPPORT AND DOCUMENTATION
+
+After installing, you can find documentation for this module with the perldoc command.
+
+ perldoc Test::Dependencies
+
+You can also look for information at:
+
+ Search CPAN
+ http://search.cpan.org/dist/Test-Dependencies
+
+ CPAN Request Tracker:
+ http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Dependencies
+
+ AnnoCPAN, annotated CPAN documentation:
+ http://annocpan.org/dist/Test-Dependencies
+
+ CPAN Ratings:
+ http://cpanratings.perl.org/d/Test-Dependencies
+
+COPYRIGHT AND LICENCE
+
+Copyright (C) 2006 Zev Benjamin
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
Added: Test-Dependencies/trunk/lib/Test/Dependencies.pm
==============================================================================
--- (empty file)
+++ Test-Dependencies/trunk/lib/Test/Dependencies.pm Fri Jun 23 17:47:33 2006
@@ -0,0 +1,172 @@
+package Test::Dependencies;
+
+use warnings;
+use strict;
+
+use Carp;
+use File::Find;
+use Module::CoreList;
+use Pod::Strip;
+use Test::More qw(no_plan);
+
+use Exporter;
+our @ISA = qw/Exporter/;
+
+=head1 NAME
+
+Test::Dependencies - Ensure that your Makefile.PL specifies all module dependencies
+
+=head1 VERSION
+
+Version 0.01
+
+=cut
+
+our $VERSION = '0.01';
+
+=head1 SYNOPSIS
+
+In your t/00-dependencies.t:
+
+ use Test::Dependencies exclude =>
+ [qw/ Your::Namespace Some::Other::Namespace /];
+
+ ok_dependencies();
+
+=head1 DESCRIPTION
+
+Makes sure that all of the modules that are 'use'd are listed in the
+Makefile.PL as dependencies.
+
+=cut
+
+our $exclude_re;
+
+sub import {
+ if (scalar @_ == 3) {
+ # package name, literal exclude, excluded namespaces
+ my $exclude = $_[2];
+ foreach my $namespace (@$exclude) {
+ croak "$namespace is not a valid namespace"
+ unless $namespace =~ m/^(?:(?:\w+::)|)+\w+$/;
+ }
+ $exclude_re = join '|', @$exclude;
+ } elsif (scalar @_ != 1) {
+ croak "wrong number of arguments while using Test::Dependencies";
+ }
+ Test::Dependencies->export_to_level(1, qw/ok_dependencies/);
+}
+
+sub ok_dependencies {
+ my %used;
+
+ my $wanted = sub {
+ return unless -f $_;
+ return if $File::Find::dir =~ m!/.svn($|/)!;
+ return if $File::Find::name =~ /~$/;
+ return if $File::Find::name =~ /\.pod$/;
+ local $/;
+ open(FILE, $_) or return;
+ my $data = <FILE>;
+ close(FILE);
+ my $p = Pod::Strip->new;
+ my $code;
+ $p->output_string(\$code);
+ $p->parse_string_document($data);
+ $used{$1}++ while $code =~ /^\s*use\s+([\w:]+)/gm;
+ while ($code =~ m|^\s*use base qw.([\w\s:]+)|gm) {
+ $used{$_}++ for split ' ', $1;
+ }
+ };
+
+ find( $wanted, qw/ lib bin t /);
+
+ my %required;
+ {
+ local $/;
+ ok(open(MAKEFILE,"Makefile.PL"), "Opened Makefile");
+ my $data = <MAKEFILE>;
+ close(FILE);
+ while ($data =~ /^\s*?requires\('([\w:]+)'(?:\s*=>\s*['"]?([\d\.]+)['"]?)?.*?(?:#(.*))?$/gm) {
+ $required{$1} = $2;
+ if (defined $3 and length $3) {
+ $required{$_} = undef for split ' ', $3;
+ }
+ }
+ }
+
+ for (sort keys %used) {
+ my $first_in = Module::CoreList->first_release($_);
+ next if defined $first_in and $first_in <= 5.00803;
+ next if /^($exclude_re)(::|$)/;
+ ok(exists $required{$_}, "$_ in Makefile.PL");
+ delete $used{$_};
+ delete $required{$_};
+ }
+
+ for (sort keys %required) {
+ my $first_in = Module::CoreList->first_release($_, $required{$_});
+ fail("Required module $_ is already in core") if defined $first_in and $first_in <= 5.00803;
+ }
+}
+
+=head1 AUTHORS
+
+=over 4
+
+=item * Jesse Vincent C<< jesse at bestpractical.org >>
+
+=item * Alex Vandiver C<< alexmv at bestpractical.org >>
+
+=item * Zev Benjamin, C<< <zev at cpan.org> >>
+
+=back
+
+=head1 BUGS
+
+Please report any bugs or feature requests to
+C<bug-test-dependencies at rt.cpan.org>, or through the web interface at
+L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Dependencies>.
+I will be notified, and then you'll automatically be notified of progress on
+your bug as I make changes.
+
+=head1 SUPPORT
+
+You can find documentation for this module with the perldoc command.
+
+ perldoc Test::Dependencies
+
+You can also look for information at:
+
+=over 4
+
+=item * AnnoCPAN: Annotated CPAN documentation
+
+L<http://annocpan.org/dist/Test-Dependencies>
+
+=item * CPAN Ratings
+
+L<http://cpanratings.perl.org/d/Test-Dependencies>
+
+=item * RT: CPAN's request tracker
+
+L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Dependencies>
+
+=item * Search CPAN
+
+L<http://search.cpan.org/dist/Test-Dependencies>
+
+=back
+
+=head1 ACKNOWLEDGEMENTS
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2006 Zev Benjamin, all rights reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
+
+1;
Added: Test-Dependencies/trunk/t/00-load-basic.t
==============================================================================
--- (empty file)
+++ Test-Dependencies/trunk/t/00-load-basic.t Fri Jun 23 17:47:33 2006
@@ -0,0 +1,8 @@
+#!perl -T
+
+# don't specify a plan so that we don't plan twice
+use Test::More;
+
+BEGIN {
+ use_ok( 'Test::Dependencies' );
+}
Added: Test-Dependencies/trunk/t/01-load-with-exclude.t
==============================================================================
--- (empty file)
+++ Test-Dependencies/trunk/t/01-load-with-exclude.t Fri Jun 23 17:47:33 2006
@@ -0,0 +1,9 @@
+#!perl -T
+
+# don't specify a plan so that we don't plan twice
+use Test::More;
+
+BEGIN {
+ use_ok( 'Test::Dependencies', 'exclude',
+ [qw/Some::Namespace Some::Other::Namespace/] );
+}
Added: Test-Dependencies/trunk/t/boilerplate.t
==============================================================================
--- (empty file)
+++ Test-Dependencies/trunk/t/boilerplate.t Fri Jun 23 17:47:33 2006
@@ -0,0 +1,48 @@
+#!perl -T
+
+use strict;
+use warnings;
+use Test::More tests => 3;
+
+sub not_in_file_ok {
+ my ($filename, %regex) = @_;
+ open my $fh, "<", $filename
+ or die "couldn't open $filename for reading: $!";
+
+ my %violated;
+
+ while (my $line = <$fh>) {
+ while (my ($desc, $regex) = each %regex) {
+ if ($line =~ $regex) {
+ push @{$violated{$desc}||=[]}, $.;
+ }
+ }
+ }
+
+ if (%violated) {
+ fail("$filename contains boilerplate text");
+ diag "$_ appears on lines @{$violated{$_}}" for keys %violated;
+ } else {
+ pass("$filename contains no boilerplate text");
+ }
+}
+
+not_in_file_ok(README =>
+ "The README is used..." => qr/The README is used/,
+ "'version information here'" => qr/to provide version information/,
+);
+
+not_in_file_ok(Changes =>
+ "placeholder date/time" => qr(Date/time)
+);
+
+sub module_boilerplate_ok {
+ my ($module) = @_;
+ not_in_file_ok($module =>
+ 'the great new $MODULENAME' => qr/ - The great new /,
+ 'boilerplate description' => qr/Quick summary of what the module/,
+ 'stub function definition' => qr/function[12]/,
+ );
+}
+
+module_boilerplate_ok('lib/Test/Dependencies.pm');
Added: Test-Dependencies/trunk/t/pod-coverage.t
==============================================================================
--- (empty file)
+++ Test-Dependencies/trunk/t/pod-coverage.t Fri Jun 23 17:47:33 2006
@@ -0,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
+all_pod_coverage_ok();
Added: Test-Dependencies/trunk/t/pod.t
==============================================================================
--- (empty file)
+++ Test-Dependencies/trunk/t/pod.t Fri Jun 23 17:47:33 2006
@@ -0,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod 1.14";
+plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
+all_pod_files_ok();
More information about the Rt-commit
mailing list