Re: [Module-build-general] Doc patchlet
Status: Beta
Brought to you by:
kwilliams
|
From: Dave R. <au...@ur...> - 2003-04-21 19:27:44
|
On Mon, 21 Apr 2003, Ken Williams wrote: > This is probably a bug, not something that should be documented. > add_to_cleanup() should work even if you're not using a Build script or > if it hasn't been created yet. Patch below sig. It's not the most beautiful test, but it does work. /*======================= House Absolute Consulting www.houseabsolute.com =======================*/ Index: lib/Module/Build/Base.pm =================================================================== RCS file: /cvsroot/module-build/Module-Build/lib/Module/Build/Base.pm,v retrieving revision 1.92 diff -u -r1.92 Base.pm --- lib/Module/Build/Base.pm 19 Apr 2003 00:16:47 -0000 1.92 +++ lib/Module/Build/Base.pm 21 Apr 2003 19:26:04 -0000 @@ -292,12 +292,14 @@ sub add_to_cleanup { my $self = shift; - my @need_to_write = grep {!exists $self->{cleanup}{$_}} @_; + my @need_to_write = grep {!exists $self->{cleanup}{$_}} @_, keys %{$self->{add_to_cleanup}}; return unless @need_to_write; if ( my $file = $self->config_file('cleanup') ) { my $fh = IO::File->new(">> $file") or die "Can't append to $file: $!"; print $fh "$_\n" foreach @need_to_write; + } else { + @{$self->{add_to_cleanup}}{@need_to_write} = (); } @{$self->{cleanup}}{ @need_to_write } = (); Index: t/runthrough.t =================================================================== RCS file: /cvsroot/module-build/Module-Build/t/runthrough.t,v retrieving revision 1.14 diff -u -r1.14 runthrough.t --- t/runthrough.t 13 Apr 2003 12:37:04 -0000 1.14 +++ t/runthrough.t 21 Apr 2003 19:26:04 -0000 @@ -1,5 +1,5 @@ use Test; -BEGIN { plan tests => 13 } +BEGIN { plan tests => 14 } use Module::Build; use File::Spec; use File::Path; @@ -23,8 +23,12 @@ license => 'perl' ); ok $build; +$build->add_to_cleanup('before_script'); + eval {$build->create_build_script}; ok $@, ''; + +ok grep $_ eq 'before_script', keys %{$build->{cleanup}}; $build->add_to_cleanup('save_out'); my $output = eval { |