From: gfx Date: Mon, 8 Mar 2010 06:57:37 +0000 (+0900) Subject: Add user module testing using Test::DependentModules X-Git-Tag: 0.50_08~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2462603aa36378017c6fe18eb41cd17d2c24e0d9;p=gitmo%2FMouse.git Add user module testing using Test::DependentModules --- diff --git a/.gitignore b/.gitignore index d3d8517..9cf041a 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,4 @@ ppport.h *.o *.obj *.c - +test-mydeps-*.log diff --git a/Makefile.PL b/Makefile.PL index daf48fa..00a6b68 100755 --- a/Makefile.PL +++ b/Makefile.PL @@ -79,7 +79,7 @@ author_tests 'xt'; repository 'git://git.moose.perl.org/Mouse.git'; -clean_files 'lib/Mouse/Tiny.pm $(O_FILES)'; +clean_files 'lib/Mouse/Tiny.pm $(O_FILES) test-mydeps-*.log'; if (author_context()) { diff --git a/author/requires.cpanm b/author/requires.cpanm index 18172ac..ac3d7c3 100644 --- a/author/requires.cpanm +++ b/author/requires.cpanm @@ -12,6 +12,13 @@ Test::More Test::Exception Test::LeakTrace Test::Output +Test::Requires + +# author's tests +Test::Pod +Test::Spelling +Test::Pod::Coverage +Test::DependentModules # required by recipes Regexp::Common diff --git a/xt/06_usermodules.t b/xt/06_usermodules.t new file mode 100644 index 0000000..a296c6e --- /dev/null +++ b/xt/06_usermodules.t @@ -0,0 +1,104 @@ +#!perl + +use if !$ENV{RELEASE_TESTING}, 'Test::More' => (skip_all => "for release testing"); + +use strict; +use warnings; +use Test::Requires qw(Test::DependentModules); +use Test::More; + +use Test::DependentModules qw(test_module); + +use Cwd qw(abs_path); + +note("Testing user modules which depend on Mouse"); + +$ENV{PERL_TEST_DM_LOG_DIR} = abs_path('.'); + +my @modules = qw( + MouseX::Types + MouseX::Types::Path::Class + + MouseX::AttributeHelpers + MouseX::Getopt + MouseX::ConfigFromFile + + Any::Moose + + HTTP::Engine + HTTP::Engine::Middleware + + HTML::Shakan + Net::Google::API +); + +test_module($_) for @modules; + +done_testing; + +__END__ +# TODO +BEGIN{ + $ENV{PERL5OPT} = '-Mblib' if exists $INC{'blib.pm'}; + #$ENV{PERL_CPANM_DEV} = 1; +} + +use strict; +use warnings; +use Test::Requires qw(App::cpanminus::script); +use Test::More; + +BEGIN{ + package Test::UserModules; + our @ISA = qw(App::cpanminus::script); + + sub init { + my($self) = @_; + $self->hook('test_user_modules', 'install_success' => \&_install_success); + $self->hook('test_user_modules', 'build_failure' => \&_build_failure); + $self->SUPER::init(); + } + + sub log { + my($self, @messages) = @_; + #Test::More->builder->note(@messages); + return; + } + + sub _install_success { + my($args) = @_; + Test::More->builder->ok(1, "install $args->{module}"); + } + + sub _build_failure { + my($args) = @_; + Test::More->builder->ok(0, "install $args->{module} ($args->{message})"); + } +} + +# See also http://cpants.perl.org/dist/used_by/Any-Moose + +my @user_modules = qw( + MouseX::Types + MouseX::Types::Path::Class + + MouseX::AttributeHelpers + MouseX::Getopt + MouseX::ConfigFromFile + + Any::Moose + + HTTP::Engine + HTTP::Engine::Middleware + + git://github.com/typester/ark-perl.git + HTML::Shakan + Net::Google::API +); + +my $t = Test::UserModules->new(); +$t->parse_options(@user_modules); +$t->doit(); + + +done_testing;