From: Steve Hay Date: Tue, 30 Sep 2008 11:25:01 +0000 (+0000) Subject: Upgrade to Module-Build-0.30 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=738349a8c2d75ad4e5c0317bb9f69744bfeef05d;p=p5sagit%2Fp5-mst-13.2.git Upgrade to Module-Build-0.30 Local changes 32357 in ppm.t and 32351 in test_type.t and xs.t remain, but not the tilde.t part of 32351, which looks like it might be superseded by changes in 0.30 p4raw-id: //depot/perl@34446 --- diff --git a/MANIFEST b/MANIFEST index aae1a23..01f80e0 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2396,9 +2396,12 @@ lib/Module/Build/t/parents.t Module::Build lib/Module/Build/t/pod_parser.t Module::Build lib/Module/Build/t/ppm.t Module::Build lib/Module/Build/t/runthrough.t Module::Build +lib/Module/Build/t/script_dist.t Module::Build +lib/Module/Build/t/test_file_exts.t Module::Build lib/Module/Build/t/test_types.t Module::Build lib/Module/Build/t/test_type.t Module::Build lib/Module/Build/t/tilde.t Module::Build +lib/Module/Build/t/use_tap_harness.t Module::Build lib/Module/Build/t/versions.t Module::Build lib/Module/Build/t/xs.t Module::Build lib/Module/Build/Version.pm Module::Build diff --git a/lib/Module/Build.pm b/lib/Module/Build.pm index 6d6cfe9..e435c8a 100644 --- a/lib/Module/Build.pm +++ b/lib/Module/Build.pm @@ -15,7 +15,7 @@ use Module::Build::Base; use vars qw($VERSION @ISA); @ISA = qw(Module::Build::Base); -$VERSION = '0.2808_02'; +$VERSION = '0.30'; $VERSION = eval $VERSION; # Okay, this is the brute-force method of finding out what kind of @@ -39,6 +39,7 @@ my %OSTYPES = qw( openbsd Unix netbsd Unix dec_osf Unix + nto Unix svr4 Unix svr5 Unix sco_sv Unix @@ -49,7 +50,9 @@ my %OSTYPES = qw( cygwin Unix os2 Unix interix Unix - + gnu Unix + gnukfreebsd Unix + dos Windows MSWin32 Windows @@ -557,10 +560,10 @@ F file (See L for details) [version 0.01] -This will use C to run any regression tests and report -their results. Tests can be defined in the standard places: a file -called C in the top-level directory, or several files ending -with C<.t> in a C directory. +This will use C or C to run any regression +tests and report their results. Tests can be defined in the standard +places: a file called C in the top-level directory, or several +files ending with C<.t> in a C directory. If you want tests to be 'verbose', i.e. show details of test execution rather than just summary information, pass the argument C. @@ -568,6 +571,14 @@ rather than just summary information, pass the argument C. If you want to run tests under the perl debugger, pass the argument C. +If you want to have Module::Build find test files with different file +name extensions, pass the C argument with an array +of extensions, such as C<[qw( .t .s .z )]>. + +If you want test to be run by C, rather than C, +pass the argument C as an array reference of arguments to +pass to the TAP::Harness constructor. + In addition, if a file called C exists in the top-level directory, this file will be executed as a Perl script and its output will be shown to the user. This is a good place to put speed tests or @@ -611,7 +622,7 @@ enumerate them in the test_types parameter. ... test_types => { special => '.st', - author => '.at', + author => ['.at', '.pt' ], }, ... diff --git a/lib/Module/Build/API.pod b/lib/Module/Build/API.pod index 2ad6dc5..6c5e24c 100644 --- a/lib/Module/Build/API.pod +++ b/lib/Module/Build/API.pod @@ -502,16 +502,16 @@ choose to provide this field, you should make sure that you keep it in sync with your written documentation if you ever change your licensing terms. +You may also use a license type of C if you don't wish to +specify your terms in the metadata. + It is a fatal error to use a license other than the ones mentioned above. This is not because I wish to impose licensing terms on you - please let me know if you would like another license option to be -added to the list. You may also use a license type of C if -you don't wish to specify your terms (but this is usually not a good -idea for you to do!). - -I just started out with a small set of licenses to keep things simple, -figuring I'd let people with actual working knowledge in this area -tell me what to do. So if that's you, drop me a line. +added to the list. I just started out with a small set of licenses to +keep things simple, figuring I'd let people with actual working +knowledge in this area tell me what to do. So if that's you, drop me +a line. =item meta_add @@ -683,13 +683,13 @@ for the details of how requirements can be specified. An optional parameter specifying a set of files that should be installed as executable Perl scripts when the module is installed. -May be given as an array reference of the files, or as a hash -reference whose keys are the files (and whose values will currently be -ignored). +May be given as an array reference of the files, as a hash reference +whose keys are the files (and whose values will currently be ignored), +as a string giving the name of a directory in which to find scripts, +or as a string giving the name of a single script file. -The default is to install no script files - in other words, there is -no default location where Module::Build will look for script files to -install. +The default is to install any scripts found in a F directory at +the top level of the distribution. For backward compatibility, you may use the parameter C instead of C. Please consider this usage deprecated, @@ -725,6 +725,26 @@ C<*.t> in the F subdirectory. If the C property is true, then the C directory will be scanned recursively for C<*.t> files. +=item use_tap_harness + +[version 0.2808_03] + +An optional parameter indicating whether or not to use TAP::Harness for +testing rather than Test::Harness. Defaults to false. If set to true, you must +therefore be sure to add TAP::Harness as a requirement for your module in +L. Implicitly set to a true value if C is +specified. + +=item tap_harness_args + +[version 0.2808_03] + +An optional parameter specifying parameters to be passed to TAP::Harness when +running tests. Must be given as a hash reference of parameters; see the +L documentation for details. Note that specifying +this parameter will implicitly set C to a true value. You +must therefore be sure to add TAP::Harness as a requirement for your module in +L. =item xs_files @@ -855,6 +875,15 @@ soon as it begins execution. Returns a hash reference indicating the C prerequisites that were passed to the C method. +=item cbuilder() + +[version 0.2809] + +Returns the internal ExtUtils::CBuilder object that can be used for +compiling & linking C code. If no such object is available (e.g. if +the system has no compiler installed) an exception will be thrown. + + =item check_installed_status($module, $version) [version 0.11] @@ -1166,6 +1195,19 @@ The C and C methods represent Module::Build's main support for configuration of installed modules. See also L. +=item fix_shebang_line(@files) + +[version 0.??] + +Modify any "shebang" line in the specified files to use the path to the +perl executable being used for the current build. Files are modified +in-place. The existing shebang line must have a command that contains +"C"; arguments to the command do not count. In particular, this +means that the use of C<#!/usr/bin/env perl> will not be changed. + +For an explanation of shebang lines, see +L. + =item have_c_compiler() [version 0.21] @@ -1660,6 +1702,8 @@ accessor methods for the following properties: =item prereq_action_types() +=item program_name() + =item quiet() =item recommends() @@ -1672,8 +1716,16 @@ accessor methods for the following properties: =item scripts() +=item sign() + +=item tap_harness_args() + +=item test_file_exts() + =item use_rcfile() +=item use_tap_harness() + =item verbose() =item xs_files() diff --git a/lib/Module/Build/Base.pm b/lib/Module/Build/Base.pm index 3090084..d844e4f 100644 --- a/lib/Module/Build/Base.pm +++ b/lib/Module/Build/Base.pm @@ -1,12 +1,15 @@ +# -*- mode: cperl; tab-width: 8; indent-tabs-mode: nil; basic-offset: 2 -*- +# vim:ts=8:sw=2:et:sta:sts=2 package Module::Build::Base; use strict; use vars qw($VERSION); -$VERSION = '0.2808_01'; +$VERSION = '0.30'; $VERSION = eval $VERSION; BEGIN { require 5.00503 } use Carp; +use Cwd (); use File::Copy (); use File::Find (); use File::Path (); @@ -82,6 +85,8 @@ sub resume { } $self->{invoked_action} = $self->{action} ||= 'build'; + + $self->_set_install_paths; return $self; } @@ -319,7 +324,6 @@ sub _find_nested_builds { } sub cwd { - require Cwd; return Cwd::cwd(); } @@ -328,18 +332,17 @@ sub _quote_args { # proper quoting so that the subprocess sees this same list of args. my ($self, @args) = @_; - my $return_args = ''; my @quoted; for (@args) { - if ( /^[^\s*?!$<>;\\|'"\[\]\{\}]+$/ ) { + if ( /^[^\s*?!\$<>;\\|'"\[\]\{\}]+$/ ) { # Looks pretty safe push @quoted, $_; } else { # XXX this will obviously have to improve - is there already a # core module lying around that does proper quoting? - s/"/"'"'"/g; - push @quoted, qq("$_"); + s/('+)/'"$1"'/g; + push @quoted, qq('$_'); } } @@ -363,6 +366,8 @@ sub _backticks { } } +# Tells us whether the construct open($fh, '-|', @command) is +# supported. It would probably be better to dynamically sense this. sub have_forkpipe { 1 } # Determine whether a given binary is the same as the perl @@ -435,7 +440,7 @@ sub _discover_perl_interpreter { # CBuilder is also in the core, so it should be available here require ExtUtils::CBuilder; - my $perl_src = ExtUtils::CBuilder->perl_src; + my $perl_src = Cwd::realpath( ExtUtils::CBuilder->perl_src ); if ( defined($perl_src) && length($perl_src) ) { my $uninstperl = File::Spec->rel2abs(File::Spec->catfile( $perl_src, $perl_basename )); @@ -694,6 +699,7 @@ sub ACTION_config_data { no strict 'refs'; if ( $type eq 'HASH' ) { *{"$class\::$property"} = sub { + # XXX this needs 'use strict' again my $self = shift; my $x = $self->{properties}; return $x->{$property} unless @_; @@ -717,6 +723,7 @@ sub ACTION_config_data { } else { *{"$class\::$property"} = sub { + # XXX this needs 'use strict' again my $self = shift; $self->{properties}{$property} = shift if @_; return $self->{properties}{$property}; @@ -772,6 +779,9 @@ __PACKAGE__->add_property(use_rcfile => 1); __PACKAGE__->add_property(create_packlist => 1); __PACKAGE__->add_property(allow_mb_mismatch => 0); __PACKAGE__->add_property(config => undef); +__PACKAGE__->add_property(test_file_exts => ['.t']); +__PACKAGE__->add_property(use_tap_harness => 0); +__PACKAGE__->add_property(tap_harness_args => {}); { my $Is_ActivePerl = eval {require ActivePerl::DocTools}; @@ -828,10 +838,12 @@ __PACKAGE__->add_property($_) for qw( pod_files pollute prefix + program_name quiet recursive_test_files script_files scripts + sign test_files verbose xs_files @@ -1072,7 +1084,7 @@ sub check_autofeatures { $self->log_info("Checking features:\n"); - my $max_name_len; + my $max_name_len = 0; $max_name_len = ( length($_) > $max_name_len ) ? length($_) : $max_name_len for keys %$features; @@ -1285,7 +1297,7 @@ sub check_installed_version { my $status = $self->check_installed_status($modname, $spec); if ($status->{ok}) { - return $status->{have} if $status->{have} and $status->{have} ne ''; + return $status->{have} if $status->{have} and "$status->{have}" ne ''; return '0 but true'; } @@ -1501,9 +1513,14 @@ sub _call_action { return $self->$method(); } +# cuts the user-specified options out of the command-line args sub cull_options { my $self = shift; - my $specs = $self->get_options or return ({}, @_); + my (@argv) = @_; + + my $specs = $self->get_options; + return({}, @argv) unless($specs and %$specs); # no user options + require Getopt::Long; # XXX Should we let Getopt::Long handle M::B's options? That would # be easy-ish to add to @specs right here, but wouldn't handle options @@ -1522,7 +1539,7 @@ sub cull_options { $args->{$k} = $v->{default} if exists $v->{default}; } - local @ARGV = @_; # No other way to dupe Getopt::Long + local @ARGV = @argv; # No other way to dupe Getopt::Long # Get the options values and return them. # XXX Add option to allow users to set options? @@ -1553,6 +1570,8 @@ sub args { return $self->{args}{$key}; } +# allows select parameters (with underscores) to be spoken with dashes +# when used as command-line options sub _translate_option { my $self = shift; my $opt = shift; @@ -1571,6 +1590,8 @@ sub _translate_option { meta_merge test_files use_rcfile + use_tap_harness + tap_harness_args ); # normalize only selected option names return $opt; @@ -1589,6 +1610,7 @@ sub _read_arg { } } +# decide whether or not an option requires/has an opterand sub _optional_arg { my $self = shift; my $opt = shift; @@ -1604,6 +1626,8 @@ sub _optional_arg { uninst use_rcfile verbose + sign + use_tap_harness ); # inverted boolean options; eg --noverbose or --no-verbose @@ -1618,7 +1642,7 @@ sub _optional_arg { # we're punting a bit here, if an option appears followed by a digit # we take the digit as the argument for the option. If there is - # nothing that looks like a digit, we pretent the option is a flag + # nothing that looks like a digit, we pretend the option is a flag # that is being set and has no argument. my $arg = 1; $arg = shift(@$argv) if @$argv && $argv->[0] =~ /^\d+$/; @@ -1628,12 +1652,13 @@ sub _optional_arg { sub read_args { my $self = shift; - my ($action, @argv); + (my $args, @_) = $self->cull_options(@_); my %args = %$args; my $opt_re = qr/[\w\-]+/; + my ($action, @argv); while (@_) { local $_ = shift; if ( /^(?:--)?($opt_re)=(.*)$/ ) { @@ -1828,9 +1853,9 @@ sub merge_args { if ($key eq 'config') { $self->config($_ => $val->{$_}) foreach keys %$val; } else { - my $add_to = ( $additive{$key} ? $self->{properties}{$key} - : $self->valid_property($key) ? $self->{properties} - : $self->{args}); + my $add_to = $additive{$key} ? $self->{properties}{$key} : + $self->valid_property($key) ? $self->{properties} : + $self->{args} ; if ($additive{$key}) { $add_to->{$_} = $val->{$_} foreach keys %$val; @@ -2094,7 +2119,7 @@ sub generic_test { @types or croak "need some types of tests to check"; my %test_types = ( - default => '.t', + default => $p->{test_file_exts}, (defined($p->{test_types}) ? %{$p->{test_types}} : ()), ); @@ -2104,7 +2129,7 @@ sub generic_test { } # we use local here because it ends up two method calls deep - local $p->{test_file_exts} = [ @test_types{@types} ]; + local $p->{test_file_exts} = [ map { ref $_ ? @$_ : $_ } @test_types{@types} ]; $self->depends_on('code'); # Protect others against our @INC changes @@ -2123,40 +2148,77 @@ sub generic_test { sub do_tests { my $self = shift; - my $p = $self->{properties}; - require Test::Harness; - - # Do everything in our power to work with all versions of Test::Harness - my @harness_switches = $p->{debugger} ? qw(-w -d) : (); - local $Test::Harness::switches = join ' ', grep defined, $Test::Harness::switches, @harness_switches; - local $Test::Harness::Switches = join ' ', grep defined, $Test::Harness::Switches, @harness_switches; - local $ENV{HARNESS_PERL_SWITCHES} = join ' ', grep defined, $ENV{HARNESS_PERL_SWITCHES}, @harness_switches; - - $Test::Harness::switches = undef unless length $Test::Harness::switches; - $Test::Harness::Switches = undef unless length $Test::Harness::Switches; - delete $ENV{HARNESS_PERL_SWITCHES} unless length $ENV{HARNESS_PERL_SWITCHES}; - - local ($Test::Harness::verbose, - $Test::Harness::Verbose, - $ENV{TEST_VERBOSE}, - $ENV{HARNESS_VERBOSE}) = ($p->{verbose} || 0) x 4; my $tests = $self->find_test_files; - if (@$tests) { + if(@$tests) { + my $args = $self->tap_harness_args; + if($self->use_tap_harness or ($args and %$args)) { + $self->run_tap_harness($tests); + } + else { + $self->run_test_harness($tests); + } + } + else { + $self->log_info("No tests defined.\n"); + } + + $self->run_visual_script; +} + +sub run_tap_harness { + my ($self, $tests) = @_; + + require TAP::Harness; + + # TODO allow the test @INC to be set via our API? + + TAP::Harness->new({ + lib => [@INC], + verbosity => $self->{properties}{verbose}, + switches => [ $self->harness_switches ], + %{ $self->tap_harness_args }, + })->runtests(@$tests); +} + +sub run_test_harness { + my ($self, $tests) = @_; + require Test::Harness; + my $p = $self->{properties}; + my @harness_switches = $self->harness_switches; + # Work around a Test::Harness bug that loses the particular perl # we're running under. $self->perl is trustworthy, but $^X isn't. local $^X = $self->perl; + + # Do everything in our power to work with all versions of Test::Harness + local $Test::Harness::switches = join ' ', grep defined, $Test::Harness::switches, @harness_switches; + local $Test::Harness::Switches = join ' ', grep defined, $Test::Harness::Switches, @harness_switches; + local $ENV{HARNESS_PERL_SWITCHES} = join ' ', grep defined, $ENV{HARNESS_PERL_SWITCHES}, @harness_switches; + + $Test::Harness::switches = undef unless length $Test::Harness::switches; + $Test::Harness::Switches = undef unless length $Test::Harness::Switches; + delete $ENV{HARNESS_PERL_SWITCHES} unless length $ENV{HARNESS_PERL_SWITCHES}; + + local ($Test::Harness::verbose, + $Test::Harness::Verbose, + $ENV{TEST_VERBOSE}, + $ENV{HARNESS_VERBOSE}) = ($p->{verbose} || 0) x 4; + Test::Harness::runtests(@$tests); - } else { - $self->log_info("No tests defined.\n"); - } +} - # This will get run and the user will see the output. It doesn't - # emit Test::Harness-style output. - if (-e 'visual.pl') { - $self->run_perl_script('visual.pl', '-Mblib='.$self->blib); - } +sub run_visual_script { + my $self = shift; + # This will get run and the user will see the output. It doesn't + # emit Test::Harness-style output. + $self->run_perl_script('visual.pl', '-Mblib='.$self->blib) + if -e 'visual.pl'; +} + +sub harness_switches { + shift->{properties}{debugger} ? qw(-w -d) : (); } sub test_files { @@ -2170,7 +2232,7 @@ sub test_files { sub expand_test_dir { my ($self, $dir) = @_; - my $exts = $self->{properties}{test_file_exts} || ['.t']; + my $exts = $self->{properties}{test_file_exts}; return sort map { @{$self->rscan_dir($dir, qr{^[^.].*\Q$_\E$})} } @$exts if $self->recursive_test_files; @@ -2392,7 +2454,6 @@ sub _find_file_by_type { sub localize_file_path { my ($self, $path) = @_; - $path =~ s/\.\z// if $self->is_vmsish; return File::Spec->catfile( split m{/}, $path ); } @@ -2879,7 +2940,7 @@ sub ACTION_ppmdist { File::Spec->abs2rel( File::Spec->rel2abs( $file ), File::Spec->rel2abs( $dir ) ); my $to_file = - File::Spec->catdir( $ppm, 'blib', + File::Spec->catfile( $ppm, 'blib', exists( $types{$type} ) ? $types{$type} : $type, $rel_file ); $self->copy_if_modified( from => $file, to => $to_file ); @@ -3034,7 +3095,6 @@ sub ACTION_distclean { sub do_create_makefile_pl { my $self = shift; require Module::Build::Compat; - $self->delete_filetree('Makefile.PL'); $self->log_info("Creating Makefile.PL\n"); Module::Build::Compat->create_makefile_pl($self->create_makefile_pl, $self, @_); $self->_add_to_manifest('MANIFEST', 'Makefile.PL'); @@ -3179,10 +3239,18 @@ sub _write_default_maniskip { \bblibdirs$ ^MANIFEST\.SKIP$ +# Avoid VMS specific Makmaker generated files +\bDescrip.MMS$ +\bDESCRIP.MMS$ +\bdescrip.mms$ + # Avoid Module::Build generated and utility files. \bBuild$ \bBuild.bat$ \b_build +\bBuild.COM$ +\bBUILD.COM$ +\bbuild.com$ # Avoid Devel::Cover generated files \bcover_db @@ -3285,6 +3353,8 @@ BEGIN { *scripts = \&script_files; } lgpl => 'http://opensource.org/licenses/lgpl-license.php', bsd => 'http://opensource.org/licenses/bsd-license.php', gpl => 'http://opensource.org/licenses/gpl-license.php', + gpl2 => 'http://opensource.org/licenses/gpl-2.0.php', + gpl3 => 'http://opensource.org/licenses/gpl-3.0.html', mit => 'http://opensource.org/licenses/mit-license.php', mozilla => 'http://opensource.org/licenses/mozilla1.1.php', open_source => undef, @@ -3902,16 +3972,20 @@ sub autosplit_file { AutoSplit::autosplit($file, $dir); } -sub _cbuilder { +sub cbuilder { # Returns a CBuilder object my $self = shift; my $p = $self->{properties}; return $p->{_cbuilder} if $p->{_cbuilder}; - return unless $self->_mb_feature('C_support'); + die "Module::Build is not configured with C_support" + unless $self->_mb_feature('C_support'); require ExtUtils::CBuilder; - return $p->{_cbuilder} = ExtUtils::CBuilder->new(config => $self->config); + return $p->{_cbuilder} = ExtUtils::CBuilder->new( + config => $self->config, + ($self->quiet ? (quiet => 1 ) : ()), + ); } sub have_c_compiler { @@ -3921,7 +3995,7 @@ sub have_c_compiler { return $p->{have_compiler} if defined $p->{have_compiler}; $self->log_verbose("Checking if compiler tools configured... "); - my $b = $self->_cbuilder; + my $b = eval { $self->cbuilder }; my $have = $b && $b->have_compiler; $self->log_verbose($have ? "ok.\n" : "failed.\n"); return $p->{have_compiler} = $have; @@ -3929,8 +4003,7 @@ sub have_c_compiler { sub compile_c { my ($self, $file, %args) = @_; - my $b = $self->_cbuilder - or die "Module::Build is not configured with C_support"; + my $b = $self->cbuilder; my $obj_file = $b->object_file($file); $self->add_to_cleanup($obj_file); @@ -3963,9 +4036,7 @@ sub link_c { my $module_name = $self->module_name; $module_name ||= $spec->{module_name}; - my $b = $self->_cbuilder - or die "Module::Build is not configured with C_support"; - $b->link( + $self->cbuilder->link( module_name => $module_name, objects => [$spec->{obj_file}, @$objects], lib_file => $spec->{lib_file}, @@ -3993,11 +4064,13 @@ sub compile_xs { or die "Can't find ExtUtils::xsubpp in INC (@INC)"; my @typemaps; - push @typemaps, Module::Build::ModuleInfo->find_module_by_name('ExtUtils::typemap', \@INC); - my $lib_typemap = Module::Build::ModuleInfo->find_module_by_name('typemap', ['lib']); - if (defined $lib_typemap and -e $lib_typemap) { - push @typemaps, 'typemap'; - } + push @typemaps, Module::Build::ModuleInfo->find_module_by_name( + 'ExtUtils::typemap', \@INC + ); + my $lib_typemap = Module::Build::ModuleInfo->find_module_by_name( + 'typemap', [File::Basename::dirname($file)] + ); + push @typemaps, $lib_typemap if $lib_typemap; @typemaps = map {+'-typemap', $_} @typemaps; my $cf = $self->{config}; @@ -4024,6 +4097,26 @@ sub split_like_shell { return Text::ParseWords::shellwords($string); } +sub oneliner { + # Returns a string that the shell can evaluate as a perl command. + # This should be avoided whenever possible, since "the shell" really + # means zillions of shells on zillions of platforms and it's really + # hard to get it right all the time. + + # Some of this code is stolen with permission from ExtUtils::MakeMaker. + + my($self, $cmd, $switches, $args) = @_; + $switches = [] unless defined $switches; + $args = [] unless defined $args; + + # Strip leading and trailing newlines + $cmd =~ s{^\n+}{}; + $cmd =~ s{\n+$}{}; + + my $perl = ref($self) ? $self->perl : $self->find_perl_interpreter; + return $self->_quote_args($perl, @$switches, '-e', $cmd, @$args); +} + sub run_perl_script { my ($self, $script, $preargs, $postargs) = @_; foreach ($preargs, $postargs) { @@ -4282,5 +4375,3 @@ modify it under the same terms as Perl itself. perl(1), Module::Build(3) =cut - -# vim:ts=8:sw=2:et:sta:sts=2 diff --git a/lib/Module/Build/Changes b/lib/Module/Build/Changes index fd84408..3cba17f 100644 --- a/lib/Module/Build/Changes +++ b/lib/Module/Build/Changes @@ -1,5 +1,147 @@ Revision history for Perl extension Module::Build. +0.30 - Thu Sep 25 20:57:36 2008 + + - First non-beta release since April 2007. In the meantime, Sarkozy + became president of France, the 35W bridge fell in Minneapolis, + Phelps won a lot of gold, a new tribe of indigenous people was + discovered in the Amazon, and Bob Barker stopped doing The Price Is + Right. As of this moment though, the U.S. economy still hasn't + collapsed completely. + +0.2808_05 - Thu Sep 18 23:30:39 PDT 2008 + + - Skip test in t/ext.t which tickles shellwords() in Text::ParseWords + below 3.23 [David Wheeler, Ken] + + - Fixed some shell-quoting issues in do_system() on Windows [Ken, + Schwern, reported by Curtis Jewell] + + - Fixed t/xs.t failure for missing 'const char *' typemap in 5.6 + [Schwern] + + - Added build_requires for Test::More 0.49 and Test::Harness 2.03. + Removed bundled Test::More (was not working for 5.005x anyway). + [Schwern] + + - Minimum required perl version is now 5.6.1. [Schwern] + +0.2808_04 - Thu Sep 11 22:51:27 PDT 2008 + + - Backed-out incompatible Module::Build::ModuleInfo change (first in + 0.2808_02.) + +0.2808_03 - Mon Sep 1 14:43:27 PDT 2008 + + - Made adjustments for the format changes of recent Test::Harness + output. [Nicholas Clark] + + - Fixed the documentation for script_files to indicate that we search + bin/ for scripts by default. It has been this way for several + years. [Spotted by Ron Savage] + +0.2808_02 - Wed Jul 9 16:45:08 PDT 2008 + + - Experimental support for TAP::Harness with --use-tap-harness option + and the tap_harness_args property. [David Wheeler & Eric Wilhelm] + + - Added test_file_exts property for main-run tests other than '*.t'. + [David Wheeler] + + - Fixed getcwd()/rmtree() failure case on 5.10+mac where something is + unhappy about all of the tests deleting their distgen directory + before leaving it. [Eric Wilhelm & David Wheeler] + + - Improved support for parsing qv() in modules' $VERSION + declarations, and made $VERSION-parsing errors more verbose. [Jos + Boumans] + + - Integrated an omnibus patch for various VMS fixes. [Craig Berry & + John E. Malmberg] + + - Some versions of Test::Harness (or something) seem to not be + stripping the ".t" suffix when outputting test reports, which was + causing one of our tests in t/compat.t to fail. Fixed. [Spotted by + a smoke tester] + + - Most Unix platforms seem to allow hyphens in usernames, so we honor + this in our de-tilde-fying methods now. [Spotted by s-murata] + + - If there are multiple assignments to the $VERSION variable in + someone's module and this generates warnings, tell the user what + line number the problem is at. + + - Added 'gnu' and 'gnukfreebsd' as Unix variants. [Niko Tyni] + + - Fixed a couple bugs in how we quote arguments to external processes + when they have to pass through the shell. Also much more + thoroughly tested our quoting now. + + - Edited the Module::Build::API docs prose about the 'license' field + in response to some comments on the module-authors mailing list. + + - Fixed a typo in some example code in the Cookbook. [Jeremy Leader] + + - Custom typemaps were being looked for in places that don't quite + exist; fixed. [Michael G Schwern] + + - QNX/Neutrino is now considered to be Unix. [rt.cpan.org 32214] + + - Added 'gpl2' and 'gpl3' to the list of valid licenses. [Allen + Engelhardt] + + - Fixed our Data::Dumper wrapper's sensitivity to users who might set + $Data::Dumper::Terse. [Spotted by Dominique Dumont] + + - Documented the fix_shebang_line() method. [Elliot Shank] + + - Applied the 'const' modifier to version() and xs_version() XS + functions we use during testing. [Robin Barker] + + - Fixed processing of INC=, POLLUTE=, INSTALLDIRS=, and LIB= for + passthrough/small Makefile.PLs. + + - perl Build.PL --sign=1 now signs. [Michael G Schwern] + + - Fixed processing of INSTALLDIRS=whatever for compatibility + Makefiles. [Spotted by John Peacock] + + - Zillions of special-cases have been added in Compat.pm for dealing + with the special Makefile system on VMS. [John E. Malmberg] + + - Fixed some stuff in how VMS command-args get quoted. [John E. Malmberg] + + - VMS now overrides localize_file_path() and localize_dir_path() so + we don't need to do special stuff in the general case. [John + E. Malmberg] + + - Added a few more VMS-specific entries to the default MANIFEST.SKIP + file that (sometimes) gets created during the 'manifest' + action. [John E. Malmberg] + + - Fixed a catdir() that should have been a catfile() when creating a + ppmdist. [John E. Malmberg] + + - Removed some assumptions about what makefiles are called (not + necessarily "Makefile") and how they take their arguments, to get + VMS tests working better. [John E. Malmberg] + + - Fixed our check for Archive::Tar in the t/runthrough.t test, which + fixes a common failure on Win32. [Spotted by Chris Williams] + + - Fixed a File::Spec mal-ism in t/destinations.t [Craig A. Berry] + + - Exposed the internal ExtUtils::CBuilder object as part of our API, + via the cbuilder() method. [Zefram] + + - Upgraded to version.pm 0.74 (fixes bug #30004.) + + - Overwrite core (post-5.9.4) Module::Build installs (bug #20528.) + + - Pass quiet() option to ExtUtils::CBuilder object. + +0.2808_01 - Wed Oct 24 11:51:25 2007 + - All .pm files in the Module-Build distribution (except for M::B::Version.pm, which is kind of tied to version.pm) now have the same $VERSION number explicitly specified. @@ -1806,3 +1948,592 @@ Revision history for Perl extension Module::Build. - Added documentation for 'extra_linker_flags' parameter, and added a corresponding 'extra_compiler_flags' parameter. [original patch by Richard Clamp] + + - The pass-through Makefile created by Module::Build::Compat now + supports MakeMaker options like POLLUTE=1 and INC. We also just + warn & skip when we see any unknown MM parameters, rather than + dying. [Dave Rolsky] + + - Fixed an error about how @INC and $ENV{PERL5LIB} interact during + the testing of M::B itself. [jk ] + + - The pass-through Makefile doesn't include 'recommended' M::B + dependencies in the Makefile anymore, since they're not strictly + necessary. In particular, this makes installing M::B itself + easier. + + - A new 'create_makefile_pl' parameter lets you use + Module::Build::Compat during the 'distdir' (or 'dist') action to + automatically create a Makefile.PL for compatibility with + ExtUtils::MakeMaker. The parameter's value should be one of the + styles named in the Module::Build::Compat documentation. + + - When compiling C code, we now respect 'pollute' and 'inc' + parameters. (XXX - needs docs) [Dave Rolsky] + + - Made the creation of the "install map" more generic. (XXX - needs + documentation) + + - Fixed a problem in which add_to_cleanup() didn't note cleanup files + unless create_build_script() had been called already. [Dave Rolsky] + + - During 'Build dist', we no longer have to load each .pm file (via + Module::Info) to determine the $VERSION numbers inside. Instead, + we call our internal version_from_file() method, which is the same + thing MakeMaker and PAUSE and search.cpan.org do. Also fixes a + failure when Module::Info is installed in a nonstandard directory. + [reported by Teun Burgers] + + - Fixed some failing test code on Windows - open files can't be + deleted. [Andrew Savige] + + - The Cygwin platform is now treated as a flavor of Unix rather than + a flavor of Windows. [chocolateboy] + + - We're now more aggressive about adding temporary C compilation + files (*.c, *.bs) to the cleanup list. [Dave Rolsky] + + - When constructing the list in META.yml of packages provided by this + distribution, we now use the same rules as the PAUSE scanner does + when a single .pm file contains multiple VERSIONs. [Andreas Koenig] + + - check_installed_status() now works as both a class method and an + object method (and is documented so). [Spotted by Dave Rolsky] + +0.18 Tue Apr 8 13:24:23 CDT 2003 + + - We now rewrite the shebang lines of scripts ourselves, rather than + relying on MakeMaker routines to do it. MakeMaker changed the way + this happened (not the result, but where the code lived) a few + times. [Suggested by Richard Clamp] + + - The scripts() method has changed to script_files(), and likewise + the 'scripts' parameter has changed to 'script_files'. The old + names can still be used for backward compatibility. + + - Support for the 'scripts' parameter (which is now 'script_files') + was broken in 0.17, now it's fixed. [Richard Clamp] + + - We now recommend ExtUtils::ParseXS 2.02, which will fail to load + with perl 5.005 or earlier (which is proper, because it doesn't + work with those versions). When it fails to load, we still fall + back to using the xsubpp script for XS parsing. [spotted by Dave + Rolsky, fix suggested by Richard Clamp] + + - Now works on VMS - the Build script's shebang-line-equivalent + wasn't being formed correctly there - though just about everything + else worked fine. [Tested & patched by Michael Schwern] + + - Eliminated a warning that occurred if 'perl Build.PL' or the + check_installed_status() method was run with -w. [Spotted by + Michael Schwern] + +0.17 Sat Mar 29 18:06:01 CST 2003 + + - Now works under perl 5.005_03. [Richard Clamp] + + - When building blib/ , .PL files are now processed before doing + anything else. This means .PL files can be used in any of the + other contexts. + + - The locating and processing of .pm, .pod, .xs, .PL files and script + files are now isolated into their own methods. This is aimed + toward providing a stable interface for this stuff, so they can be + overridden, parameterized, etc. They're not quite stable yet, + though. + + - The internal lib_to_blib() method has gone away, because processing + is now done by smaller specialized methods. This method had some + duplicate assumptions about filenames that it's nice to get rid of. + + - .PL files are no longer automatically processed in the c_source + directory, they must be specified manually in a 'PL_files' + parameter. + + - Mention in the docs that it's useful to do "PL_FILES => {}" in a + Makefile.PL if you're using both a Makefile.PL and a + Build.PL. [Dom] + + - Add several options to the 'license' field, so that we're in better + sync with PAUSE and CPAN options. [Andreas Koenig] + + - Created a find_perl_interpreter() method that tries to locate the + currently executing perl interpreter. Following a suggestion from + Nicholas Clark for Inline, we prefer an absolute + path in $^X, then an existent path in $Config{perlpath}, then + whatever's in $^X. + + - Use the aforementioned perl to run scripts in run_perl_script(). + This fixes the spurious warning "WARNING: Configuration was + initially created with 'foo', but we are now using 'bar'" that + appeared a lot in version 0.16. + + +0.16 Mon Feb 24 13:06:47 CST 2003 + + - All three C compilers that perl supports on Windows environments + (MSVC, BCC, and GCC) are now supported by Module::Build. We now + reportedly pass all tests on Windows. [Randy W. Sims] + + - The test t/xs.t, which tests building of XS modules, will be + skipped if no C compiler is found. [suggested by Randy W. Sims] + + - The "install" action accepts new "destdir" [motivated by Michael + Schwern and Chip Salzenberg] and "uninst" parameters [by Dave + Rolsky]. The former prepends an arbitrary directory to all + installation paths (useful for package management), and the latter + will tell ExtUtils::Install to remove any differing files that are + "shadowing" the stuff you're installing from a different location, + just like MakeMaker's "make install UNINST=1" command will do. + + - Made changes to the generated Makefile in Module::Build::Compat + that much better support Windows platforms [after suggestions by + James Freeman] + + - Added experimental support for creating distribution SIGNATURE + files via Module::Signature. [Dave Rolsky] + + - Added experimental support for installing via the "only.pm" module, + which allows loading specific versions of modules. Since this + module is so new, the interface may still be changing. [Brian + Ingerson] + + - Added support for installing executable scripts, via the 'scripts' + parameter to new(), and the scripts() accessor method. + + - Fix an infinite loop that occurred when doing 'perl Build.PL + config="foo=bar"' + + - Fix up the formatting of the error message the user gets when + prereqs aren't satisfied. + +0.15 Fri Jan 17 15:00:24 CST 2003 + + - In link_c(), extra object files were mistakenly being treated as + output files, not input files, in the up-to-date check. Fixed. + + - In up_to_date(), don't make an unnecessary copy of the file lists + when they're specified as array references. + + - Split off the C compilation phase into its own method, + compile_support_files(), for easier subclassing. + + - Start a stub of a 'manifypods' action. + + - Compiler optimizations weren't being included in C compilation + statements. Fixed. + + - The 'extra_linker_flags' parameter wasn't being honored. Fixed. + + - The 'ccflags' Config.pm entry wasn't being properly split into + separate arguments. Fixed. + + +0.14 Fri Dec 13 14:06:29 AEST 2002 + + - Added support for MacPerl (Mac OS version 9 and below), which (as + far as I know) was never natively supported by MakeMaker. Still + lacks support for the 'test' action (because Test::Harness + requires forking, which MacPerl won't do) and compiling XS/C files + (because I don't know how to invoke a compiler on MacOS, and one + may not even be available). This change is brought to you by + Michael Schwern and the letter '('. + + - Improved processing of .xs files. Now we use the new + ExtUtils::ParseXS module if it's available, otherwise we use + backticks and write the result to a .c file ourselves. This + avoids the need to do cross-platform shell redirection. + + - Make sure all parts of 'Build test' use the not-yet-installed + version of Module::Build. This only affects the tests for this + module, not any of the module code itself. [Spotted by Schwern] + + - Oopsie - use $Config{ld} instead of $Config{cc} for linking. + + - Added a 'diff' action, which is useful for comparing the details + of what you're about to install with what is already installed on + your system. This uses File::Compare, which is in the core. + + - Fixed a problem on Windows in which the _build/ directory wasn't + getting deleted during the 'realclean' action, because we had a + file open in that directory. [Spotted by Michael Schwern] + + - delete_filetree() now always uses File::Path::rmtree(), regardless + of whether the thing being deleted is a file or a directory. This + helps remove things on obscure platforms with strange locking + rules (or even not so obscure ones like MacOS). It also now + reports the number of files or directories deleted (without + recursing directory contents). + + - rm_previous_build_script() is gone, replaced by calls to + delete_filetree(). + + - 'Build' now chdir()s in a BEGIN block, so the 'use Module::Build' + statement will work correctly. Solves a problem on MacOS, where + the 'Build' script may often be invoked from the wrong working + directory. [Fix by Michael Schwern] + + - Internally we now use the multi-argument form of system() to run + external commands (such as 'diff' or 'cc') whenever possible (and + whenever we can't avoid system() altogether). Note that this + means we have to handle splitting some strings (such as + $Config{ccflags}) into argument lists like the shell would, which + is a drag. However, the alternative would be to handle shell + quoting of all arguments to commands ourselves, which is an even + bigger drag across platforms and involves arbitrary filenames and + so on. + + - To handle the argument splitting mentioned above, a method + split_like_shell() has been created. So far it's just doing naive + processing. In practice, I've yet to actually see a %Config entry + that uses quotes & spaces, so the splitting task is usually not + very error-prone. + + - The 'test' action now takes a 'test_files' parameter, similar to + the (undocumented) ExtUtils::MakeMaker TEST_FILES argument. Handy + during development when fixing bugs. + + - Internally, the rscan_dir() method can now accept a predicate + function that decides whether a file/directory should be matched. + + - We now issue a warning message when the author hasn't specified a + license type. + +0.13 Wed Nov 20 20:07:53 AEST 2002 + + - 'cleanup' file lists are now written immediately, rather than at + program termination. This helps avoid "phantom files" that don't + get handled by the 'realclean' action. The internal + write_cleanup() method (which was never documented) is now gone. + + - The 'blib/' directory is now properly cleaned up in more (all?) + circumstances. Previously it could become a phantom if + create_build_script() was never called. + + - Now scan the 'c_source' directory for .cpp (C++) files as well as + .c files, and compiles them. + + - Use a 'phony' target for 'make manifest' in the pass-through + Makefile, for the same reason as 'make install' (see version 0.12 + notes below). + + - Module::Build::Compat now accepts any known Config.pm key and + passes it through to the Build.PL. Fixes a problem with CPANPLUS, + which was passing INSTALLMAN1DIR. + + - The file 'META.yaml' has been re-named to 'META.yml' in order to + cooperate better with systems that can only handle 3 characters + after the dot. + + - The t/xs.t test should give more informative error messages upon + failure. + +0.12 Thu Nov 14 18:31:47 AEST 2002 + + - The META.yaml file was erroneously looking for 'build_depends' + instead of 'build_requires'. [spotted by Iain Truskett] + + - Add prompt() and y_n() methods for use in Build.PLs + + - Do more to work with all versions of Test::Harness when setting + the TEST_VERBOSE flag and running under the debugger [patch by + Dave Rolsky] + + - Include a test for verbosity handling + + - Make sure the blib/ directory is always cleaned up with the + 'clean' or 'realclean' action. + + - In a pass-through Makefile.PL, inform 'make' that 'install' is a + "fake target", so that it works properly on case-insensitive + filesystems like HFS+ with distributions that contain an INSTALL + file. [patch by Brian Ingerson] + + - In Module::Build::Compat, show an example Makefile.PL that can + install Module::Build and re-invoke itself in one fell swoop [Dave + Rolsky and Autrijus Tang] + + - Improve the formatting of the Module::Build and + Module::Build::Compat documentation. + +0.11 Fri Aug 23 18:50:46 AEST 2002 + + - 'module_version' and 'module_version_from' have been replaced by + 'dist_version' and 'dist_version_from', which is what they really + meant in the first place. 'dist_name' has been added. + + - 'module_name' is now just a way to set 'dist_name' and + 'dist_version_from' in a convenient way. + + - The 'name' in META.yaml is now the distribution name, not the + (incorrect) module name. [spotted by Graham Barr] + + - Added the check_installed_status() and prereq_failures() methods + for checking prerequisite information with the programmatic + interface + + - check_installed_version() now uses check_installed_status() + internally + + - Documented the create_build_script() method, which had escaped + documentation. + + - create_build_script() now writes prerequisite information to the + _build/ directory, for use by Module::Build::Compat. + + - Module::Build::Compat has documentation for a safer way to write a + dummy Makefile.PL. [patch by Autrijus Tang] + +0.10 Wed Aug 7 19:36 2002 + - Recommend YAML 0.35 instead of 0.30. + + - Don't die during 'Build disttest' if YAML isn't installed. This + fixes tests 5-10 in runthrough.t if YAML isn't installed. + + - Die if an unknown license type is used, but still default to + 'unknown' if no license is specified. + + - Use YAML::DumpFile() if we're using a recent YAML, + YAML::StoreFile() otherwise. + + - Show specific error messages in runthrough.t. + + - Add a generated_by entry to the META.yaml file. + + - Skip a few tests if YAML isn't installed. + +0.09 Fri Jun 28 11:07:08 EST 2002 + + - The 'distdir' action wasn't deleting the distribution directory + before building it again. This meant that, say, if you did 'Build + disttest' then 'Build dist', you'd end up with a blib/ directory + in your distribution. I actually had this happen for version + 0.08, and it's not nice to distribute a blib/ on CPAN. + + - We now keep track of the 'base_dir', i.e. the top-level build + directory, so we can change back into it if we change out of it. + This necessitated a cwd() method, which uses the Cwd.pm module. + I'm aware of Cwd's limitations, particularly under taint-mode, but + I don't know a way around using it here. + + - The 'dist_dir' action now changes back into 'base_dir' directory. + + - We now do write_config() inside the create_build_script() method, + not inside the new() method. + + - Simplified the find_version() method, and improved its error + messages. + + - Renamed module_name_to_file() to find_module_by_name(), and added + a parameter specifying the directories to search in. Previously + we searched in 'lib' and @INC, which wasn't correct in all + situations. + + - Patched the docs to change "Build test" to "./Build test" + [Elizabeth Mattijsen] + +0.08 Wed Jun 26 20:30:56 EST 2002 + + - Fixed the 'prereq' alias for the 'requires' parameter + + - Added some tests in t/basic.t to test the dependency checking + + - Added 'artistic' as a licensing option [Arthur Bergman] + + - Fixed some bugs in requires/prereq/recommends/conflicts/build_depends + + - Fixed a typo in the 'distclean' action that prevented its + execution [Arthur Bergman] + + - Separated the linking phase of building XS items into its own + link_c() method. Its interface is still unstable, so it's not + documented yet. [suggested by Arthur Bergman] + +0.07 Jun 9 2002 15:46 + + - We now generate a 'META.yaml' metadata file during 'Build dist'. + This can be very useful for lots of things, none of which are + implemented yet. + + - Added a 'dynamic_config' parameter, defaulting to false. This + lets distribution systems (CPAN.pm, etc.) build, test, and install + "easy" modules without having to execute the Build.PL at runtime. + It's also a guarantee that the list of dependencies is exactly + what is present in the metadata file, and won't be changed during + the build process. + + - Added support for "recommended" and "build-time requirement" + modules, besides those that are absolutely required. Also added a + "conflicts" field. + + - Changed the 'prereq' field to 'requires' (the old name will + continue to work). + + - Added support for checking the installed version of perl as an + explicit dependency. + + - Added a 'license' parameter to specify one of a fixed number of + licenses for the distribution. + + - Fixed a bug in Module::Build::Compat that was preventing arguments + from being processed properly. [patch by Ilya Martynov] + + - Make sure we're in the right directory when we write the cleanup + file, since various ExtUtils::Install errors might leave us in an + unknown directory. [patch by Ilya Martynov] + + - Specified the 'license', 'recommends', and 'dynamic_config' + values in Build.PL, and changed 'prereq' to 'requires'. + +0.06 Apr 2 2002 17:44 + + - Added the Module::Build::Compat module for assisting and + explaining compatibility with ExtUtils::Makemaker and cohorts. + + - State is now saved using Data::Dumper instead of my ad-hoc + mechanism, guaranteeing data integrity. Whitespace values broke + in the former scheme. + + - Added the 'recommended' option, which works like 'prereq' but + isn't insistent. + + - Separated the various parameters into three groups: parameters + that tell Module::Build what to do, Config.pm parameters, and + user-defined parameters for each build (the module author is the + 'user' here). This helps avoid conflicts between names, and it + was silly to have them all together. The three groups of + parameters are subject to the same rules for overriding: values + specified during a Build action take precedence over values + specified at 'perl Build.PL' time, which in turn take precedence + over values specified in the call to new(). + + - Improved support for .PL files. Any .PL file in the lib/ + directory or the directory specified by 'c_source' will now get + properly executed. I also added a 'PL_files' parameter that you + can use in case the .PL doesn't create an obviously-named output + file. + + - If a prerequisite condition is malformed, we now report a prereq + failure and say why. Previously we issued a warning and kept + going. + + +0.05 10-Jan-2002 20:26 + - Added the Module::Build->subclass() method, which makes it easier to + make quick-and-dirty subclasses of Module::Build. + + - Reorganized the docs a bit. + + - Added the 'testdb' action, and the 'debugger=1' argument to the + 'test' action, both of which run tests under the perl + debugger. (idea: Dave Rolsky) + + - Added prerequisite checking (Dave Rolsky) + + - Fixed an unlikely-to-occur bug with misquoted strings in the + 'Build' script (spot: Dave Rolsky) + + - We're more careful about shush-ing warnings that + ExtUtils::Manifest might emit (Dave Rolsky) + + - The 'help' action now auto-generates the list of actions (Dave Rolsky) + + - Added the 'distcheck', 'skipcheck', 'distclean', 'distdir', and + 'disttest' actions (Dave Rolsky) + + - We're a little more aggressive about cleaning up temporary files - + we'll try to clean them up even when we don't have write permission + on them. This isn't as dastardly as it sounds; if we /really/ + don't have permission, we won't be able to remove them no matter + how hard we try. + +0.04 Fri Nov 16 16:55 2001 + - Added a 'manifest' action. It's just like MakeMaker's 'make manifest', it + brings your MANIFEST file up to date with your distribution directory. + + - Reorganized some of the responsibilities of various methods, which + allows modules to be built and tested programmatically. + + - The 'clean' action will now clean up files that were created more + recently than the on-disk cleanup registry was written. + + - Undefined values from Config.pm are handled correctly now. + + - The dispatch() method will now accept explicit dispatch + parameters, for use in a programmatic setting. + + - $ENV{TEST_VERBOSE} will be set in test scripts if the 'verbose=1' + parameter is set. + + - Moved the test.pl script to t/basic.t + + - Created the t/xs.t script, which tests building a module with a + .xs component. + + - Fixed the loading of $^O-specific modules (there were no such + modules before). + + - Added a 'darwin' platform module, which removes -flat_namespace + from $Config{ccflags} while building .xs modules (it's a linker + flag, not a compiler flag). + + - Now uses $^W instead of the 'warnings' pragma, which apparently + provides compatibility with perl 5.005 (I've only tested it with + 5.6.x myself). + + - If a file called C exists in the top-level directory, + this file will be executed as a Perl script during 'Build test' and + its output will be shown to the user. This is a good place to put + speed tests or other tests that don't use the C format + for output. + + - The 'Build install' step will now put .xs-related things in the + correct architecture-dependent libraries. + + - Added the 'autosplit' option, even though I think autosplitting is + a load of hooie. + +0.03 Sun Nov 11 14:58 CDT 2001 + - The 'perl Build.PL' step will now detect whether the current + environment is "unixish", "windowsish", etc., and load the correct + module (i.e. Module::Build::Platform::Unix). More specific + modules may also be written for particular values of $^O. + + - Module::Build will now process any .xs files in the lib/ + directory. Please let me know whether this works or not with your + distribution & platform. I'll be trying out various distributions + on my platform. + + - Corrected some embarassing errors in the POD documentation. Also + added a long documentation section on the various build actions + (test, install, build, etc.) and added some neato ASCII art. + + - Added a 'cleanup' mechanism - any method may call the + $self->add_to_cleanup(@files) method to register files which need + to be cleaned up during 'Build clean'. + + - Added a 'Build help' action that gives a little syntax help, and + lists all the actions available. + + - Fixed a bug in which 'blib/' wasn't properly being added to @INC + when running 'Build test'. + + - For the 'Build dist' action, we'll use the 'tar' and 'gzip' + programs (as specified by Config.pm) on Unix platforms, otherwise + we'll use Archive::Tar and Compress::Zlib. + +0.02 Wed Sep 5 00:53:04 CDT 2001 + - Added POD documentation. + + - Added the 'install', 'fakeinstall', and 'dist' actions. + + - new() will now determine version string based on 'module_version', or + 'module_version_from', or 'module_name', in that order. + + - Module::Build::Base handles its file paths in a platform-independent + way, using the File:: modules + + +0.01 Sun Aug 5 01:23:10 2001 + - original version; created by h2xs 1.1.1.4 with options -XA -n Module::Build + diff --git a/lib/Module/Build/Compat.pm b/lib/Module/Build/Compat.pm index d1bc725..92c2b5e 100644 --- a/lib/Module/Build/Compat.pm +++ b/lib/Module/Build/Compat.pm @@ -2,7 +2,7 @@ package Module::Build::Compat; use strict; use vars qw($VERSION); -$VERSION = '0.2808_01'; +$VERSION = '0.30'; use File::Spec; use IO::File; @@ -11,19 +11,50 @@ use Module::Build; use Module::Build::ModuleInfo; use Data::Dumper; +my %convert_installdirs = ( + PERL => 'core', + SITE => 'site', + VENDOR => 'vendor', +); + my %makefile_to_build = ( TEST_VERBOSE => 'verbose', VERBINST => 'verbose', - INC => sub { map {('--extra_compiler_flags', $_)} Module::Build->split_like_shell(shift) }, - POLLUTE => sub { ('--extra_compiler_flags', '-DPERL_POLLUTE') }, - INSTALLDIRS => sub {local $_ = shift; 'installdirs=' . (/^perl$/ ? 'core' : $_) }, - LIB => sub { ('--install_path', 'lib='.shift()) }, + INC => sub { map {(extra_compiler_flags => $_)} Module::Build->split_like_shell(shift) }, + POLLUTE => sub { (extra_compiler_flags => '-DPERL_POLLUTE') }, + INSTALLDIRS => sub { (installdirs => $convert_installdirs{uc shift()}) }, + LIB => sub { + my $lib = shift; + my %config = ( + installprivlib => $lib, + installsitelib => $lib, + installarchlib => "$lib/$Config{archname}", + installsitearch => "$lib/$Config{archname}" + ); + return map { (config => "$_=$config{$_}") } keys %config; + }, + + # Convert INSTALLVENDORLIB and friends. + ( + map { + my $name = "INSTALL".$_."LIB"; + $name => sub { + my @ret = (config => { lc $name => shift }); + print STDERR "# Converted to @ret\n"; + + return @ret; + } + } keys %convert_installdirs + ), # Some names they have in common map {$_, lc($_)} qw(DESTDIR PREFIX INSTALL_BASE UNINST), ); +my %macro_to_build = %makefile_to_build; +# "LIB=foo make" is not the same as "perl Makefile.PL LIB=foo" +delete $macro_to_build{LIB}; sub create_makefile_pl { @@ -37,6 +68,8 @@ sub create_makefile_pl { $fh = $args{fh}; } else { $args{file} ||= 'Makefile.PL'; + local $build->{properties}{quiet} = 1; + $build->delete_filetree($args{file}); $fh = IO::File->new("> $args{file}") or die "Can't write $args{file}: $!"; } @@ -50,7 +83,7 @@ sub create_makefile_pl { } # If a *bundled* custom subclass is being used, make sure we add its - # directory to @INC. + # directory to @INC. Also, lib.pm always needs paths in Unix format. my $subclass_load = ''; if (ref($build) ne "Module::Build") { my $subclass_dir = $package->subclass_dir($build); @@ -60,10 +93,13 @@ sub create_makefile_pl { if ($build->dir_contains($base_dir, $subclass_dir)) { $subclass_dir = File::Spec->abs2rel($subclass_dir, $base_dir); + $subclass_dir = $package->unixify_dir($subclass_dir); $subclass_load = "use lib '$subclass_dir';"; } + # Otherwise, leave it the empty string } else { + $subclass_dir = $package->unixify_dir($subclass_dir); $subclass_load = "use lib '$subclass_dir';"; } } @@ -161,8 +197,13 @@ sub subclass_dir { || File::Spec->catdir($build->config_dir, 'lib')); } +sub unixify_dir { + my ($self, $path) = @_; + return join '/', File::Spec->splitdir($path); +} + sub makefile_to_build_args { - shift; + my $class = shift; my @out; foreach my $arg (@_) { next if $arg eq ''; @@ -171,24 +212,34 @@ sub makefile_to_build_args { die "Malformed argument '$arg'"); # Do tilde-expansion if it looks like a tilde prefixed path - ( $val ) = glob( $val ) if $val =~ /^~/; + ( $val ) = Module::Build->_detildefy( $val ) if $val =~ /^~/; if (exists $makefile_to_build{$key}) { my $trans = $makefile_to_build{$key}; - push @out, ref($trans) ? $trans->($val) : ("--$trans", $val); + push @out, $class->_argvify( ref($trans) ? $trans->($val) : ($trans => $val) ); } elsif (exists $Config{lc($key)}) { - push @out, '--config', lc($key) . "=$val"; + push @out, $class->_argvify( config => lc($key) . "=$val" ); } else { # Assume M::B can handle it in lowercase form - push @out, "--\L$key", $val; + push @out, $class->_argvify("\L$key" => $val); } } return @out; } +sub _argvify { + my ($self, @pairs) = @_; + my @out; + while (@pairs) { + my ($k, $v) = splice @pairs, 0, 2; + push @out, ("--$k", $v); + } + return @out; +} + sub makefile_to_build_macros { my @out; - while (my ($macro, $trans) = each %makefile_to_build) { + while (my ($macro, $trans) = each %macro_to_build) { # On some platforms (e.g. Cygwin with 'make'), the mere presence # of "EXPORT: FOO" in the Makefile will make $ENV{FOO} defined. # Therefore we check length() too. @@ -216,18 +267,26 @@ sub fake_makefile { my $class = $args{build_class}; my $perl = $class->find_perl_interpreter; + + # VMS MMS/MMK need to use MCR to run the Perl image. + $perl = 'MCR ' . $perl if $self->_is_vms_mms; + my $noop = ($class->is_windowsish ? 'rem>nul' : - $class->is_vmsish ? 'Continue' : + $self->_is_vms_mms ? 'Continue' : 'true'); - my $Build = 'Build --makefile_env_macros 1'; - # Start with a couple special actions + my $filetype = $class->is_vmsish ? '.COM' : ''; + + my $Build = 'Build' . $filetype . ' --makefile_env_macros 1'; + my $unlink = $class->oneliner('1 while unlink $ARGV[0]', [], [$args{makefile}]); + $unlink =~ s/\$/\$\$/g; + my $maketext = <<"EOF"; all : force_do_it $perl $Build realclean : force_do_it $perl $Build realclean - $perl -e unlink -e shift $args{makefile} + $unlink force_do_it : @ $noop @@ -241,7 +300,17 @@ $action : force_do_it EOF } - $maketext .= "\n.EXPORT : " . join(' ', keys %makefile_to_build) . "\n\n"; + if ($self->_is_vms_mms) { + # Roll our own .EXPORT as MMS/MMK don't honor that directive. + $maketext .= "\n.FIRST\n\t\@ $noop\n"; + for my $macro (keys %macro_to_build) { + $maketext .= ".IFDEF $macro\n\tDEFINE $macro \"\$($macro)\"\n.ENDIF\n"; + } + $maketext .= "\n"; + } + else { + $maketext .= "\n.EXPORT : " . join(' ', keys %macro_to_build) . "\n\n"; + } return $maketext; } @@ -267,13 +336,24 @@ sub fake_prereqs { sub write_makefile { my ($pack, %in) = @_; - $in{makefile} ||= 'Makefile'; + + unless (exists $in{build_class}) { + warn "Unknown 'build_class', defaulting to 'Module::Build'\n"; + $in{build_class} = 'Module::Build'; + } + my $class = $in{build_class}; + $in{makefile} ||= $pack->_is_vms_mms ? 'Descrip.MMS' : 'Makefile'; + open MAKE, "> $in{makefile}" or die "Cannot write $in{makefile}: $!"; print MAKE $pack->fake_prereqs; print MAKE $pack->fake_makefile(%in); close MAKE; } +sub _is_vms_mms { + return Module::Build->is_vmsish && ($Config{make} =~ m/MM[SK]/i); +} + 1; __END__ diff --git a/lib/Module/Build/Config.pm b/lib/Module/Build/Config.pm index 76b92b9..e8004aa 100644 --- a/lib/Module/Build/Config.pm +++ b/lib/Module/Build/Config.pm @@ -2,7 +2,7 @@ package Module::Build::Config; use strict; use vars qw($VERSION); -$VERSION = '0.2808_01'; +$VERSION = '0.30'; $VERSION = eval $VERSION; use Config; diff --git a/lib/Module/Build/Cookbook.pm b/lib/Module/Build/Cookbook.pm index ba721b9..7e963b0 100644 --- a/lib/Module/Build/Cookbook.pm +++ b/lib/Module/Build/Cookbook.pm @@ -1,4 +1,7 @@ package Module::Build::Cookbook; +use strict; +use vars qw($VERSION); +$VERSION = '0.30'; =head1 NAME @@ -245,7 +248,7 @@ change the order of the entries in that property: # Process pod files first my @e = @{$build->build_elements}; - my $i = grep {$e[$_] eq 'pod'} 0..$#e; + my ($i) = grep {$e[$_] eq 'pod'} 0..$#e; unshift @e, splice @e, $i, 1; Currently, C has the following default value: diff --git a/lib/Module/Build/Dumper.pm b/lib/Module/Build/Dumper.pm index 7021ece..2c2ca59 100644 --- a/lib/Module/Build/Dumper.pm +++ b/lib/Module/Build/Dumper.pm @@ -1,4 +1,7 @@ package Module::Build::Dumper; +use strict; +use vars qw($VERSION); +$VERSION = '0.30'; # This is just a split-out of a wrapper function to do Data::Dumper # stuff "the right way". See: @@ -9,7 +12,7 @@ use Data::Dumper; sub _data_dump { my ($self, $data) = @_; return ("do{ my " - . Data::Dumper->new([$data],['x'])->Purity(1)->Dump() + . Data::Dumper->new([$data],['x'])->Purity(1)->Terse(0)->Dump() . '$x; }') } diff --git a/lib/Module/Build/ModuleInfo.pm b/lib/Module/Build/ModuleInfo.pm index 66a6671..d78efed 100644 --- a/lib/Module/Build/ModuleInfo.pm +++ b/lib/Module/Build/ModuleInfo.pm @@ -1,3 +1,5 @@ +# -*- mode: cperl; tab-width: 8; indent-tabs-mode: nil; basic-offset: 2 -*- +# vim:ts=8:sw=2:et:sta:sts=2 package Module::Build::ModuleInfo; # This module provides routines to gather information about @@ -6,7 +8,7 @@ package Module::Build::ModuleInfo; use strict; use vars qw($VERSION); -$VERSION = '0.2808_01'; +$VERSION = '0.30'; $VERSION = eval $VERSION; use File::Spec; @@ -14,16 +16,16 @@ use IO::File; use Module::Build::Version; -my $PKG_REGEXP = qr/ # match a package declaration +my $PKG_REGEXP = qr{ # match a package declaration ^[\s\{;]* # intro chars on a line package # the word 'package' \s+ # whitespace ([\w:]+) # a package name \s* # optional whitespace ; # semicolon line terminator -/x; +}x; -my $VARNAME_REGEXP = qr/ # match fully-qualified VERSION name +my $VARNAME_REGEXP = qr{ # match fully-qualified VERSION name ([\$*]) # sigil - $ or * ( ( # optional leading package name @@ -32,9 +34,9 @@ my $VARNAME_REGEXP = qr/ # match fully-qualified VERSION name )? VERSION )\b -/x; +}x; -my $VERS_REGEXP = qr/ # match a VERSION definition +my $VERS_REGEXP = qr{ # match a VERSION definition (?: \(\s*$VARNAME_REGEXP\s*\) # with parens | @@ -42,43 +44,45 @@ my $VERS_REGEXP = qr/ # match a VERSION definition ) \s* =[^=~] # = but not ==, nor =~ -/x; +}x; sub new_from_file { - my $package = shift; + my $class = shift; my $filename = File::Spec->rel2abs( shift ); + return undef unless defined( $filename ) && -f $filename; - return $package->_init( undef, $filename, @_ ); + return $class->_init(undef, $filename, @_); } sub new_from_module { - my $package = shift; + my $class = shift; my $module = shift; my %props = @_; + $props{inc} ||= \@INC; - my $filename = $package->find_module_by_name( $module, $props{inc} ); + my $filename = $class->find_module_by_name( $module, $props{inc} ); return undef unless defined( $filename ) && -f $filename; - return $package->_init( $module, $filename, %props ); + return $class->_init($module, $filename, %props); } sub _init { - my $package = shift; + my $class = shift; my $module = shift; my $filename = shift; - my %props = @_; + my( %valid_props, @valid_props ); @valid_props = qw( collect_pod inc ); @valid_props{@valid_props} = delete( @props{@valid_props} ); warn "Unknown properties: @{[keys %props]}\n" if scalar( %props ); my %data = ( - module => $module, - filename => $filename, - version => undef, - packages => [], - versions => {}, + module => $module, + filename => $filename, + version => undef, + packages => [], + versions => {}, pod => {}, pod_headings => [], collect_pod => 0, @@ -86,20 +90,22 @@ sub _init { %valid_props, ); - my $self = bless( \%data, $package ); + my $self = bless(\%data, $class); $self->_parse_file(); - unless ( $self->{module} && length( $self->{module} ) ) { - my( $v, $d, $f ) = File::Spec->splitpath( $self->{filename} ); - if ( $f =~ /\.pm$/ ) { + unless($self->{module} and length($self->{module})) { + my ($v, $d, $f) = File::Spec->splitpath($self->{filename}); + if($f =~ /\.pm$/) { $f =~ s/\..+$//; my @candidates = grep /$f$/, @{$self->{packages}}; - $self->{module} = shift( @candidates ); # punt - } else { - if ( grep /main/, @{$self->{packages}} ) { - $self->{module} = 'main'; - } else { + $self->{module} = shift(@candidates); # punt + } + else { + if(grep /main/, @{$self->{packages}}) { + $self->{module} = 'main'; + } + else { $self->{module} = $self->{packages}[0] || ''; } } @@ -113,7 +119,7 @@ sub _init { # class method sub _do_find_module { - my $package = shift; + my $class = shift; my $module = shift || die 'find_module_by_name() requires a package name'; my $dirs = shift || \@INC; @@ -179,6 +185,7 @@ sub _parse_fh { my $pod_data = ''; while (defined( my $line = <$fh> )) { + my $line_num = $.; chomp( $line ); next if $line =~ /^\s*#/; @@ -233,7 +240,7 @@ sub _parse_fh { # that we should watch out for...) warn <<"EOM" unless $line =~ /=\s*eval/; Package '$vers_pkg' already declared with version '$vers{$vers_pkg}', -ignoring subsequent declaration. +ignoring subsequent declaration on line $line_num. EOM } @@ -263,7 +270,7 @@ EOM } else { warn <<"EOM"; Package '$pkg' already declared with version '$vers{$pkg}' -ignoring new version '$v'. +ignoring new version '$v' on line $line_num. EOM } @@ -283,6 +290,8 @@ EOM $self->{pod_headings} = \@pod; } +{ +my $pn = 0; sub _evaluate_version_line { my $self = shift; my( $sigil, $var, $line ) = @_; @@ -292,8 +301,10 @@ sub _evaluate_version_line { # We compile into $vsub because 'use version' would cause # compiletime/runtime issues with local() my $vsub; + $pn++; # everybody gets their own package my $eval = qq{BEGIN { q# Hide from _packages_inside() - #; package Module::Build::ModuleInfo::_version; + #; package Module::Build::ModuleInfo::_version::p$pn; + use Module::Build::Version; no strict; local $sigil$var; @@ -311,13 +322,16 @@ sub _evaluate_version_line { if $@; (ref($vsub) eq 'CODE') or die "failed to build version sub for $self->{filename}"; - my $result = $vsub->(); + my $result = eval { $vsub->() }; + + die "Could not get version from $self->{filename} by executing:\n$eval\n\nThe fatal error was: $@\n" if $@; # Bless it into our own version class $result = Module::Build::Version->new($result); return $result; } +} ############################################################ diff --git a/lib/Module/Build/Notes.pm b/lib/Module/Build/Notes.pm index 8afdd8c..056ac4d 100644 --- a/lib/Module/Build/Notes.pm +++ b/lib/Module/Build/Notes.pm @@ -4,7 +4,7 @@ package Module::Build::Notes; use strict; use vars qw($VERSION); -$VERSION = '0.2808_01'; +$VERSION = '0.30'; $VERSION = eval $VERSION; use Data::Dumper; use IO::File; diff --git a/lib/Module/Build/PPMMaker.pm b/lib/Module/Build/PPMMaker.pm index f4b2cd8..bf6715c 100644 --- a/lib/Module/Build/PPMMaker.pm +++ b/lib/Module/Build/PPMMaker.pm @@ -2,7 +2,7 @@ package Module::Build::PPMMaker; use strict; use vars qw($VERSION); -$VERSION = '0.2808_01'; +$VERSION = '0.30'; $VERSION = eval $VERSION; # This code is mostly borrowed from ExtUtils::MM_Unix 6.10_03, with a diff --git a/lib/Module/Build/Platform/Amiga.pm b/lib/Module/Build/Platform/Amiga.pm index d437560..a74c173 100644 --- a/lib/Module/Build/Platform/Amiga.pm +++ b/lib/Module/Build/Platform/Amiga.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::Amiga; use strict; use vars qw($VERSION); -$VERSION = '0.2808_01'; +$VERSION = '0.30'; $VERSION = eval $VERSION; use Module::Build::Base; diff --git a/lib/Module/Build/Platform/Default.pm b/lib/Module/Build/Platform/Default.pm index 1fc3415..a8e9dce 100644 --- a/lib/Module/Build/Platform/Default.pm +++ b/lib/Module/Build/Platform/Default.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::Default; use strict; use vars qw($VERSION); -$VERSION = '0.2808_01'; +$VERSION = '0.30'; $VERSION = eval $VERSION; use Module::Build::Base; diff --git a/lib/Module/Build/Platform/EBCDIC.pm b/lib/Module/Build/Platform/EBCDIC.pm index da5b75c..63b9bfd 100644 --- a/lib/Module/Build/Platform/EBCDIC.pm +++ b/lib/Module/Build/Platform/EBCDIC.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::EBCDIC; use strict; use vars qw($VERSION); -$VERSION = '0.2808_01'; +$VERSION = '0.30'; $VERSION = eval $VERSION; use Module::Build::Base; diff --git a/lib/Module/Build/Platform/MPEiX.pm b/lib/Module/Build/Platform/MPEiX.pm index 6706484..b548e06 100644 --- a/lib/Module/Build/Platform/MPEiX.pm +++ b/lib/Module/Build/Platform/MPEiX.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::MPEiX; use strict; use vars qw($VERSION); -$VERSION = '0.2808_01'; +$VERSION = '0.30'; $VERSION = eval $VERSION; use Module::Build::Base; diff --git a/lib/Module/Build/Platform/MacOS.pm b/lib/Module/Build/Platform/MacOS.pm index 9cd7b8f..6ad7be3 100644 --- a/lib/Module/Build/Platform/MacOS.pm +++ b/lib/Module/Build/Platform/MacOS.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::MacOS; use strict; use vars qw($VERSION); -$VERSION = '0.2808_01'; +$VERSION = '0.30'; $VERSION = eval $VERSION; use Module::Build::Base; use vars qw(@ISA); diff --git a/lib/Module/Build/Platform/RiscOS.pm b/lib/Module/Build/Platform/RiscOS.pm index 8883e20..faeac89 100644 --- a/lib/Module/Build/Platform/RiscOS.pm +++ b/lib/Module/Build/Platform/RiscOS.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::RiscOS; use strict; use vars qw($VERSION); -$VERSION = '0.2808_01'; +$VERSION = '0.30'; $VERSION = eval $VERSION; use Module::Build::Base; diff --git a/lib/Module/Build/Platform/Unix.pm b/lib/Module/Build/Platform/Unix.pm index e5fa17c..5e67436 100644 --- a/lib/Module/Build/Platform/Unix.pm +++ b/lib/Module/Build/Platform/Unix.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::Unix; use strict; use vars qw($VERSION); -$VERSION = '0.2808_01'; +$VERSION = '0.30'; $VERSION = eval $VERSION; use Module::Build::Base; @@ -44,7 +44,7 @@ sub _construct { sub _detildefy { my ($self, $value) = @_; - $value =~ s[^~(\w*)(?=/|$)] # tilde with optional username + $value =~ s[^~(\w[-\w]*)?(?=/|$)] # tilde with optional username [$1 ? ((getpwnam $1)[7] || "~$1") : (getpwuid $>)[7] diff --git a/lib/Module/Build/Platform/VMS.pm b/lib/Module/Build/Platform/VMS.pm index ed0a682..85320e7 100644 --- a/lib/Module/Build/Platform/VMS.pm +++ b/lib/Module/Build/Platform/VMS.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::VMS; use strict; use vars qw($VERSION); -$VERSION = '0.2808_01'; +$VERSION = '0.30'; $VERSION = eval $VERSION; use Module::Build::Base; @@ -136,10 +136,15 @@ sub _quote_args { ? 1 : 0; - map { $_ = q(").$_.q(") if !/^\"/ && length($_) > 0 } - ($got_arrayref ? @{$args[0]} - : @args - ); + # Do not quote qualifiers that begin with '/'. + map { if (!/^\//) { + $_ =~ s/\"/""/g; # escape C<"> by doubling + $_ = q(").$_.q("); + } + } + ($got_arrayref ? @{$args[0]} + : @args + ); return $got_arrayref ? $args[0] : join(' ', @args); @@ -357,6 +362,29 @@ lossy. sub find_perl_interpreter { return $^X; } +=item localize_file_path + +Convert the file path to the local syntax + +=cut + +sub localize_file_path { + my ($self, $path) = @_; + $path =~ s/\.\z//; + return VMS::Filespec::vmsify($path); +} + +=item localize_dir_path + +Convert the directory path to the local syntax + +=cut + +sub localize_dir_path { + my ($self, $path) = @_; + return VMS::Filespec::vmspath($path); +} + =back =head1 AUTHOR diff --git a/lib/Module/Build/Platform/VOS.pm b/lib/Module/Build/Platform/VOS.pm index a3e5c8e..befec9d 100644 --- a/lib/Module/Build/Platform/VOS.pm +++ b/lib/Module/Build/Platform/VOS.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::VOS; use strict; use vars qw($VERSION); -$VERSION = '0.2808_01'; +$VERSION = '0.30'; $VERSION = eval $VERSION; use Module::Build::Base; diff --git a/lib/Module/Build/Platform/Windows.pm b/lib/Module/Build/Platform/Windows.pm index 2ac4322..7cdb560 100644 --- a/lib/Module/Build/Platform/Windows.pm +++ b/lib/Module/Build/Platform/Windows.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::Windows; use strict; use vars qw($VERSION); -$VERSION = '0.2808_01'; +$VERSION = '0.30'; $VERSION = eval $VERSION; use Config; @@ -175,6 +175,29 @@ EOT } +sub _quote_args { + # Returns a string that can become [part of] a command line with + # proper quoting so that the subprocess sees this same list of args. + my ($self, @args) = @_; + + my @quoted; + + for (@args) { + if ( /^[^\s*?!\$<>;|'"\[\]\{\}]+$/ ) { + # Looks pretty safe + push @quoted, $_; + } else { + # XXX this will obviously have to improve - is there already a + # core module lying around that does proper quoting? + s/"/\\"/g; + push @quoted, qq("$_"); + } + } + + return join " ", @quoted; +} + + sub split_like_shell { # As it turns out, Windows command-parsing is very different from # Unix command-parsing. Double-quotes mean different things, @@ -233,6 +256,23 @@ sub split_like_shell { return @argv; } + +# system(@cmd) does not like having double-quotes in it on Windows. +# So we quote them and run it as a single command. +sub do_system { + my ($self, @cmd) = @_; + + my $cmd = $self->_quote_args(@cmd); + my $status = system($cmd); + if ($status and $! =~ /Argument list too long/i) { + my $env_entries = ''; + foreach (sort keys %ENV) { $env_entries .= "$_=>".length($ENV{$_})."; " } + warn "'Argument list' was 'too long', env lengths are $env_entries"; + } + return !$status; +} + + 1; __END__ diff --git a/lib/Module/Build/Platform/aix.pm b/lib/Module/Build/Platform/aix.pm index 36257a7..b521a65 100644 --- a/lib/Module/Build/Platform/aix.pm +++ b/lib/Module/Build/Platform/aix.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::aix; use strict; use vars qw($VERSION); -$VERSION = '0.2808_01'; +$VERSION = '0.30'; $VERSION = eval $VERSION; use Module::Build::Platform::Unix; diff --git a/lib/Module/Build/Platform/cygwin.pm b/lib/Module/Build/Platform/cygwin.pm index 71d465f..56b600f 100644 --- a/lib/Module/Build/Platform/cygwin.pm +++ b/lib/Module/Build/Platform/cygwin.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::cygwin; use strict; use vars qw($VERSION); -$VERSION = '0.2808_01'; +$VERSION = '0.30'; $VERSION = eval $VERSION; use Module::Build::Platform::Unix; diff --git a/lib/Module/Build/Platform/darwin.pm b/lib/Module/Build/Platform/darwin.pm index 60df8c4..aee1773 100644 --- a/lib/Module/Build/Platform/darwin.pm +++ b/lib/Module/Build/Platform/darwin.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::darwin; use strict; use vars qw($VERSION); -$VERSION = '0.2808_01'; +$VERSION = '0.30'; $VERSION = eval $VERSION; use Module::Build::Platform::Unix; diff --git a/lib/Module/Build/Platform/os2.pm b/lib/Module/Build/Platform/os2.pm index 1b8ca0c..035cc9a 100644 --- a/lib/Module/Build/Platform/os2.pm +++ b/lib/Module/Build/Platform/os2.pm @@ -2,7 +2,7 @@ package Module::Build::Platform::os2; use strict; use vars qw($VERSION); -$VERSION = '0.2808_01'; +$VERSION = '0.30'; $VERSION = eval $VERSION; use Module::Build::Platform::Unix; diff --git a/lib/Module/Build/PodParser.pm b/lib/Module/Build/PodParser.pm index 53a191e..58301d7 100644 --- a/lib/Module/Build/PodParser.pm +++ b/lib/Module/Build/PodParser.pm @@ -2,7 +2,7 @@ package Module::Build::PodParser; use strict; use vars qw($VERSION); -$VERSION = '0.2808_01'; +$VERSION = '0.30'; $VERSION = eval $VERSION; use vars qw(@ISA); diff --git a/lib/Module/Build/Version.pm b/lib/Module/Build/Version.pm index 5ba357b..f85d0d9 100644 --- a/lib/Module/Build/Version.pm +++ b/lib/Module/Build/Version.pm @@ -2,7 +2,7 @@ package Module::Build::Version; use strict; use vars qw($VERSION); -$VERSION = 0.7203; +$VERSION = 0.74; eval "use version $VERSION"; if ($@) { # can't locate version files, use our own @@ -69,13 +69,12 @@ sub import { 1; # replace everything from here to the end with the current version/vpp.pm - package version::vpp; use strict; use locale; use vars qw ($VERSION @ISA @REGEXS); -$VERSION = 0.7203; +$VERSION = 0.74; push @REGEXS, qr/ ^v? # optional leading 'v' @@ -93,6 +92,17 @@ use overload ( 'nomethod' => \&vnoop, ); +my $VERSION_MAX = 0x7FFFFFFF; + +eval "use warnings"; +if ($@) { + eval ' + package warnings; + sub enabled {return $^W;} + 1; + '; +} + sub new { my ($class, $value) = @_; @@ -145,6 +155,7 @@ sub new my $alpha = 0; my $width = 3; my $saw_period = 0; + my $vinf = 0; my ($start, $last, $pos, $s); $s = 0; @@ -163,9 +174,8 @@ sub new while ( substr($value,$pos,1) =~ /[._\d]/ ) { if ( substr($value,$pos,1) eq '.' ) { if ($alpha) { - require Carp; Carp::croak("Invalid version format ". - "(underscores before decimal)"); + "(underscores before decimal)"); } $saw_period++; $last = $pos; @@ -174,7 +184,7 @@ sub new if ($alpha) { require Carp; Carp::croak("Invalid version format ". - "(multiple underscores)"); + "(multiple underscores)"); } $alpha = 1; $width = $pos - $last - 1; # natural width of sub-version @@ -184,18 +194,21 @@ sub new if ( $alpha && !$saw_period ) { require Carp; - Carp::croak("Invalid version format (alpha without decimal)"); + Carp::croak("Invalid version format ". + "(alpha without decimal)"); } if ( $alpha && $saw_period && $width == 0 ) { require Carp; - Carp::croak("Invalid version format (misplaced _ in number)"); + Carp::croak("Invalid version format ". + "(misplaced _ in number)"); } if ( $saw_period > 1 ) { $qv = 1; # force quoted version processing } + $last = $pos; $pos = $s; if ( $qv ) { @@ -235,9 +248,14 @@ sub new $orev = $rev; $rev += substr($value,$s,1) * $mult; $mult /= 10; - if ( abs($orev) > abs($rev) ) { - require Carp; - Carp::croak("Integer overflow in version"); + if ( abs($orev) > abs($rev) + || abs($rev) > abs($VERSION_MAX) ) { + if ( warnings::enabled("overflow") ) { + require Carp; + Carp::carp("Integer overflow in version"); + } + $s = $end - 1; + $rev = $VERSION_MAX; } $s++; if ( substr($value,$s,1) eq '_' ) { @@ -250,9 +268,14 @@ sub new $orev = $rev; $rev += substr($value,$end,1) * $mult; $mult *= 10; - if ( abs($orev) > abs($rev) ) { - require Carp; - Carp::croak("Integer overflow in version"); + if ( abs($orev) > abs($rev) + || abs($rev) > abs($VERSION_MAX) ) { + if ( warnings::enabled("overflow") ) { + require Carp; + Carp::carp("Integer overflow in version"); + } + $end = $s - 1; + $rev = $VERSION_MAX; } } } @@ -300,12 +323,21 @@ sub new } if ( substr($value,$pos) ) { # any remaining text - warn "Version string '$value' contains invalid data; ". - "ignoring: '".substr($value,$pos)."'"; + if ( warnings::enabled("misc") ) { + require Carp; + Carp::carp("Version string '$value' contains invalid data; ". + "ignoring: '".substr($value,$pos)."'"); + } } # cache the original value for use when stringification - $self->{original} = substr($value,0,$pos); + if ( $vinf ) { + $self->{vinf} = 1; + $self->{original} = 'v.Inf'; + } + else { + $self->{original} = substr($value,0,$pos); + } return ($self); } diff --git a/lib/Module/Build/YAML.pm b/lib/Module/Build/YAML.pm index 2106308..3515432 100644 --- a/lib/Module/Build/YAML.pm +++ b/lib/Module/Build/YAML.pm @@ -1,7 +1,6 @@ package Module::Build::YAML; use strict; - use vars qw($VERSION @EXPORT @EXPORT_OK); $VERSION = "0.50"; @EXPORT = (); diff --git a/lib/Module/Build/t/basic.t b/lib/Module/Build/t/basic.t index a1adaa7..284fcae 100644 --- a/lib/Module/Build/t/basic.t +++ b/lib/Module/Build/t/basic.t @@ -4,27 +4,20 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; use MBTest tests => 52; -use Cwd (); -my $cwd = Cwd::cwd; +use_ok 'Module::Build'; +ensure_blib('Module::Build'); + my $tmp = MBTest->tmpdir; use DistGen; my $dist = DistGen->new( dir => $tmp ); $dist->regen; -chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; +$dist->chdir_in; ######################### -use_ok 'Module::Build'; - -SKIP: { - skip "no blib in core", 1 if $ENV{PERL_CORE}; - like $INC{'Module/Build.pm'}, qr/\bblib\b/, "Make sure Module::Build was loaded from blib/"; -} - - # Test object creation { my $mb = Module::Build->new( module_name => $dist->name ); @@ -112,7 +105,7 @@ SKIP: { $mb->add_to_cleanup('save_out'); # Use uc() so we don't confuse the current test output like uc(stdout_of( sub {$mb->dispatch('test', verbose => 1)} )), qr/^OK \d/m; - like uc(stdout_of( sub {$mb->dispatch('test', verbose => 0)} )), qr/\.\.OK/; + like uc(stdout_of( sub {$mb->dispatch('test', verbose => 0)} )), qr/\.\. ?OK/; $mb->dispatch('realclean'); $dist->clean; @@ -170,11 +163,10 @@ SKIP: { is $args{foo}, 1; # revert test distribution to pristine state because we modified a file - chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; $dist->remove; $dist = DistGen->new( dir => $tmp ); $dist->regen; - chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; + $dist->chdir_in; } # Test author stuff @@ -213,8 +205,4 @@ SKIP: { # cleanup -chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; $dist->remove; - -use File::Path; -rmtree( $tmp ); diff --git a/lib/Module/Build/t/compat.t b/lib/Module/Build/t/compat.t index 2d70e98..1f35a27 100644 --- a/lib/Module/Build/t/compat.t +++ b/lib/Module/Build/t/compat.t @@ -13,19 +13,24 @@ local @ENV{@makefile_keys}; delete @ENV{@makefile_keys}; my @makefile_types = qw(small passthrough traditional); -my $tests_per_type = 14; -if ( $Config{make} && find_in_path($Config{make}) ) { - plan tests => 38 + @makefile_types*$tests_per_type*2; +my $tests_per_type = 15; + +#find_in_path does not understand VMS. + +if ( $Config{make} && $^O ne 'VMS' ? find_in_path($Config{make}) : 1 ) { + plan tests => 34 + @makefile_types*$tests_per_type*2; } else { plan skip_all => "Don't know how to invoke 'make'"; } -ok 1, "Loaded"; + +my $is_vms_mms = ($^O eq 'VMS') && ($Config{make} =~ /MM[SK]/i); + +use_ok 'Module::Build'; +ensure_blib('Module::Build'); ######################### -use Cwd (); -my $cwd = Cwd::cwd; my $tmp = MBTest->tmpdir; # Create test distribution; set requires and build_requires @@ -33,7 +38,7 @@ use DistGen; my $dist = DistGen->new( dir => $tmp ); $dist->regen; -chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; +$dist->chdir_in; ######################### @@ -45,6 +50,14 @@ use Carp; $SIG{__WARN__} = \&Carp::cluck; my @make = $Config{make} eq 'nmake' ? ('nmake', '-nologo') : ($Config{make}); +my $makefile = 'Makefile'; + +# VMS MMK/MMS by convention use Descrip.MMS +if ($is_vms_mms) { + $makefile = 'Descrip.MMS'; +} + + ######################### # Test without requires @@ -95,7 +108,8 @@ ok $mb, "Module::Build->new_from_context"; # in older-generated Makefile.PLs my $warning = ''; local $SIG{__WARN__} = sub { $warning = shift; }; - my $maketext = eval { Module::Build::Compat->fake_makefile(makefile => 'Makefile') }; + + my $maketext = eval { Module::Build::Compat->fake_makefile(makefile => $makefile) }; is $@, '', "fake_makefile lived"; like $maketext, qr/^realclean/m, "found 'realclean' in fake_makefile output"; like $warning, qr/build_class/, "saw warning about 'build_class'"; @@ -142,7 +156,7 @@ ok $mb, "Module::Build->new_from_context"; # Make sure various Makefile.PL arguments are supported Module::Build::Compat->create_makefile_pl('passthrough', $mb); - my $libdir = File::Spec->catdir( $cwd, 't', 'libdir' ); + my $libdir = File::Spec->catdir( $tmp, 'libdir' ); my $result; stdout_of( sub { $result = $mb->run_perl_script('Makefile.PL', [], @@ -171,21 +185,49 @@ ok $mb, "Module::Build->new_from_context"; like $output, qr/(?:# ok \d+\s+)+/, 'Should be verbose'; # Make sure various Makefile arguments are supported - $output = stdout_of( sub { $ran_ok = $mb->do_system(@make, 'test', 'TEST_VERBOSE=0') } ); + my $make_macro = 'TEST_VERBOSE=0'; + + # VMS MMK/MMS macros use different syntax. + if ($is_vms_mms) { + $make_macro = '/macro=("' . $make_macro . '")'; + } + + $output = stdout_of( sub { + $ran_ok = $mb->do_system(@make, 'test', $make_macro) + } ); + ok $ran_ok, "make test without verbose ran ok"; $output =~ s/^/# /gm; # Don't confuse our own test output like $output, - qr/(?:# .+basic\.+ok\s+(?:[\d.]+\s*m?s\s*)?(?:# \[[\d:]+\]\s*)?)# All tests/, - 'Should be non-verbose'; + qr/# .+basic(\.t)?[.\s#]+ok[.\s#]+All tests successful/, + 'Should be non-verbose'; - $mb->delete_filetree($libdir); - ok ! -e $libdir, "Sample installation directory should be cleaned up"; + (my $libdir2 = $libdir) =~ s/libdir/lbiidr/; + my @make_args = ('INSTALLDIRS=vendor', "INSTALLVENDORLIB=$libdir2"); + + if ($is_vms_mms) { # VMS MMK/MMS macros use different syntax. + $make_args[0] = '/macro=("' . join('","',@make_args) . '")'; + pop @make_args while scalar(@make_args) > 1; + } + ($output) = stdout_stderr_of( + sub { + $ran_ok = $mb->do_system(@make, 'fakeinstall', @make_args); + } + ); + + ok $ran_ok, "make fakeinstall with INSTALLDIRS=vendor ran ok"; + $output =~ s/^/# /gm; # Don't confuse our own test output + like $output, + qr/\Q$libdir2\E .* Simple\.pm/x, + 'Should have installdirs=vendor'; stdout_of( sub { $mb->do_system(@make, 'realclean'); } ); - ok ! -e 'Makefile', "Makefile shouldn't exist"; + ok ! -e $makefile, "$makefile shouldn't exist"; 1 while unlink 'Makefile.PL'; ok ! -e 'Makefile.PL', "Makefile.PL cleaned up"; + + 1 while unlink $libdir, $libdir2; } { # Make sure tilde-expansion works @@ -203,12 +245,15 @@ ok $mb, "Module::Build->new_from_context"; unlike $b2->install_base, qr/^~/, "Tildes should be expanded"; stdout_of( sub { $mb->do_system(@make, 'realclean'); } ); - ok ! -e 'Makefile', "Makefile shouldn't exist"; + ok ! -e $makefile, "$makefile shouldn't exist"; 1 while unlink 'Makefile.PL'; ok ! -e 'Makefile.PL', "Makefile.PL cleaned up"; } +# cleanup +$dist->remove; + ######################################################### sub test_makefile_types { @@ -270,13 +315,13 @@ sub test_makefile_creation { $label .= " (postargs: $postargs)"; } ok $result, $label; - ok -e 'Makefile', "Makefile exists"; + ok -e $makefile, "$makefile exists"; if ($cleanup) { $output = stdout_of( sub { $build->do_system(@make, 'realclean'); }); - ok ! -e 'Makefile', "Makefile cleaned up"; + ok ! -e '$makefile', "$makefile cleaned up"; } else { pass '(skipping cleanup)'; # keep test count constant @@ -287,10 +332,10 @@ sub test_makefile_prereq_pm { my %requires = %{ $_[0] }; delete $requires{perl}; # until EU::MM supports this SKIP: { - skip 'Makefile not found', 1 unless -e 'Makefile'; + skip "$makefile not found", 1 unless -e $makefile; my $prereq_pm = find_makefile_prereq_pm(); is_deeply $prereq_pm, \%requires, - "Makefile has correct PREREQ_PM line"; + "$makefile has correct PREREQ_PM line"; } } @@ -313,8 +358,8 @@ sub test_makefile_pl_requires_perl { # Following subroutine adapted from code in CPAN.pm # by Andreas Koenig and A. Speer. sub find_makefile_prereq_pm { - my $fh = IO::File->new( 'Makefile', 'r' ) - or die "Can't read Makefile: $!"; + my $fh = IO::File->new( $makefile, 'r' ) + or die "Can't read $makefile: $!"; my $req = {}; local($/) = "\n"; while (<$fh>) { @@ -337,10 +382,3 @@ sub find_makefile_prereq_pm { } return $req; } - -# cleanup -chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; -$dist->remove; - -use File::Path; -rmtree( $tmp ); diff --git a/lib/Module/Build/t/destinations.t b/lib/Module/Build/t/destinations.t index b28abf5..5319afd 100644 --- a/lib/Module/Build/t/destinations.t +++ b/lib/Module/Build/t/destinations.t @@ -2,17 +2,18 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; -use MBTest tests => 113; +use MBTest tests => 115; + +use_ok 'Module::Build'; +ensure_blib('Module::Build'); -use Cwd (); -my $cwd = Cwd::cwd; my $tmp = MBTest->tmpdir; use DistGen; my $dist = DistGen->new( dir => $tmp ); $dist->regen; -chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; +$dist->chdir_in; use Config; @@ -23,7 +24,6 @@ use File::Spec::Functions qw( catdir splitdir splitpath ); # We need to create a well defined environment to test install paths. # We do this by setting up appropriate Config entries. -use Module::Build; my @installstyle = qw(lib perl5); my $mb = Module::Build->new_from_context( installdirs => 'site', @@ -321,8 +321,4 @@ sub test_install_destinations { } -chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; $dist->remove; - -use File::Path; -rmtree( $tmp ); diff --git a/lib/Module/Build/t/ext.t b/lib/Module/Build/t/ext.t index cbe2190..faa392b 100644 --- a/lib/Module/Build/t/ext.t +++ b/lib/Module/Build/t/ext.t @@ -4,10 +4,15 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; use MBTest; +use Module::Build; + my @unix_splits = ( { q{one t'wo th'ree f"o\"ur " "five" } => [ 'one', 'two three', 'fo"ur ', 'five' ] }, { q{ foo bar } => [ 'foo', 'bar' ] }, + { q{ D\'oh f\{g\'h\"i\]\* } => [ "D'oh", "f{g'h\"i]*" ] }, + { q{ D\$foo } => [ 'D$foo' ] }, + { qq{one\\\ntwo} => [ "one\ntwo" ] }, # TODO ); my @win_splits = @@ -53,12 +58,11 @@ my @win_splits = { 'a " b " c' => [ 'a', ' b ', 'c' ] }, ); -plan tests => 10 + 2*@unix_splits + 2*@win_splits; +plan tests => 10 + 4*@unix_splits + 4*@win_splits; -######################### +ensure_blib('Module::Build'); -use Module::Build; -ok(1); +######################### # Should always return an array unscathed foreach my $platform ('', '::Platform::Unix', '::Platform::Windows') { @@ -68,8 +72,13 @@ foreach my $platform ('', '::Platform::Unix', '::Platform::Windows') { is "@result", "foo bar baz", "Split using $pkg"; } +# I think 3.24 isn't actually the majik version, my 3.23 seems to pass... +my $low_TPW_version = Text::ParseWords->VERSION < 3.24; use Module::Build::Platform::Unix; foreach my $test (@unix_splits) { + # Text::ParseWords bug: + local $TODO = $low_TPW_version && ((keys %$test)[0] =~ m{\\\n}); + do_split_tests('Module::Build::Platform::Unix', $test); } @@ -94,11 +103,41 @@ foreach my $test (@win_splits) { } { + # Make sure data can make a round-trip through an external perl + # process, which can involve the shell command line + + # Holy crap, I can't believe this works: + local $Module::Build{properties}{quiet} = 1; + + my @data = map values(%$_), @unix_splits, @win_splits; + for my $d (@data) { + my $out = stdout_of + ( sub { + Module::Build->run_perl_script('-le', [], ['print join " ", map "{$_}", @ARGV', @$d]); + } ); + chomp $out; + is($out, join(' ', map "{$_}", @$d), "perl round trip for ".join('',map "{$_}", @$d)); + } +} + +{ + # Make sure data can make a round-trip through an external backtick + # process, which can involve the shell command line + + local $Module::Build{properties}{quiet} = 1; + my @data = map values(%$_), @unix_splits, @win_splits; + for my $d (@data) { + chomp(my $out = Module::Build->_backticks('perl', '-le', 'print join " ", map "{$_}", @ARGV', @$d)); + is($out, join(' ', map "{$_}", @$d), "backticks round trip for ".join('',map "{$_}", @$d)); + } +} + +{ # Make sure run_perl_script() propagates @INC my $dir = 'whosiewhatzit'; mkdir $dir, 0777; local @INC = ($dir, @INC); - my $output = stdout_of( sub { Module::Build->run_perl_script('', ['-le', 'print for @INC']) } ); + my $output = stdout_of( sub { Module::Build->run_perl_script('-le', [], ['print for @INC']) } ); like $output, qr{^$dir}m; rmdir $dir; } @@ -112,5 +151,7 @@ sub do_split_tests { is( 0 + grep( !defined(), @result ), # all defined 0, "'$string' result all defined" ); - is_deeply(\@result, $expected); + is_deeply(\@result, $expected) or + diag("$package split_like_shell error \n" . + ">$string< is not splitting as >" . join("|", @$expected) . '<'); } diff --git a/lib/Module/Build/t/extend.t b/lib/Module/Build/t/extend.t index a6e27e4..4c96421 100644 --- a/lib/Module/Build/t/extend.t +++ b/lib/Module/Build/t/extend.t @@ -2,23 +2,21 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; -use MBTest tests => 65; +use MBTest tests => 66; + +use_ok 'Module::Build'; +ensure_blib('Module::Build'); -use Cwd (); -my $cwd = Cwd::cwd; my $tmp = MBTest->tmpdir; use DistGen; my $dist = DistGen->new( dir => $tmp ); $dist->regen; -chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; +$dist->chdir_in; ######################### -use Module::Build; -ok 1; - # Here we make sure actions are only called once per dispatch() $::x = 0; my $mb = Module::Build->subclass @@ -276,8 +274,4 @@ print "Hello, World!\n"; } # cleanup -chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; $dist->remove; - -use File::Path; -rmtree( $tmp ); diff --git a/lib/Module/Build/t/files.t b/lib/Module/Build/t/files.t index eac96b7..fde77cf 100644 --- a/lib/Module/Build/t/files.t +++ b/lib/Module/Build/t/files.t @@ -2,23 +2,22 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; -use MBTest tests => 6; +use MBTest tests => 8; -use Cwd (); -my $cwd = Cwd::cwd; +use_ok 'Module::Build'; +ensure_blib('Module::Build'); + +use IO::File; my $tmp = MBTest->tmpdir; use DistGen; my $dist = DistGen->new( dir => $tmp ); $dist->regen; -chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; +$dist->chdir_in; -use IO::File; - -use Module::Build; my $mb = Module::Build->new_from_context; my @files; @@ -60,8 +59,4 @@ my @files; } # cleanup -chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; $dist->remove; - -use File::Path; -rmtree( $tmp ); diff --git a/lib/Module/Build/t/help.t b/lib/Module/Build/t/help.t index ef43e12..18fb082 100644 --- a/lib/Module/Build/t/help.t +++ b/lib/Module/Build/t/help.t @@ -2,7 +2,10 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; -use MBTest 'no_plan';#tests => 0; +use MBTest tests => 25; + +use_ok 'Module::Build'; +ensure_blib('Module::Build'); use Cwd (); use File::Path (); @@ -31,8 +34,6 @@ my $restart = sub { chdir($dist->dirname) or die "Can't chdir to '@{[$dist->dirname]}': $!"; -use_ok 'Module::Build'; - ######################################################################## { # check the =item style my $mb = Module::Build->subclass( diff --git a/lib/Module/Build/t/install.t b/lib/Module/Build/t/install.t index 42fafc5..317ca8b 100644 --- a/lib/Module/Build/t/install.t +++ b/lib/Module/Build/t/install.t @@ -2,8 +2,12 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; -use MBTest tests => 34; +use MBTest tests => 36; +use_ok 'Module::Build'; +ensure_blib('Module::Build'); + +use Config; use Cwd (); my $cwd = Cwd::cwd; my $tmp = MBTest->tmpdir; @@ -11,14 +15,10 @@ my $tmp = MBTest->tmpdir; use DistGen; my $dist = DistGen->new( dir => $tmp ); $dist->regen; - -chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; +$dist->chdir_in; ######################### -use Module::Build; -use Config; - $dist->add_file( 'script', <<'---' ); #!perl -w @@ -225,11 +225,10 @@ Simple Man is keys %$pms, 0; # revert to pristine state - chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; $dist->remove; $dist = DistGen->new( dir => $tmp ); $dist->regen; - chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; + $dist->chdir_in; } sub strip_volume { @@ -246,8 +245,4 @@ sub file_exists { # cleanup -chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; $dist->remove; - -use File::Path; -rmtree( $tmp ); diff --git a/lib/Module/Build/t/lib/DistGen.pm b/lib/Module/Build/t/lib/DistGen.pm index 380db1a..e1e51f9 100644 --- a/lib/Module/Build/t/lib/DistGen.pm +++ b/lib/Module/Build/t/lib/DistGen.pm @@ -8,6 +8,8 @@ $VERSION = '0.01'; $VERBOSE = 0; +use Carp; + use Cwd (); use File::Basename (); use File::Find (); @@ -18,11 +20,11 @@ use Tie::CPHash; use Data::Dumper; BEGIN { - if( $^O eq 'VMS' ) { - # For things like vmsify() - require VMS::Filespec; - VMS::Filespec->import; - } + if( $^O eq 'VMS' ) { + # For things like vmsify() + require VMS::Filespec; + VMS::Filespec->import; + } } BEGIN { require Exporter; @@ -32,6 +34,16 @@ BEGIN { ); } +sub undent { + my ($string) = @_; + + my ($space) = $string =~ m/^(\s+)/; + $string =~ s/^$space//gm; + + return($string); +} +######################################################################## + sub new { my $package = shift; my %options = @_; @@ -46,6 +58,9 @@ sub new { ); my $self = bless( \%data, $package ); + # So we can clean up later even if the caller chdir()s + $self->{dir} = File::Spec->rel2abs($self->{dir}); + tie %{$self->{filedata}}, 'Tie::CPHash'; tie %{$self->{pending}{change}}, 'Tie::CPHash'; @@ -60,16 +75,6 @@ sub new { return $self; } -# not a method -sub undent { - my ($string) = @_; - - my ($space) = $string =~ m/^(\s+)/; - $string =~ s/^$space//gm; - - return($string); -} - sub _gen_default_filedata { my $self = shift; @@ -195,6 +200,11 @@ sub _gen_default_filedata { RETVAL --- + # 5.6 is missing const char * in its typemap + $self->$add_unless('typemap', undent(<<" ---")); + const char * T_PV + --- + $self->$add_unless('t/basic.t', undent(<<" ---")); use Test::More tests => 2; use strict; @@ -358,7 +368,11 @@ sub clean { sub remove { my $self = shift; - File::Path::rmtree( File::Spec->canonpath($self->dirname) ); + croak("invalid usage -- remove()") if(@_); + $self->chdir_original if($self->did_chdir); + File::Path::rmtree( $self->dirname ); + # might as well check + croak("\nthis test should have used chdir_in()") unless(Cwd::getcwd); } sub revert { @@ -405,6 +419,31 @@ sub change_file { $self->{pending}{change}{$file} = 1; } +sub chdir_in { + my $self = shift; + + $self->{original_dir} ||= Cwd::cwd; # only once + my $dir = $self->dirname; + chdir($dir) or die "Can't chdir to '$dir': $!"; +} +######################################################################## + +sub did_chdir { + my $self = shift; + + return exists($self->{original_dir}); +} +######################################################################## + +sub chdir_original { + my $self = shift; + + croak("never called chdir_in()") unless($self->{original_dir}); + my $dir = $self->{original_dir}; + chdir($dir) or die "Can't chdir to '$dir': $!"; +} +######################################################################## + 1; __END__ @@ -482,6 +521,19 @@ Regenerate all missing or changed files. If the optional C argument is given, it also removes any extraneous files that do not belong to the distribution. +=head2 chdir_in + +Change directory into the dist root. + + $dist->chdir_in; + +=head2 chdir_original + +Returns to whatever directory you were in before chdir_in() (regardless +of the cwd.) + + $dist->chdir_original; + =head3 clean() Removes any files that are not part of the distribution. diff --git a/lib/Module/Build/t/lib/MBTest.pm b/lib/Module/Build/t/lib/MBTest.pm index a2443b4..14b8b9e 100644 --- a/lib/Module/Build/t/lib/MBTest.pm +++ b/lib/Module/Build/t/lib/MBTest.pm @@ -9,9 +9,8 @@ BEGIN { # Make sure none of our tests load the users ~/.modulebuildrc file $ENV{MODULEBUILDRC} = 'NONE'; - # In case the test wants to use Test::More or our other bundled - # modules, make sure they can be loaded. They'll still do "use - # Test::More" in the test script. + # In case the test wants to use our other bundled + # modules, make sure they can be loaded. my $t_lib = File::Spec->catdir('t', 'bundled'); unless ($ENV{PERL_CORE}) { @@ -54,6 +53,7 @@ my @extra_exports = qw( find_in_path check_compiler have_module + ensure_blib ); push @EXPORT, @extra_exports; __PACKAGE__->export(scalar caller, @extra_exports); @@ -68,7 +68,9 @@ __PACKAGE__->export(scalar caller, @extra_exports); sub tmpdir { $tmp } END { if(-d $tmp) { - File::Path::rmtree($tmp) or warn "cannot clean dir '$tmp'"; + # Go back to where you came from! + chdir $cwd or die "Couldn't chdir to $cwd"; + File::Path::rmtree($tmp) or diag "cannot clean dir '$tmp'"; } } } @@ -163,5 +165,16 @@ sub have_module { return eval "use $module; 1"; } +sub ensure_blib { + # Make sure the given module was loaded from blib/, not the larger system + my $mod = shift; + (my $path = $mod) =~ s{::}{/}g; + + SKIP: { + skip "no blib in core", 1 if $ENV{PERL_CORE}; + like $INC{"$path.pm"}, qr/\bblib\b/, "Make sure $mod was loaded from blib/"; + } +} + 1; # vim:ts=2:sw=2:et:sta diff --git a/lib/Module/Build/t/manifypods.t b/lib/Module/Build/t/manifypods.t index b0c7328..263c137 100644 --- a/lib/Module/Build/t/manifypods.t +++ b/lib/Module/Build/t/manifypods.t @@ -7,10 +7,12 @@ use Module::Build; use Module::Build::ConfigData; if ( Module::Build::ConfigData->feature('manpage_support') ) { - plan tests => 21; + plan tests => 22; } else { plan skip_all => 'manpage_support feature is not enabled'; } +ensure_blib('Module::Build'); + ######################### @@ -55,7 +57,7 @@ Simple Man $dist->regen; -chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; +$dist->chdir_in; use File::Spec::Functions qw( catdir ); my $destdir = catdir($cwd, 't', 'install_test' . $$); @@ -137,11 +139,10 @@ $mb->dispatch('realclean'); # revert to a pristine state -chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; $dist->remove; $dist = DistGen->new( dir => $tmp ); $dist->regen; -chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; +$dist->chdir_in; my $mb2 = Module::Build->new( @@ -164,8 +165,4 @@ foreach ('testcover', 'disttest') { # cleanup -chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; $dist->remove; - -use File::Path; -rmtree( $tmp ); diff --git a/lib/Module/Build/t/mbyaml.t b/lib/Module/Build/t/mbyaml.t index 01e27ae..f210ed7 100644 --- a/lib/Module/Build/t/mbyaml.t +++ b/lib/Module/Build/t/mbyaml.t @@ -4,12 +4,14 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; use MBTest 'no_plan'; +use_ok 'Module::Build::YAML'; +ensure_blib('Module::Build::YAML'); + my ($dir); $dir = "."; $dir = "t" if (-d "t"); { - use_ok("Module::Build::YAML"); my ($expected, $got, $var); ########################################################## # Test a typical-looking Module::Build structure (alphabetized) diff --git a/lib/Module/Build/t/metadata.t b/lib/Module/Build/t/metadata.t index 00eebe5..caa7d47 100644 --- a/lib/Module/Build/t/metadata.t +++ b/lib/Module/Build/t/metadata.t @@ -2,14 +2,13 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; -use MBTest tests => 49; +use MBTest tests => 51; -use Cwd (); -my $cwd = Cwd::cwd; -my $tmp = MBTest->tmpdir; +use_ok 'Module::Build'; +ensure_blib('Module::Build'); +my $tmp = MBTest->tmpdir; -use Module::Build; use Module::Build::ConfigData; my %metadata = @@ -45,7 +44,7 @@ my $simple2_file = 'lib/Simple2.pm'; } -chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; +$dist->chdir_in; use Module::Build; my $mb = Module::Build->new_from_context; @@ -582,8 +581,4 @@ is_deeply($mb->find_dist_packages, {}); ############################################################ # cleanup -chdir( $cwd ) or die "Can't chdir to '$cwd': $!"; $dist->remove; - -use File::Path; -rmtree( $tmp ); diff --git a/lib/Module/Build/t/metadata2.t b/lib/Module/Build/t/metadata2.t index 1ca4508..e582a5b 100644 --- a/lib/Module/Build/t/metadata2.t +++ b/lib/Module/Build/t/metadata2.t @@ -2,13 +2,13 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; -use MBTest tests => 18; +use MBTest tests => 20; + +use_ok 'Module::Build'; +ensure_blib('Module::Build'); -use Cwd (); -my $cwd = Cwd::cwd; my $tmp = MBTest->tmpdir; -use Module::Build; use Module::Build::ConfigData; use DistGen; @@ -22,7 +22,7 @@ SKIP: { my $dist = DistGen->new( dir => $tmp, skip_manifest => 1 ); $dist->regen; - chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; + $dist->chdir_in; ok ! -e 'MANIFEST'; @@ -36,7 +36,6 @@ SKIP: { ok -e 'META.yml'; - chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; $dist->remove; } @@ -74,7 +73,7 @@ $dist->change_build_pl }); $dist->regen; -chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; +$dist->chdir_in; # .pm File with pod @@ -143,8 +142,4 @@ is( $mb->dist_abstract, "A simple module", ############################################################ # cleanup -chdir( $cwd ) or die "Can't chdir to '$cwd': $!"; $dist->remove; - -use File::Path; -rmtree( $tmp ); diff --git a/lib/Module/Build/t/moduleinfo.t b/lib/Module/Build/t/moduleinfo.t index 56838e4..a9bdcf0 100644 --- a/lib/Module/Build/t/moduleinfo.t +++ b/lib/Module/Build/t/moduleinfo.t @@ -1,24 +1,24 @@ #!/usr/bin/perl -w +# -*- mode: cperl; tab-width: 8; indent-tabs-mode: nil; basic-offset: 2 -*- +# vim:ts=8:sw=2:et:sta:sts=2 use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; -use MBTest tests => 81; +use MBTest tests => 82; + +use_ok 'Module::Build::ModuleInfo'; +ensure_blib('Module::Build::ModuleInfo'); -use Cwd (); -my $cwd = Cwd::cwd; my $tmp = MBTest->tmpdir; use DistGen; my $dist = DistGen->new( dir => $tmp ); $dist->regen; -chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; +$dist->chdir_in; ######################### - -use_ok( 'Module::Build::ModuleInfo' ); - # class method C my $module = Module::Build::ModuleInfo->find_module_by_name( 'Module::Build::ModuleInfo' ); @@ -199,11 +199,10 @@ foreach my $module ( @modules ) { } # revert to pristine state -chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; $dist->remove; $dist = DistGen->new( dir => $tmp ); $dist->regen; -chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; +$dist->chdir_in; # Find each package only once @@ -258,11 +257,10 @@ is( $pm_info->version, '1.23_01', 'alpha version reported'); ok( $pm_info->version > 1.23, 'alpha version greater than non'); # revert to pristine state -chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; $dist->remove; $dist = DistGen->new( dir => $tmp ); $dist->regen; -chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; +$dist->chdir_in; # parse $VERSION lines scripts for package main @@ -427,8 +425,4 @@ $VERSION = version->new('0.61.' . (qw$Revision: 129 $)[1]); # cleanup -chdir( $cwd ) or die "Can't chdir to '$cwd': $!"; $dist->remove; - -use File::Path; -rmtree( $tmp ); diff --git a/lib/Module/Build/t/new_from_context.t b/lib/Module/Build/t/new_from_context.t index abdc079..a1a2433 100644 --- a/lib/Module/Build/t/new_from_context.t +++ b/lib/Module/Build/t/new_from_context.t @@ -2,10 +2,12 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; -use MBTest tests => 2; +use MBTest tests => 4; -use Cwd (); -my $cwd = Cwd::cwd; +use_ok 'Module::Build'; +ensure_blib('Module::Build'); + +use IO::File; my $tmp = MBTest->tmpdir; use DistGen; @@ -15,10 +17,8 @@ my $libdir = 'badlib'; $dist->add_file("$libdir/Build.PL", 'die'); $dist->regen; -chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; +$dist->chdir_in; -use IO::File; -use Module::Build; unshift(@INC, $libdir); my $mb = eval { Module::Build->new_from_context}; @@ -26,10 +26,6 @@ ok(! $@, 'dodged the bullet') or die; ok($mb); # cleanup -chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; $dist->remove; -use File::Path; -rmtree( $tmp ); - # vim:ts=2:sw=2:et:sta diff --git a/lib/Module/Build/t/notes.t b/lib/Module/Build/t/notes.t index 94958cb..2a20d72 100644 --- a/lib/Module/Build/t/notes.t +++ b/lib/Module/Build/t/notes.t @@ -2,20 +2,19 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; -use MBTest tests => 11; +use MBTest tests => 13; + +use_ok 'Module::Build'; +ensure_blib('Module::Build'); -use Cwd (); -my $cwd = Cwd::cwd; my $tmp = MBTest->tmpdir; use DistGen; my $dist = DistGen->new( dir => $tmp ); $dist->regen; -chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; - +$dist->chdir_in; -use Module::Build; ################################### $dist->change_file( 'Build.PL', <<"---" ); @@ -68,8 +67,4 @@ is $mb->notes('foo'), 'bar'; # cleanup -chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; $dist->remove; - -use File::Path; -rmtree( $tmp ); diff --git a/lib/Module/Build/t/parents.t b/lib/Module/Build/t/parents.t index 3229def..7270c67 100644 --- a/lib/Module/Build/t/parents.t +++ b/lib/Module/Build/t/parents.t @@ -2,12 +2,12 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; -use MBTest tests => 27; +use MBTest tests => 28; -######################### +use_ok 'Module::Build'; +ensure_blib('Module::Build'); -use Module::Build; -ok(1); +######################### package Foo; sub foo; diff --git a/lib/Module/Build/t/pod_parser.t b/lib/Module/Build/t/pod_parser.t index cd5fd22..c90608f 100644 --- a/lib/Module/Build/t/pod_parser.t +++ b/lib/Module/Build/t/pod_parser.t @@ -2,15 +2,13 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; -use MBTest tests => 7; +use MBTest tests => 8; -use Cwd (); -my $cwd = Cwd::cwd; +use_ok 'Module::Build::PodParser'; +ensure_blib('Module::Build::PodParser'); ######################### -use_ok 'Module::Build::PodParser'; - { package IO::StringBased; diff --git a/lib/Module/Build/t/ppm.t b/lib/Module/Build/t/ppm.t index eec8a92..d4c3dbf 100644 --- a/lib/Module/Build/t/ppm.t +++ b/lib/Module/Build/t/ppm.t @@ -3,13 +3,13 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; use MBTest; + use Module::Build; use Module::Build::ConfigData; my $manpage_support = Module::Build::ConfigData->feature('manpage_support'); my $HTML_support = Module::Build::ConfigData->feature('HTML_support'); - { my ($have_c_compiler, $C_support_feature) = check_compiler(); if (! $C_support_feature) { @@ -23,13 +23,12 @@ my $HTML_support = Module::Build::ConfigData->feature('HTML_support'); } elsif ( $^O eq 'VMS' ) { plan skip_all => "Needs porting work on VMS"; } else { - plan tests => 12; + plan tests => 13; } } +ensure_blib('Module::Build'); -use Cwd (); -my $cwd = Cwd::cwd; my $tmp = MBTest->tmpdir; @@ -60,7 +59,7 @@ $dist->change_build_pl }); $dist->regen; -chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; +$dist->chdir_in; use File::Spec::Functions qw(catdir); @@ -183,12 +182,8 @@ SKIP: { } -chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; $dist->remove; -use File::Path; -rmtree( $tmp ); - ######################################## diff --git a/lib/Module/Build/t/runthrough.t b/lib/Module/Build/t/runthrough.t index 3fa09d5..e095a60 100644 --- a/lib/Module/Build/t/runthrough.t +++ b/lib/Module/Build/t/runthrough.t @@ -3,15 +3,15 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; use MBTest tests => 32; -use Module::Build; -use Module::Build::ConfigData; +use_ok 'Module::Build'; +ensure_blib('Module::Build'); + +use Module::Build::ConfigData; my $have_yaml = Module::Build::ConfigData->feature('YAML_support'); ######################### -use Cwd (); -my $cwd = Cwd::cwd; my $tmp = MBTest->tmpdir; use DistGen; @@ -55,17 +55,8 @@ close FH; --- $dist->regen; -chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; - -######################### +$dist->chdir_in; -use Module::Build; -ok(1); - -SKIP: { - skip "no blib in core", 1 if $ENV{PERL_CORE}; - like $INC{'Module/Build.pm'}, qr/\bblib\b/, "Make sure version from blib/ is loaded"; -} ######################### @@ -149,7 +140,7 @@ SKIP: { SKIP: { skip( "not sure if we can create a tarball on this platform", 1 ) - unless $mb->check_installed_status('Archive::Tar', 0) || + unless $mb->check_installed_version('Archive::Tar', 0) || $mb->isa('Module::Build::Platform::Unix'); $mb->add_to_cleanup($mb->dist_dir . ".tar.gz"); @@ -206,7 +197,6 @@ ok ! -e $mb->build_script; ok ! -e $mb->config_dir; ok ! -e $mb->dist_dir; -chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; $dist->remove; SKIP: { @@ -227,7 +217,7 @@ echo Hello, World! $dist->add_file( 'bin/script.bat', $script_data ); $dist->regen; - chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; + $dist->chdir_in; $mb = Module::Build->new_from_context; ok $mb; @@ -241,13 +231,8 @@ echo Hello, World! my $out = slurp( $script_file ); is $out, $script_data, ' unmodified by pl2bat'; - chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; $dist->remove; } # cleanup -chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; $dist->remove; - -use File::Path; -rmtree( $tmp ); diff --git a/lib/Module/Build/t/script_dist.t b/lib/Module/Build/t/script_dist.t new file mode 100644 index 0000000..2b13c02 --- /dev/null +++ b/lib/Module/Build/t/script_dist.t @@ -0,0 +1,79 @@ +#!/usr/bin/perl -w +# -*- mode: cperl; tab-width: 8; indent-tabs-mode: nil; basic-offset: 2 -*- +# vim:ts=8:sw=2:et:sta:sts=2 + +use strict; +use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; +use MBTest 'no_plan'; + +use DistGen qw(undent); + +use Module::Build; + +# XXX DistGen shouldn't be assuming module-ness? +my $dist = DistGen->new(dir => MBTest->tmpdir); +$dist->add_file('bin/foo', undent(<<' ---')); + #!/usr/bin/perl + + package bin::foo; + $VERSION = 0.01; + + =head1 NAME + + foo - does stuff + + =head1 AUTHOR + + A. U. Thor, a.u.thor@a.galaxy.far.far.away + + =cut + + print "hello world\n"; + --- + +my %details = ( + dist_name => 'bin-foo', + dist_version_from => 'bin/foo', + dist_author => ['A. U. Thor, a.u.thor@a.galaxy.far.far.away'], + dist_version => '0.01', +); +my %meta_provides = ( + 'bin-foo' => { + file => 'bin/foo', + version => '0.01', + } +); +$dist->change_build_pl({ + # TODO need to get all of this data out of the program itself + ! $ENV{EXTRA_TEST} ? ( + %details, meta_merge => { provides => \%meta_provides, }, + ) : (), + program_name => 'bin/foo', + license => 'perl', +}); + +# hmm... the old assumption of what a dist looks like is wrong here +$dist->remove_file('lib/Simple.pm'); $dist->regen; + +$dist->chdir_in; +rmdir('lib'); + +#system('konsole'); +my $mb = Module::Build->new_from_context; +ok($mb); +is($mb->program_name, 'bin/foo'); +is($mb->license, 'perl'); +is($mb->dist_name, 'bin-foo'); +is($mb->dist_version, '0.01'); +is_deeply($mb->dist_author, + ['A. U. Thor, a.u.thor@a.galaxy.far.far.away']); +ok $mb->dispatch('distmeta'); + +use Module::Build::ConfigData; +SKIP: { + skip( 'YAML_support feature is not enabled', 1 ) + unless Module::Build::ConfigData->feature('YAML_support'); + require YAML; + my $yml = YAML::LoadFile('META.yml'); + is_deeply($yml->{provides}, \%meta_provides); +} diff --git a/lib/Module/Build/t/test_type.t b/lib/Module/Build/t/test_type.t index 99ae121..598ddb1 100644 --- a/lib/Module/Build/t/test_type.t +++ b/lib/Module/Build/t/test_type.t @@ -9,10 +9,11 @@ BEGIN { use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; -use MBTest tests => 8; +use MBTest tests => 9; + +use_ok 'Module::Build'; +ensure_blib('Module::Build'); -use Cwd (); -my $cwd = Cwd::cwd; my $tmp = MBTest->tmpdir; use DistGen; @@ -29,12 +30,10 @@ ok(1, 'second test in special_ext'); $dist->regen; -chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; +$dist->chdir_in; ######################### -use_ok 'Module::Build'; - # Here we make sure we can define an action that will test a particular type $::x = 0; my $mb = Module::Build->subclass( @@ -69,11 +68,10 @@ is( $::x, 2, "called again"); my $output = uc(stdout_of( sub {$mb->dispatch('testspecial', verbose => 0)} )); -like($output, qr/\.\.OK/); +like($output, qr/\.\. ?OK/); is($::x, 3, "called a third time"); -chdir( $cwd ) or die "Can't chdir to '$cwd': $!"; $dist->remove; # vim:ts=4:sw=4:et:sta diff --git a/lib/Module/Build/t/test_types.t b/lib/Module/Build/t/test_types.t index 143efdd..1d2902e 100644 --- a/lib/Module/Build/t/test_types.t +++ b/lib/Module/Build/t/test_types.t @@ -2,10 +2,11 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; -use MBTest tests => 14 + 12; +use MBTest tests => 15 + 12; + +use_ok 'Module::Build'; +ensure_blib('Module::Build'); -use Cwd (); -my $cwd = Cwd::cwd(); my $tmp = MBTest->tmpdir; use DistGen; @@ -33,13 +34,9 @@ die "don't run this non-test file"; --- $dist->regen; - -chdir($dist->dirname) or die "Can't chdir to '@{[$dist->dirname]}': $!"; - +$dist->chdir_in; ######################### -use_ok 'Module::Build'; - my $mb = Module::Build->subclass( code => q# sub ACTION_testspecial { @@ -101,7 +98,6 @@ is(scalar(@{[$all_output =~ m/OK 1/mg]}), 3 ); is(scalar(@{[$all_output =~ m/OK/mg]}), 8 ); is(scalar(@{[$all_output =~ m/ALL TESTS SUCCESSFUL\./mg]}), 1); -chdir($cwd) or die "Can't chdir to '$cwd': $!"; $dist->remove; { # once-again @@ -118,8 +114,7 @@ use strict; use Simple; ok 1; --- $dist->regen; - -chdir($dist->dirname) or die "Can't chdir to '@{[$dist->dirname]}': $!"; +$dist->chdir_in; my $mb = Module::Build->subclass( code => q# @@ -179,7 +174,6 @@ like($all_output, qr/^OK 2 - SECOND TEST IN ANOTHER_EXT/m); is(scalar(@{[$all_output =~ m/(OK 1)/mg]}), 5 ); is(scalar(@{[$all_output =~ m/(OK)/mg]}), 13 ); -chdir($cwd) or die "Can't chdir to '$cwd': $!"; $dist->remove; } # end once-again diff --git a/lib/Module/Build/t/tilde.t b/lib/Module/Build/t/tilde.t index 71d3500..7dfcf1e 100644 --- a/lib/Module/Build/t/tilde.t +++ b/lib/Module/Build/t/tilde.t @@ -4,20 +4,19 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; -use MBTest tests => 15; +use MBTest tests => 17; + +use_ok 'Module::Build'; +ensure_blib('Module::Build'); -use Cwd (); -my $cwd = Cwd::cwd; my $tmp = MBTest->tmpdir; use DistGen; my $dist = DistGen->new( dir => $tmp ); $dist->regen; -chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; - +$dist->chdir_in; -use Module::Build; sub run_sample { my @args = @_; @@ -39,7 +38,13 @@ my $p = 'install_base'; SKIP: { my $home = $ENV{HOME} ? $ENV{HOME} : undef; - skip "Needs case and syntax tweaks for VMS", 14 if $^O eq 'VMS'; + + if ($^O eq 'VMS') { + # Convert the path to UNIX format, trim off the trailing slash + $home = VMS::Filespec::unixify($home); + $home =~ s#/$##; + } + unless (defined $home) { my @info = eval { getpwuid $> }; skip "No home directory for tilde-expansion tests", 14 if $@; @@ -83,18 +88,22 @@ SKIP: { # Again, with named users SKIP: { - skip "Needs case and syntax tweaks for VMS", 1 if $^O eq 'VMS'; my @info = eval { getpwuid $> }; skip "No home directory for tilde-expansion tests", 1 if $@; my ($me, $home) = @info[0,7]; - is( run_sample( $p => "~$me/foo")->$p(), "$home/foo" ); + my $expected = "$home/foo"; + + if ($^O eq 'VMS') { + # Convert the path to UNIX format and trim off the trailing slash + $home = VMS::Filespec::unixify($home); + $home =~ s#/$##; + $expected = $home . '/../[^/]+' . '/foo'; + } + + like( run_sample( $p => "~$me/foo")->$p(), qr($expected)i ); } # cleanup -chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; $dist->remove; - -use File::Path; -rmtree( $tmp ); diff --git a/lib/Module/Build/t/versions.t b/lib/Module/Build/t/versions.t index e2d66a9..0bf4781 100644 --- a/lib/Module/Build/t/versions.t +++ b/lib/Module/Build/t/versions.t @@ -2,10 +2,11 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; -use MBTest tests => 2; +use MBTest tests => 4; + +use_ok 'Module::Build'; +ensure_blib('Module::Build'); -use Cwd (); -my $cwd = Cwd::cwd; my $tmp = MBTest->tmpdir; use DistGen; @@ -14,8 +15,6 @@ $dist->regen; ######################### -use Module::Build; - my @mod = split( /::/, $dist->name ); my $file = File::Spec->catfile( $dist->dirname, 'lib', @mod ) . '.pm'; is( Module::Build->version_from_file( $file ), '0.01', 'version_from_file' ); @@ -25,6 +24,3 @@ ok( Module::Build->compare_versions( '1.01_01', '>', '1.01' ), 'compare: 1.0_01 # cleanup $dist->remove; - -use File::Path; -rmtree( $tmp ); diff --git a/lib/Module/Build/t/xs.t b/lib/Module/Build/t/xs.t index e5e13a0..4319a68 100644 --- a/lib/Module/Build/t/xs.t +++ b/lib/Module/Build/t/xs.t @@ -15,22 +15,23 @@ use Module::Build; } elsif ( $^O eq 'VMS' ) { plan skip_all => 'Child test output confuses harness'; } else { - plan tests => 22; + plan tests => 23; } } +ensure_blib('Module::Build'); + + ######################### -use Cwd (); -my $cwd = Cwd::cwd; my $tmp = MBTest->tmpdir; use DistGen; my $dist = DistGen->new( dir => $tmp, xs => 1 ); $dist->regen; -chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; +$dist->chdir_in; my $mb = Module::Build->new_from_context; @@ -103,7 +104,6 @@ ok ! -e 'blib'; # cleanup -chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; $dist->remove; @@ -114,7 +114,7 @@ $dist->remove; $dist = DistGen->new( name => 'Simple::With::Deep::Name', dir => $tmp, xs => 1 ); $dist->regen; -chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; +$dist->chdir_in; $mb = Module::Build->new_from_context; is $@, ''; @@ -129,7 +129,6 @@ $mb->dispatch('realclean'); is $@, ''; # cleanup -chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; $dist->remove; @@ -208,7 +207,7 @@ ok( Simple::okay() eq 'ok' ); --- $dist->regen; -chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; +$dist->chdir_in; $mb = Module::Build->new_from_context; @@ -224,8 +223,4 @@ $mb->dispatch('realclean'); is $@, ''; # cleanup -chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; $dist->remove; - -use File::Path; -rmtree( $tmp );