Alien-Build-MB

 view release on metacpan or  search on metacpan

t/alien_build_mb.t  view on Meta::CPAN

use Test2::V0 -no_srand => 1;
use Alien::Build::MB;
use File::Temp qw( tempdir );
use Path::Tiny qw( path );
use File::chdir;
use lib 'corpus/lib';
use Data::Dumper;
use Capture::Tiny qw( capture_merged );

delete $ENV{$_} for qw( ALIEN_BUILD_PRELOAD ALIEN_BUILD_POSTLOAD ALIEN_INSTALL_TYPE );
$ENV{ALIEN_BUILD_RC} = '-';

@INC = map { ref($_) ? $_ : path($_)->absolute->stringify } @INC;

sub alienfile
{
  my($str) = @_;
  my(undef, $filename, $line) = caller;
  $str = '# line '. $line . ' "' . $filename . qq("\n) . $str;
  path('alienfile')->spew($str);
  return;
}

subtest 'share' => sub {

  local $CWD = tempdir( CLEANUP => 1 );

  alienfile q{
    use alienfile;
    use Path::Tiny qw( path );

    plugin 'Test::Mock',
      probe    => 'share',
      download => {
        'foo-1.00.tar.gz' => 'testdata',
      },
      extract  => 1;

    configure { requires 'Foo' => '2.01' };
    probe sub { 'share' };
    share {
      requires 'Bar' => '0.01';

      # TODO: remove this when newer version of AB is required
      # workaround so this works in old and new
      # versions of AB
      after download => sub {
        my($build) = @_;
        my $tarball = Path::Tiny->new('foo-1.00.tar.gz')->absolute->stringify;
        $build->install_prop->{download_detail}->{$tarball}->{digest} ||= [ FAKE => 'deadbeaf' ];
        $build->install_prop->{download_detail}->{$tarball}->{protocol} ||= 'file';
      };

      # TODO: remove this when newer version of AB is required
      meta->register_hook(check_digest => sub { 1 });

      build sub {
        my($build) = @_;
        $build->install_prop->{did_the_install} = 1;
      };
    };
    sys   {
      requires 'Baz' => '0.02'
    };
  };



( run in 1.340 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )