Alien-Build-MB

 view release on metacpan or  search on metacpan

t/alien_build_mb.t  view on Meta::CPAN


  ok(-d "_alien", "_alien directory created");
  ok(-f "_alien/state.json", "state file created");

  is( $abmb->dynamic_config, T(), "is dynamic" );

  subtest 'configure' => sub {

    my $build = $abmb->alien_build(1);

    isa_ok $build, 'Alien::Build';

    is($build->runtime_prop->{install_type}, 'share', 'type = share');
    is($build->runtime_prop->{prefix}, T(), "runtime prefix");
    is($build->runtime_prop->{perl_module_version}, '1.00', 'perl_module_version is set');
    note $build->runtime_prop->{prefix};

    my $stage = path($build->install_prop->{stage})->relative($CWD);
    is($stage->stringify, "blib/lib/auto/share/dist/Alien-Foo", "stage dir");

    is(
      $abmb->configure_requires,
      hash {
        field 'Module::Build' => T();
        field 'Alien::Build::MB' => T();
        field 'Foo' => '2.01';
        etc;
      },
      'configure requires are set'
    );

    is(
      $abmb->build_requires,
      hash {
        field 'Module::Build' => T();
        field 'Alien::Build::MB' => T();
        field 'Bar' => '0.01';
        etc;
      },
      'build requires are set',
    );
  };

  subtest 'download' => sub {

    note scalar capture_merged { $abmb->ACTION_alien_download };

    is($INC{'Foo.pm'}, T(), 'Foo.pm is loaded' );
    is($INC{'Bar.pm'}, T(), 'Bar.pm is loaded' );
    is($INC{'Baz.pm'}, F(), 'Baz.pm is not loaded' );

    my $build = $abmb->alien_build(1);

    my $download = path($build->install_prop->{download});

    is($download->slurp, 'testdata', 'fake tar faile has content');

  };

  subtest 'build' => sub {
    my($out, $error) = capture_merged {
      eval { $abmb->ACTION_alien_build };
      $@;
    };

    is($error, '', 'build did not error ') || do {
      diag Dumper($abmb->alien_build);
      return;
    };

    my $build = $abmb->alien_build(1);
    is $build->install_prop->{did_the_install}, T();
    ok -f "blib/lib/Alien/Foo/Install/Files.pm", "created Alien::Foo::Install::Files";

    local $INC{'Alien/Foo.pm'} = __FILE__;

    eval { require './blib/lib/Alien/Foo/Install/Files.pm' };
    is "$@", "", "Alien::Foo::Install::Files compiles okay";

    my $mock = mock 'Alien::Foo' => (
      add => [
        Inline => sub {
          { x => 'y', args => [@_] };
        },
      ],
    );

    is(
      Alien::Foo::Install::Files->Inline(1,2,3,4,5,6),
      hash {
        field x => 'y';
        field args => [ 'Alien::Foo', 1,2,3,4,5,6 ];
        end;
      },
      'called Alien::Foo->Inline',
    );

  };

};

subtest 'system' => sub {

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

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

    configure { requires 'Foo' => '2.01' };
    probe sub { 'system' };
    sys   {
      requires 'Baz' => '0.02';
      gather sub {
        my($build) = @_;
        $build->install_prop->{did_the_gather} = 1;
      };
    };
  };

  my $abmb = Alien::Build::MB->new(
    module_name  => 'Alien::Foo',
    dist_version => '1.00',
  );

  subtest 'configure' => sub {



( run in 1.354 second using v1.01-cache-2.11-cpan-adec679a428 )