| 1 | package Test::Run::Builder; |
| 2 | |
| 3 | use strict; |
| 4 | use warnings; |
| 5 | |
| 6 | use Module::Build; |
| 7 | |
| 8 | use vars qw(@ISA); |
| 9 | |
| 10 | @ISA = (qw(Module::Build)); |
| 11 | |
| 12 | sub ACTION_runtest |
| 13 | { |
| 14 | my ($self) = @_; |
| 15 | my $p = $self->{properties}; |
| 16 | |
| 17 | $self->depends_on('code'); |
| 18 | |
| 19 | local @INC = @INC; |
| 20 | |
| 21 | # Make sure we test the module in blib/ |
| 22 | unshift @INC, (File::Spec->catdir($p->{base_dir}, $self->blib, 'lib'), |
| 23 | File::Spec->catdir($p->{base_dir}, $self->blib, 'arch')); |
| 24 | |
| 25 | $self->do_test_run_tests; |
| 26 | } |
| 27 | |
| 28 | sub ACTION_distruntest { |
| 29 | my ($self) = @_; |
| 30 | |
| 31 | $self->depends_on('distdir'); |
| 32 | |
| 33 | my $start_dir = $self->cwd; |
| 34 | my $dist_dir = $self->dist_dir; |
| 35 | chdir $dist_dir or die "Cannot chdir to $dist_dir: $!"; |
| 36 | # XXX could be different names for scripts |
| 37 | |
| 38 | $self->run_perl_script('Build.PL') # XXX Should this be run w/ --nouse-rcfile |
| 39 | or die "Error executing 'Build.PL' in dist directory: $!"; |
| 40 | $self->run_perl_script('Build') |
| 41 | or die "Error executing 'Build' in dist directory: $!"; |
| 42 | $self->run_perl_script('Build', [], ['runtest']) |
| 43 | or die "Error executing 'Build test' in dist directory"; |
| 44 | chdir $start_dir; |
| 45 | } |
| 46 | |
| 47 | sub do_test_run_tests |
| 48 | { |
| 49 | my $self = shift; |
| 50 | |
| 51 | require Test::Run::CmdLine::Iface; |
| 52 | |
| 53 | my $test_run = |
| 54 | Test::Run::CmdLine::Iface->new( |
| 55 | { |
| 56 | 'test_files' => [glob("t/*.t")], |
| 57 | } |
| 58 | # 'backend_params' => $self->_get_backend_params(), |
| 59 | ); |
| 60 | |
| 61 | return $test_run->run(); |
| 62 | } |
| 63 | |
| 64 | sub ACTION_tags |
| 65 | { |
| 66 | my $self = shift; |
| 67 | return |
| 68 | $self->do_system( |
| 69 | "ctags", |
| 70 | qw(-f tags --recurse --totals |
| 71 | --exclude=blib/** --exclude=t/lib/** |
| 72 | --exclude=**/.svn/** --exclude='*~'), |
| 73 | "--exclude=".$self->dist_name()."-*/**", |
| 74 | qw(--languages=Perl --langmap=Perl:+.t) |
| 75 | ); |
| 76 | } |
| 77 | |
| 78 | 1; |
| 79 |