Alien-Build

 view release on metacpan or  search on metacpan

t/alien_base_wrapper.t  view on Meta::CPAN

    sub cflags { '-I/foo/include -DBAR=1' }
    sub cflags_static { 'wrong' }
    sub libs   { '-L/foo/lib -lfoo'   }
    sub libs_static { 'wrong' }
  }

  Alien::Base::Wrapper->import('Foo2');

  is(
    exec_arrayref {
      local @ARGV = qw( one two three );
      Alien::Base::Wrapper::cc();
    },
    [shellwords($Config{cc}), qw( -I/foo/include -DBAR=1 one two three )],
    'cc',
  );

  is(
    exec_arrayref {
      local @ARGV = qw( one two three );
      Alien::Base::Wrapper::ld();
    },
    [shellwords($Config{ld}), qw( -L/foo/lib one two three -lfoo )],
    'ld',
  );

};

subtest 'share' => sub {

t/alien_base_wrapper.t  view on Meta::CPAN

    sub cflags { '-I/foo/include -DBAR=1' }
    sub cflags_static { '-I/foo/include -DBAR=2' }
    sub libs   { '-L/foo/lib -lfoo'   }
    sub libs_static { '-L/foo/lib -lfoo -lbaz' }
  }

  Alien::Base::Wrapper->import('Alien::Foo3');

  is(
    exec_arrayref {
      local @ARGV = qw( one two three );
      Alien::Base::Wrapper::cc();
    },
    [shellwords($Config{cc}), qw( -I/foo/include -DBAR=2 one two three )],
    'cc',
  );

  is(
    exec_arrayref {
      local @ARGV = qw( one two three );
      Alien::Base::Wrapper::ld();
    },
    [shellwords($Config{ld}), qw( -L/foo/lib one two three -lfoo -lbaz )],
    'ld',
  );

};

subtest 'share sans static' => sub {

t/alien_base_wrapper.t  view on Meta::CPAN


    sub install_type { 'share' }
    sub cflags { '-I/foo/include -DBAR=1' }
    sub libs   { '-L/foo/lib -lfoo'   }
  }

  Alien::Base::Wrapper->import('Alien::Foo4');

  is(
    exec_arrayref {
      local @ARGV = qw( one two three );
      Alien::Base::Wrapper::cc();
    },
    [shellwords($Config{cc}), qw( -I/foo/include -DBAR=1 one two three )],
    'cc',
  );

  is(
    exec_arrayref {
      local @ARGV = qw( one two three );
      Alien::Base::Wrapper::ld();
    },
    [shellwords($Config{ld}), qw( -L/foo/lib one two three -lfoo )],
    'ld',
  );

};

subtest 'combine aliens' => sub {

t/alien_base_wrapper.t  view on Meta::CPAN


    sub install_type { 'share' }
    sub cflags { '-I/bar/include -DBAR5=1' }
    sub libs   { '-L/foo/lib --ld-bar -lbar' }
  }

  Alien::Base::Wrapper->import('Alien::Foo5', 'Alien::Bar5=1.23');

  is(
    exec_arrayref {
      local @ARGV = qw( one two three );
      Alien::Base::Wrapper::cc();
    },
    [shellwords($Config{cc}), qw( -I/foo/include -I/bar/include -DFOO5=1 -DBAR5=1 one two three ) ],
    'cc',
  );

  is(
    exec_arrayref {
      local @ARGV = qw( one two three );
      Alien::Base::Wrapper::ld();
    },
    [shellwords($Config{ld}), qw( -L/foo/lib -L/foo/lib --ld-foo --ld-bar one two three -lfoo -lbar )],
    'ld',
  );

  subtest 'mm_args' => sub {

    my %mm_args = Alien::Base::Wrapper->mm_args;

t/alien_build_mm.t  view on Meta::CPAN

      $_->mkpath for @dirs;

      do {
        my $abmm = Alien::Build::MM->new;
        $abmm->mm_args(
          DISTNAME => 'Alien-Foo',
        );
      };

      note capture_merged {
        local @ARGV = ($type, @dirs);
        prefix();
      };

      ok( -f '_alien/mm/prefix', 'touched prefix' );

      my $build = Alien::Build->resume('alienfile', '_alien');
      my $prefix = path($build->runtime_prop->{prefix})->relative($CWD)->stringify;
      is $prefix, "foo/$type/auto/share/dist/Alien-Foo", "correct path";
    };
  }

t/alien_build_mm.t  view on Meta::CPAN

    };
  };

  my $abmm = Alien::Build::MM->new;

  $abmm->mm_args(
    DISTNAME => 'Alien-Foo',
  );

  note capture_merged {
    local @ARGV = ('perl', map { ($_,$_,$_) } tempdir( CLEANUP => 1 ));
    prefix();
  };

  my($out, $error) = capture_merged {
    local @ARGV = ();
    eval { download() };
    $@;
  };
  note $out if $out ne '';

  is($error, '', 'no error in download') || do {
    diag _dump(get_build()->install_prop);
    return;
  };
  note _dump(get_build()->install_prop);

  ok( -f '_alien/mm/download', 'touched download' );
  is $main::call_download, 1, 'download';

  ($out, $error) = capture_merged {
    local @ARGV = ();
    eval { build() };
    $@;
  };
  note $out if $out ne '';

  is($error, '', 'no error in build') || do {
    diag _dump(get_build()->install_prop);
    return;
  };
  note _dump(get_build()->install_prop);



( run in 0.529 second using v1.01-cache-2.11-cpan-49f99fa48dc )