Skip to content

Commit

Permalink
add support for PERL_MB_OPT
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.perl.org/modules/Module-Build/trunk@13390 50811bd7-b8ce-0310-adc1-d9db26280581
  • Loading branch information
xdg committed Oct 16, 2009
1 parent 097f273 commit 1c6c487
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ Revision history for Perl extension Module::Build.
argument for modification. The method now takes no arguments and just
returns a hash reference of metadata. [David Golden]

Enhancements
- Command line options may be set via the PERL_MB_OPT environment
variable (similar to PERL_MM_OPT in ExtUtils::MakeMaker)

Bug fixes:
- Updated PPM generation to PPM v4 (RT#49600) [Olivier Mengue]
- When c_source is specified, the directory scan will include additional,
Expand Down
20 changes: 19 additions & 1 deletion lib/Module/Build.pm
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,6 @@ executed build actions.
=back
=head2 Default Options File (F<.modulebuildrc>)
[version 0.28]
Expand Down Expand Up @@ -797,6 +796,25 @@ If you wish to locate your resource file in a different location, you
can set the environment variable C<MODULEBUILDRC> to the complete
absolute path of the file containing your options.
=head2 Environment variables
=over
=item MODULEBUILDRC
[version 0.28]
Specifies an alternate location for a default options file as described above.
=item PERL_MB_OPT
[version 0.36]
Command line options that are applied to Build.PL or any Build action. The
string is split as the shell would (e.g. whitespace) and the result is
prepended to any actual command-line arguments.
=back
=head1 INSTALL PATHS
Expand Down
5 changes: 4 additions & 1 deletion lib/Module/Build/Base.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2094,7 +2094,10 @@ sub merge_args {

sub cull_args {
my $self = shift;
my ($args, $action) = $self->read_args(@_);
my @arg_list = @_;
unshift @arg_list, $self->split_like_shell($ENV{PERL_MB_OPT})
if $ENV{PERL_MB_OPT};
my ($args, $action) = $self->read_args(@arg_list);
$self->merge_args($action, %$args);
$self->merge_modulebuildrc( $action, %$args );
}
Expand Down
1 change: 1 addition & 0 deletions t/lib/MBTest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ BEGIN {
my @delete_env_keys = qw(
DEVEL_COVER_OPTIONS
MODULEBUILDRC
PERL_MB_OPT
HARNESS_TIMER
HARNESS_OPTIONS
HARNESS_VERBOSE
Expand Down
62 changes: 62 additions & 0 deletions t/perl_mb_opt.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# sample.t -- a sample test file for Module::Build

use strict;
use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
use MBTest;
use DistGen;

plan tests => 8; # or 'no_plan'

# Ensure any Module::Build modules are loaded from correct directory
blib_load('Module::Build');

# create dist object in a temp directory
# enter the directory and generate the skeleton files
my $dist = DistGen->new->chdir_in->regen;

$dist->add_file('t/subtest/foo.t', <<'END_T');
use strict;
use Test::More tests => 1;
ok(1, "this is a recursive test");
END_T

$dist->regen;

# get a Module::Build object and test with it
my $mb = $dist->new_from_context(); # quiet by default
isa_ok( $mb, "Module::Build" );
is( $mb->dist_name, "Simple", "dist_name is 'Simple'" );
ok( ! $mb->recursive_test_files, "set for no recursive testing" );

# set for recursive testing using PERL_MB_OPT
{
local $ENV{PERL_MB_OPT} = "--verbose --recursive_test_files 1";

my $out = stdout_stderr_of( sub {
$dist->run_build('test');
});
like( $out, qr/this is a recursive test/,
"recursive tests run via PERL_MB_OPT"
);
}

# set Build.PL opts using PERL_MB_OPT
{
local $ENV{PERL_MB_OPT} = "--verbose --recursive_test_files 1";
my $mb = $dist->new_from_context(); # quiet by default
ok( $mb->recursive_test_files, "PERL_MB_OPT set recusive tests in Build.PL" );
ok( $mb->verbose, "PERL_MB_OPT set verbose in Build.PL" );
}

# verify settings preserved during 'Build test'
{
ok( !$ENV{PERL_MB_OPT}, "PERL_MB_OPT cleared" );
my $out = stdout_stderr_of( sub {
$dist->run_build('test');
});
like( $out, qr/this is a recursive test/,
"recursive tests run via Build object"
);
}

# vim:ts=2:sw=2:et:sta:sts=2

0 comments on commit 1c6c487

Please sign in to comment.