Alien-Build

 view release on metacpan or  search on metacpan

t/alien_build_plugin_pkgconfig_commandline.t  view on Meta::CPAN

      my($out, $type) = capture_merged { $build->probe };
      note $out;

      is( $type, 'system' );

    };

    subtest 'max version (more)' => sub {

      my($build, $meta, $plugin) = build(
        pkg_name => 'foo',
        max_version => '1.2.4',
      );

      my($out, $type) = capture_merged { $build->probe };
      note $out;

      is( $type, 'system' );

    };

    subtest 'max version (lots more)' => sub {

      my($build, $meta, $plugin) = build(
        pkg_name => 'foo',
        max_version => '3.3.3',
      );

      my($out, $type) = capture_merged { $build->probe };
      note $out;

      is( $type, 'system' );

    };

  };
};

subtest 'system available, okay' => sub {

  my($build, $meta, $plugin) = build(
    pkg_name => 'foo',
    minimum_version => '1.2.3',
  );

  my($out, $type) = capture_merged { $build->probe };
  note $out;

  is( $type, 'system' );

  return unless $type eq 'system';

  note capture_merged { $build->build; () };

  if($^O eq 'MSWin32')
  {
    if($build->runtime_prop->{cflags} =~ m/-I(.*)\/include\/foo/
    && $1 ne '/test')
    {
      $prefix = $1;
      ok(-f "$prefix/lib/pkgconfig/foo.pc", "relocation looks okay");
      note "prefix = $prefix\n";
      note "-f $prefix/lib/pkgconfig/foo.pc";
    }
  }

  is(
    $build->runtime_prop,
    hash {
      #field cflags      => match qr/-fPIC/;
      field cflags      => match qr/-I\Q$prefix\E\/include\/foo/;
      field libs        => "-L$prefix/lib -lfoo ";
      field libs_static => "-L$prefix/lib -lfoo -lbar -lbaz ";
      field version     => '1.2.3';
      field alt         => U();
      etc;
    },
  );

  # not supported by pkg-config.
  # may be supported by recent pkgconfig
  # so we do not test it.
  note "cflags_static = @{[ $build->runtime_prop->{cflags_static} ]}";

};

subtest 'hook prop' => sub {

  my($build, $meta, $plugin) = build(
    pkg_name => 'foo',
  );

  my $hook_prop_version;

  $meta->around_hook(
    probe => sub {
      my($orig, $build) = @_;
      my $install_type = $build->$orig;
      $hook_prop_version = $build->hook_prop->{version};
      $install_type;
    },
  );

  my($out, $type) = capture_merged { $build->probe };
  note $out;

  is $type, 'system';
  is $hook_prop_version, '1.2.3';

};

subtest 'system multiple' => sub {

  subtest 'all found in system' => sub {

    my $build = alienfile_ok q{

      use alienfile;
      plugin 'PkgConfig::CommandLine' => (
        pkg_name => [ 'xor', 'xor-chillout' ],
      );



( run in 0.339 second using v1.01-cache-2.11-cpan-ed4147ee29a )