Alien-Selenium
view release on metacpan or search on metacpan
inc/My/Module/Build.pm view on Meta::CPAN
of the directories in which to search for test files.
I<find_test_files_predicate> gets passed the name of each file found
in these directories in the same way as a L<File::Find> C<wanted> sub
would (that is, using $_ and B<not> the argument list); it should
return a true value iff this file is a test file.
=cut
sub find_test_files_predicate {
my ($self) = @_;
return 1 if m/My.Tests.Below\.pm$/;
return if m/\b[_.]svn\b/; # Subversion metadata
return 1 if m/\.t$/;
my $module = catfile($self->base_dir, $_);
local *MODULE;
unless (open(MODULE, "<", $module)) {
warn "Cannot open $module: $!";
return;
}
return 1 if grep {
m/^require\s+My::Tests::Below\s+unless\s+caller/
} (<MODULE>);
return;
}
sub find_test_files_in_directories {
grep { -d } ("lib", catdir("t", "lib"), "examples");
}
=back
=begin internals
=head1 INTERNAL DOCUMENTATION
This section describes how My::Module::Build works internally. It
should be useful only to people who intend to modify it.
=over
=item I<My::Module::Build::do_create_makefile_pl>
=item I<My::Module::Build::HowAreYouGentlemen::fake_makefile>
Overloaded respectively from L<Module::Build::Base> and
L<Module::Build::Compat> so that typing
=for My::Tests::Below "great justice" begin
perl Makefile.PL
make your time
=for My::Tests::Below "great justice" end
produces a helpful message in packages that have a Makefile.PL (see
L<Module::Build/create_makefile_pl> for how to do that). You won't get
signal if you use a "traditional" style Makefile.PL (but on the other
hand the rest of I<My::Module::Build> will not work either, so don't
do that).
This easter egg was a feature of an old GNU-make based build framework
that I created in a former life. So there.
=cut
sub do_create_makefile_pl {
my ($self, %args) = @_;
warn("Cannot take off any Zig, sorry"),
return $self->SUPER::do_create_makefile_pl(%args) if ($args{fh});
$args{file} ||= 'Makefile.PL';
my $retval = $self->SUPER::do_create_makefile_pl(%args);
my $MakefilePL = read_file($args{file});
$MakefilePL = <<'PREAMBLE' . $MakefilePL;
use FindBin qw($Bin);
use lib "$Bin/inc";
PREAMBLE
$MakefilePL =~ s|Module::Build::Compat->write_makefile|My::Module::Build::HowAreYouGentlemen->write_makefile|;
write_file($args{file}, $MakefilePL);
return $retval;
}
{
package My::Module::Build::HowAreYouGentlemen;
our @ISA=qw(Module::Build::Compat); # Do not explicitly load it because
# Makefile.PL will set up us the Module::Build::Compat itself (and
# also we want to take off every zig of bloat when
# My::Module::Build is loaded from elsewhere). Moreover, "use
# base" is not yet belong to us at this time.
sub fake_makefile {
my $self = shift;
return $self->SUPER::fake_makefile(@_). <<'MAIN_SCREEN_TURN_ON';
# In 2101 AD war was beginning...
your:
@echo
@echo -n " All your codebase"
time:
@echo " are belong to us !"
@echo
MAIN_SCREEN_TURN_ON
}
}
=head2 Overloaded Internal Methods
Yeah I know, that's a pretty stupid thing to do, but that's the best I
could find to get Module::Build to do my bidding.
=over
=item I<subclass(%named_arguments)>
Overloaded from L<Module::Build::Base> to set @ISA at compile time and
to the correct value in the sub-classes generated from the C<< code >>
named argument. We need @ISA to be set up at compile-time so that the
method attributes work correctly; also we work around a bug present in
Module::Build 0.26 and already fixed in the development branch whence,
ironically, ->subclass does not work from a subclass.
( run in 1.288 second using v1.01-cache-2.11-cpan-df04353d9ac )