Alien-Selenium
view release on metacpan or search on metacpan
inc/My/Module/Build.pm view on Meta::CPAN
=for My::Tests::Below "META.yml excerpt" end
(indentation is meaningful - "no_index:" must start at the very first
column and the indenting quantum is exactly 2 spaces, B<no tabs
allowed>)
If you prefer the META.yml file to be built automatically, do a
=for My::Tests::Below "distmeta" begin
./Build manifest
./Build distmeta
=for My::Tests::Below "distmeta" end
and the aforementioned no_index exclusions will be set up
automatically (but B<please double-check nevertheless>).
=back
=head2 Coding Style and Practices supported by this module
No, I don't want to go into silly regulations regarding whether I
should start a new line before the opening bracket in a sub
declaration. This would be coding syntax, or coding grammar. The stuff
here is about style, and only the subset thereof that is somehow under
control of the CPAN build process.
=head3 Unit tests
A large fraction of the unit tests are written as perlmodlib-style
__END__ documents attached directly to the module to test. See
L<My::Tests::Below> for details. My::Module::Build removes the test
footer at build time so as not to waste any resources on the install
target platform.
=head3 Extended C<test> action
The C<./Build test> action allows one to specify a list of individual
test scripts to run, in a less cumbersome fashion than straight
L<Module::Build>:
./Build test t/sometest.t lib/Foo/Bar.pm
For the developper's comfort, if only one test is specified in this
way, I<ACTION_test> assumes that I<verbose> mode is wanted (see
L<Module::Build/test>). This DWIM can be reversed on the command line:
./Build test verbose=0 t/sometest.t
In the case of running a single test, I<ACTION_test> also
automatically detects that we are running under Emacs' perldb mode and
runs the required test script under the Perl debugger. Running a
particular test under Emacs perldb is therefore as simple as typing:
M-x perldb <RET> /path/to/CPAN/module/Build test MyModule.pm
If a relative path is passed (as shown), it is interpreted relative to
the current directory set by Emacs (which, except under very bizarre
conditions, will be the directory of the file currently being
edited). The verbose switch above applies here by default,
conveniently causing the test script to run in verbose mode in the
debugger.
Like the original L<Module::Build/test>, C<./Build test> accepts
supplemental key=value command line switches, as exemplified above
with C<verbose>. Additional switches are provided by
I<My::Module::Build>:
=over
=item I<< use_blib=0 >>
Load modules from the B<source> directory (e.g. C<lib>) instead of the
build directories (e.g. C<blib/lib> and C<blib/arch>). I use this to
debug L<Inline::C> code in a tight tweak-run-tweak-run loop, a
situation in which the MD5-on-C-code feature of L<Inline> saves a lot
of rebuilds.
=item I<full_debugging=1>
Sets the FULL_DEBUGGING environment variable to 1 while running
C<./Build test>, in addition to any environment customization already
performed by L</customize_env>. Packages of mine that use L<Inline>
enable extra debugging when this environment variable is set.
=back
=head3 Dependent Option Graph
This feature wraps around L<Module::Build/prompt>,
L<Module::Build/get_options> and L<Module::Build/notes> to streamline
the programming of optional features into a ./Build.PL script. Here is
a short synopsis for this feature:
=for My::Tests::Below "option-graph" begin
my $class = My::Module::Build->subclass(code => <<'CODE');
sub install_everything: Config_Option {
question => "Install everything",
default => 1;
}
sub install_module_foo: Config_Option(type="boolean") {
my $build = shift;
return (default => 1) # Don't even bother asking the question
if $build->option_value("install_everything");
question => "Install module foo",
default => 0;
}
CODE
my $builder = $class->new(...) # See SYNOPSIS
=for My::Tests::Below "option-graph" end
Options can then be fed from the command line (e.g. C<< ./Build.PL
--gender=f >>) or by answering the questions interactively on the
terminal. I<My::Module::Build> will ask the questions at L</new>
inc/My/Module/Build.pm view on Meta::CPAN
$self->SUPER::ACTION_build(@_);
}
=item I<ACTION_dist>
Overloaded so that typing C<./Build dist> does The Right Thing and
regenerates everything that is needed in order to create the
distribution tarball. This includes the C<Makefile.PL> if so requested
(see L<Module::Build::Compat/create_makefile_pl>) and the C<MANIFEST>
file (see L<Module::Build/manifest>). On the other hand, the
C<META.yml> file is not regenerated automatically, so that the author
has the option of maintaining it by hand.
=cut
sub ACTION_dist {
my $self = shift;
$self->do_create_makefile_pl if $self->create_makefile_pl;
$self->do_create_readme if $self->create_readme;
$self->depends_on("manifest");
$self->SUPER::ACTION_dist(@_);
}
=item I<ACTION_buildXS>
Does nothing. Intended for overloading by packages that have XS code,
which e.g. may want to call L</process_Inline_C_file> there.
=cut
sub ACTION_buildXS { }
=item I<ACTION_test>
Overloaded to add t/lib and t/inc to the test scripts' @INC (we
sometimes put helper test classes in there), and also to implement the
features described in L</Extended C<test> action>. See also
L</_massage_ARGV> for more bits of the Emacs debugger support code.
=cut
sub ACTION_test {
my $self = shift;
# Tweak @INC (done this way, works regardless of whether we'll be
# doing the harnessing ourselves or not)
local @INC = (@INC, catdir($self->base_dir, "t", "lib"),
catdir($self->base_dir, "t", "inc"));
# use_blib feature, part 1:
$self->depends_on("buildXS") if $self->use_blib;
my @files_to_test = map {
our $initial_cwd; # Set at BEGIN time, see L<_startperl>
File::Spec->rel2abs($_, $initial_cwd)
} (@{$self->{args}->{ARGV} || []});
if ($running_under_emacs_debugger && @files_to_test == 1) {
# We want to run this script under a slave_editor debugger, so
# as to implement the documented trick. The simplest way
# (although inelegant) is to bypass Module::Build and
# Test::Harness entirely, and run the child Perl
# ourselves. Most of the code below was therefore cobbled
# together from the real T::H version 2.40 and M::B 0.26
$self->depends_on('code'); # As in original ACTION_test
# Compute adequate @INC for sub-perl:
my @inc = do { my %inc_dupes; grep { !$inc_dupes{$_}++ } @INC };
if (is_win32) { s/[\\\/+]$// foreach @inc; }
# Add blib/lib and blib/arch like the original ACTION_test does:
if ($self->use_blib) {
unshift @inc, catdir($self->base_dir(), $self->blib, 'lib'),
catdir($self->base_dir(), $self->blib, 'arch');
} else {
unshift @inc, catdir($self->base_dir(), 'lib');
}
# Parse shebang line to set taintedness properly:
local *TEST;
open(TEST, $files_to_test[0]) or die
"Can't open $files_to_test[0]. $!\n";
my $shebang = <TEST>;
close(TEST) or print "Can't close $files_to_test[0]. $!\n";
my $taint = ( $shebang =~ /^#!.*\bperl.*\s-\w*([Tt]+)/ );
my ($perl) = ($^X =~ m/^(.*)$/); # Untainted
system($perl, "-d",
($taint ? ("-T") : ()),
(map { ("-I" => $_) } @inc),
$files_to_test[0], "-emacs");
return;
}
# Localize stuff in order to fool our superclass for fun & profit
local %ENV = $self->customize_env(%ENV);
local $self->{FORCE_find_test_files_result}; # See L</find_test_files>
$self->{FORCE_find_test_files_result} = \@files_to_test if
@files_to_test;
# DWIM for ->{verbose} (see POD)
local $self->{properties} = { %{$self->{properties}} };
if (@files_to_test == 1) {
$self->{properties}->{verbose} = 1 if
(! defined $self->{properties}->{verbose});
}
# use_blib feature, cont'd:
no warnings "once";
local *blib = sub {
my $self = shift;
return File::Spec->curdir if ! $self->use_blib;
return $self->SUPER::blib(@_);
};
$self->SUPER::ACTION_test(@_);
}
=item I<ACTION_distmeta>
( run in 1.356 second using v1.01-cache-2.11-cpan-13bb782fe5a )