Hi all! Today, after a long session of hacking on XML-Grammar-ProductsSyndication (more about that later), I experimented a bit with integrating Test::Run into a Module::Build build system. It turns out to be very easy, with just having to add ACTION_runtest and ACTION_distruntest with the appropriate logic. My complete Build.PL (for the Test-Run distribution) now looks like this:
<<<<<<< use strict; use warnings; use Module::Build; my $class = Module::Build->subclass( class => "Test::Run::Module::Build", code => <<'EOF', use strict; use warnings; sub ACTION_runtest { my ($self) = @_; my $p = $self->{properties}; $self->depends_on('code'); local @INC = @INC; # Make sure we test the module in blib/ unshift @INC, (File::Spec->catdir($p->{base_dir}, $self->blib, 'lib'), File::Spec->catdir($p->{base_dir}, $self->blib, 'arch')); $self->do_test_run_tests; } sub ACTION_distruntest { my ($self) = @_; $self->depends_on('distdir'); my $start_dir = $self->cwd; my $dist_dir = $self->dist_dir; chdir $dist_dir or die "Cannot chdir to $dist_dir: $!"; # XXX could be different names for scripts $self->run_perl_script('Build.PL') # XXX Should this be run w/ --nouse-rcfile or die "Error executing 'Build.PL' in dist directory: $!"; $self->run_perl_script('Build') or die "Error executing 'Build' in dist directory: $!"; $self->run_perl_script('Build', [], ['runtest']) or die "Error executing 'Build test' in dist directory"; chdir $start_dir; } sub do_test_run_tests { my $self = shift; require Test::Run::CmdLine::Iface; my $test_run = Test::Run::CmdLine::Iface->new( 'test_files' => [glob("t/*.t")], # 'backend_params' => $self->_get_backend_params(), ); return $test_run->run(); } EOF ); my $build = $class->new( module_name => "Test::Run", requires => { 'Class::Accessor' => 0, 'File::Spec' => 0.6, 'Test::Harness' => "2.53", 'Scalar::Util' => 0, 'TAPx::Parser' => "0.21", }, dist_version_from => "lib/Test/Run/Obj.pm", ); $build->create_build_script; >>>>>>> Now, the ->do_test_run_tests() method is much shorter than its Test::Harness equivalent. I had to copy and paste some code in the $self->ACTION_... methods. Perhaps the M::B hackers would like to abstract the common functionality somehow. In other news, Test::Run now makes use of TAPx::Parser to parse the TAP. It still collects the statistics on its own, because I couldn't remember whether TAPx::Parser does that or not, and it was too much work to do at one time. Regards, Shlomi Fish --------------------------------------------------------------------- Shlomi Fish [EMAIL PROTECTED] Homepage: http://www.shlomifish.org/ Chuck Norris wrote a complete Perl 6 implementation in a day but then destroyed all evidence with his bare hands, so no one will know his secrets.