| 1 |
package Module::Build::with::XSTests; |
| 2 |
|
| 3 |
use v5.14; |
| 4 |
use warnings; |
| 5 |
|
| 6 |
use base qw( Module::Build ); |
| 7 |
|
| 8 |
# Stolen and edited from Module::Build::Base::_infer_xs_spec |
| 9 |
sub _infer_xs_spec |
| 10 |
{ |
| 11 |
my $self = shift; |
| 12 |
my ( $file ) = @_; |
| 13 |
|
| 14 |
my $spec = $self->SUPER::_infer_xs_spec( $file ); |
| 15 |
|
| 16 |
if( $file =~ m{^t/} ) { |
| 17 |
$spec->{$_} = File::Spec->catdir( "t", $spec->{$_} ) |
| 18 |
for qw( archdir bs_file lib_file ); |
| 19 |
} |
| 20 |
|
| 21 |
return $spec; |
| 22 |
} |
| 23 |
|
| 24 |
# Various bits stolen from Module::Build::Base:: |
| 25 |
# process_xs_files() |
| 26 |
sub ACTION_testlib |
| 27 |
{ |
| 28 |
my $self = shift; |
| 29 |
|
| 30 |
my $testxsfiles = $self->_find_file_by_type('xs', 't'); |
| 31 |
|
| 32 |
foreach my $from ( sort keys %$testxsfiles ) { |
| 33 |
my $to = $testxsfiles->{$from}; |
| 34 |
|
| 35 |
if( $to ne $from ) { |
| 36 |
$self->add_to_cleanup( $to ); |
| 37 |
$self->copy_if_modified( from => $from, to => $to ); |
| 38 |
} |
| 39 |
|
| 40 |
$self->process_xs( $to ); |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
sub ACTION_test |
| 45 |
{ |
| 46 |
my $self = shift; |
| 47 |
$self->depends_on( "testlib" ); |
| 48 |
|
| 49 |
$self->SUPER::ACTION_test( @_ ); |
| 50 |
} |
| 51 |
|
| 52 |
0x55AA; |