The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Test::Alien::Build - Tools for testing Alien::Build + alienfile

VERSION

version 0.98_01

SYNOPSIS

 use Test2::V0;
 use Test::Alien::Build;
 
 # returns an instance of Alien::Build.
 my $build = alienfile_ok q{
   use alienfile;
   
   plugin 'My::Plugin' => (
     foo => 1,
     bar => 'string',
     ...
   );
 };
 
 alien_build_ok 'builds okay.';
 
 done_testing;

DESCRIPTION

This module provides some tools for testing Alien::Build and alienfile. Outside of Alien::Build core development, It is probably most useful for Alien::Build::Plugin developers.

This module also unsets a number of Alien::Build specific environment variables, in order to make tests reproducible even when overrides are set in different environments. So if you want to test those variables in various states you should explicitly set them in your test script. These variables are unset if they defined: ALIEN_BUILD_PRELOAD ALIEN_BUILD_POSTLOAD ALIEN_INSTALL_TYPE.

FUNCTIONS

alienfile

 my $build = alienfile;
 my $build = alienfile q{ use alienfile ... };
 my $build = alienfile filename => 'alienfile';

Create a Alien::Build instance from the given alienfile. The first two forms are abbreviations.

 my $build = alienfile;
 # is the same as
 my $build = alienfile filename => 'alienfile';

and

 my $build = alienfile q{ use alienfile ... };
 # is the same as
 my $build = alienfile source => q{ use alienfile ... };

Except for the second abbreviated form sets the line number before feeding the source into Alien::Build so that you will get diagnostics with the correct line numbers.

source

The source for the alienfile as a string. You must specify one of source or filename.

filename

The filename for the alienfile. You must specify one of source or filename.

root

The build root.

stage

The staging area for the build.

prefix

The install prefix for the build.

alienfile_ok

 my $build = alienfile_ok;
 my $build = alienfile_ok q{ use alienfile ... };
 my $build = alienfile_ok filename => 'alienfile';

Same as alienfile above, except that it runs as a test, and will not throw an exception on failure (it will return undef instead).

alien_install_type_is

 alien_install_type_is $type;
 alien_install_type_is $type, $name;

Simple test to see if the install type is what you expect. $type should be one of system or share.

alien_download_ok

 my $file = alien_download_ok;
 my $file = alien_download_ok $name;

Makes a download attempt and test that a file or directory results. Returns the file or directory if successful. Returns undef otherwise.

alien_extract_ok

 my $dir = alien_extract_ok;
 my $dir = alien_extract_ok $archive;
 my $dir = alien_extract_ok $archive, $name;
 my $dir = alien_extract_ok undef, $name;

Makes an extraction attempt and test that a directory results. Returns the directory if successful. Returns undef otherwise.

alien_build_ok

 my $alien = alien_build_ok;
 my $alien = alien_build_ok $name;
 my $alien = alien_build_ok { class => $class };
 my $alien = alien_build_ok { class => $class }, $name;

Runs the download and build stages. Passes if the build succeeds. Returns an instance of Alien::Base which can be passed into alien_ok from Test::Alien. Returns undef if the test fails.

Options

class

The base class to use for your alien. This is Alien::Base by default. Should be a subclass of Alien::Base, or at least adhere to its API.

alien_build_clean

 alien_build_clean;

Removes all files with the current build, except for the runtime prefix. This helps test that the final install won't depend on the build files.

SEE ALSO

Alien
alienfile
Alien::Build
Test::Alien

AUTHOR

Author: Graham Ollis <plicease@cpan.org>

Contributors:

Diab Jerius (DJERIUS)

Roy Storey

Ilya Pavlov

David Mertens (run4flat)

Mark Nunberg (mordy, mnunberg)

Christian Walde (Mithaldu)

Brian Wightman (MidLifeXis)

Zaki Mughal (zmughal)

mohawk2

Vikas N Kumar (vikasnkumar)

Flavio Poletti (polettix)

Salvador Fandiño (salva)

Gianni Ceccarelli (dakkar)

Pavel Shaydo (zwon, trinitum)

Kang-min Liu (劉康民, gugod)

Nicholas Shipp (nshp)

Juan Julián Merelo Guervós (JJ)

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Graham Ollis.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.