Add user module testing using Test::DependentModules
gfx [Mon, 8 Mar 2010 06:57:37 +0000 (15:57 +0900)]
.gitignore
Makefile.PL
author/requires.cpanm
xt/06_usermodules.t [new file with mode: 0644]

index d3d8517..9cf041a 100644 (file)
@@ -22,4 +22,4 @@ ppport.h
 *.o
 *.obj
 *.c
-
+test-mydeps-*.log
index daf48fa..00a6b68 100755 (executable)
@@ -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()) {
index 18172ac..ac3d7c3 100644 (file)
@@ -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 (file)
index 0000000..a296c6e
--- /dev/null
@@ -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;