Commits

Shlomi Fish  committed ef7e5f6

Conver to Test::Run::Builder

  • Participants
  • Parent commits 4ab95dd

Comments (0)

Files changed (3)

File module/Build.PL

 # This file is under the MIT X11 License:
 # http://www.opensource.org/licenses/mit-license.php
 
-use Module::Build;
+use strict;
+use warnings;
 
-my $build = Module::Build->new(
+use File::Spec;
+use lib File::Spec->catdir(File::Spec->curdir(), "inc");
+
+use Test::Run::Builder;
+
+my $builder = Test::Run::Builder->new(
     module_name => "SVN::Pusher",
     requires =>
     {
     script_files => ["bin/svn-pusher"],
 );
 
-$build->create_build_script;
+$builder->create_build_script;
 

File module/MANIFEST

-bin/svn-pusher
 Build.PL
 Changes
+MANIFEST
+META.json
+META.yml                                 Module meta-data (added by MakeMaker)
+Makefile.PL
+README
+TODO
+bin/svn-pusher
 examples/svn-pusher-test.sh
+inc/Test/Run/Builder.pm
+lib/SVN/Pusher.pm
 lib/SVN/Pusher/CmdLine.pm
-lib/SVN/Pusher.pm
-Makefile.PL
-MANIFEST
-META.yml                                 Module meta-data (added by MakeMaker)
-README
 t/00-load.t
-TODO
-META.json

File module/inc/Test/Run/Builder.pm

+package Test::Run::Builder;
+
+use strict;
+use warnings;
+
+use Module::Build;
+
+use vars qw(@ISA);
+
+@ISA = (qw(Module::Build));
+
+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();
+}
+
+1;
+