Author: dagolden
Date: Wed Sep 2 20:31:35 2009
New Revision: 13261
Modified:
Module-Build/trunk/t/basic.t
Module-Build/trunk/t/compat.t
Module-Build/trunk/t/debug.t
Module-Build/trunk/t/destinations.t
Module-Build/trunk/t/extend.t
Module-Build/trunk/t/files.t
Module-Build/trunk/t/help.t
Module-Build/trunk/t/install.t
Module-Build/trunk/t/install_extra_target.t
Module-Build/trunk/t/lib/DistGen.pm
Module-Build/trunk/t/manifypods.t
Module-Build/trunk/t/metadata.t
Module-Build/trunk/t/metadata2.t
Module-Build/trunk/t/moduleinfo.t
Module-Build/trunk/t/mymeta.t
Module-Build/trunk/t/new_from_context.t
Module-Build/trunk/t/notes.t
Module-Build/trunk/t/par.t
Module-Build/trunk/t/ppm.t
Module-Build/trunk/t/properties/needs_compiler.t
Module-Build/trunk/t/properties/share_dir.t
Module-Build/trunk/t/runthrough.t
Module-Build/trunk/t/signature.t
Module-Build/trunk/t/test_file_exts.t
Module-Build/trunk/t/test_type.t
Module-Build/trunk/t/test_types.t
Module-Build/trunk/t/tilde.t
Module-Build/trunk/t/use_tap_harness.t
Module-Build/trunk/t/versions.t
Module-Build/trunk/t/xs.t
Log:
DistGen API changes and auto-cleanup
This commit includes a number of DistGen changes.
In particular, DistGen objects now clean up after
themselves in an END block, so all the ->remove()
calls sprinkled through tests have been removed.
Implemented revert() and also a reset() method.
Most methods return $self to allow for method
chaining. In general, using DistGen should be
simpler as a result of these changes.
Modified: Module-Build/trunk/t/basic.t
==============================================================================
--- Module-Build/trunk/t/basic.t (original)
+++ Module-Build/trunk/t/basic.t Wed Sep 2 20:31:35 2009
@@ -162,10 +162,7 @@
is $args{foo}, 1;
# revert test distribution to pristine state because we modified a file
- $dist->remove;
- $dist = DistGen->new( dir => $tmp );
- $dist->regen;
- $dist->chdir_in;
+ $dist->regen( clean => 1 );
}
# Test author stuff
@@ -235,5 +232,3 @@
is_deeply $mb->include_dirs, ['/foo'], 'Should have single include dir';
}
-# cleanup
-$dist->remove;
Modified: Module-Build/trunk/t/compat.t
==============================================================================
--- Module-Build/trunk/t/compat.t (original)
+++ Module-Build/trunk/t/compat.t Wed Sep 2 20:31:35 2009
@@ -312,9 +312,6 @@
}
-# cleanup
-$dist->remove;
-
#########################################################
sub test_makefile_types {
Modified: Module-Build/trunk/t/debug.t
==============================================================================
--- Module-Build/trunk/t/debug.t (original)
+++ Module-Build/trunk/t/debug.t Wed Sep 2 20:31:35 2009
@@ -11,8 +11,6 @@
use DistGen;
my $dist = DistGen->new( dir => $tmp );
$dist->regen;
-END{ $dist->remove }
-
$dist->chdir_in;
#########################
@@ -27,6 +25,3 @@
);
}
-#########################
-
-# cleanup
Modified: Module-Build/trunk/t/destinations.t
==============================================================================
--- Module-Build/trunk/t/destinations.t (original)
+++ Module-Build/trunk/t/destinations.t Wed Sep 2 20:31:35 2009
@@ -321,5 +321,3 @@
}
}
-
-$dist->remove;
Modified: Module-Build/trunk/t/extend.t
==============================================================================
--- Module-Build/trunk/t/extend.t (original)
+++ Module-Build/trunk/t/extend.t Wed Sep 2 20:31:35 2009
@@ -274,5 +274,3 @@
}
-# cleanup
-$dist->remove;
Modified: Module-Build/trunk/t/files.t
==============================================================================
--- Module-Build/trunk/t/files.t (original)
+++ Module-Build/trunk/t/files.t Wed Sep 2 20:31:35 2009
@@ -45,5 +45,3 @@
ok( Module::Build->dir_contains($first, $second) );
}
-# cleanup
-$dist->remove;
Modified: Module-Build/trunk/t/help.t
==============================================================================
--- Module-Build/trunk/t/help.t (original)
+++ Module-Build/trunk/t/help.t Wed Sep 2 20:31:35 2009
@@ -6,33 +6,19 @@
blib_load('Module::Build');
-use Cwd ();
-use File::Path ();
-
-my $cwd = Cwd::cwd();
-my $tmp = MBTest->tmpdir;
-
use DistGen;
-my $dist = DistGen->new(dir => $tmp);
-
-
+my $dist = DistGen->new;
$dist->regen;
+$dist->chdir_in;
my $restart = sub {
- $dist->clean();
- DistGen::chdir_all( $cwd );
- File::Path::rmtree( $tmp );
# we're redefining the same package as we go, so...
delete($::{'MyModuleBuilder::'});
delete($INC{'MyModuleBuilder.pm'});
- $dist->regen;
- chdir($dist->dirname) or
- die "Can't chdir to '@{[$dist->dirname]}': $!";
+ $dist->regen( clean => 1 );
};
-chdir($dist->dirname) or die "Can't chdir to '@{[$dist->dirname]}': $!";
-
########################################################################
{ # check the =item style
my $mb = Module::Build->subclass(
@@ -273,7 +259,5 @@
# cleanup
$dist->clean();
-DistGen::chdir_all($cwd);
-File::Path::rmtree( $tmp );
# vim:ts=2:sw=2:et:sta
Modified: Module-Build/trunk/t/install.t
==============================================================================
--- Module-Build/trunk/t/install.t (original)
+++ Module-Build/trunk/t/install.t Wed Sep 2 20:31:35 2009
@@ -224,10 +224,7 @@
is keys %$pms, 0;
# revert to pristine state
- $dist->remove;
- $dist = DistGen->new( dir => $tmp );
- $dist->regen;
- $dist->chdir_in;
+ $dist->regen( clean => 1 );
}
sub strip_volume {
@@ -242,6 +239,3 @@
ok -e $file or diag("Expected $file to exist, but it doesn't");
}
-
-# cleanup
-$dist->remove;
Modified: Module-Build/trunk/t/install_extra_target.t
==============================================================================
--- Module-Build/trunk/t/install_extra_target.t (original)
+++ Module-Build/trunk/t/install_extra_target.t Wed Sep 2 20:31:35 2009
@@ -133,4 +133,3 @@
$error++ unless ok(-e "$installdest/share/simple/html/index.html", "installed
share/html");
diag "OUTPUT:\n$output" if $error;
-$dist->remove();
Modified: Module-Build/trunk/t/lib/DistGen.pm
==============================================================================
--- Module-Build/trunk/t/lib/DistGen.pm (original)
+++ Module-Build/trunk/t/lib/DistGen.pm Wed Sep 2 20:31:35 2009
@@ -7,9 +7,9 @@
$VERSION = '0.01';
$VERBOSE = 0;
-
use Carp;
+use MBTest ();
use Cwd ();
use File::Basename ();
use File::Find ();
@@ -18,7 +18,6 @@
use IO::File ();
use Tie::CPHash;
use Data::Dumper;
-require MBTest; # for tmpdir
my $vms_mode;
my $vms_lower_case;
@@ -70,46 +69,77 @@
chdir('/') if $^O eq 'os2';
chdir shift;
}
+
########################################################################
-sub new {
- my $package = shift;
- my %options = @_;
-
- $options{name} ||= 'Simple';
- $options{dir} ||= MBTest->tmpdir( CLEANUP => 0 );
-
- my %data = (
- no_manifest => 0,
- xs => 0,
- %options,
- );
- my $self = bless( \%data, $package );
+{
+ my @CLEANUP_DIRS;
- # So we can clean up later even if the caller chdir()s
- $self->{dir} = File::Spec->rel2abs($self->{dir});
- $self->{original_dir} = Cwd::cwd; # only once
+ END {
+ chdir_all(MBTest->original_cwd);
+ File::Path::rmtree($_) for @CLEANUP_DIRS;
+ }
- tie %{$self->{filedata}}, 'Tie::CPHash';
+ sub new {
+ my $self = bless {}, shift;
+ $self->reset(@_);
+ }
- tie %{$self->{pending}{change}}, 'Tie::CPHash';
+ sub reset {
+ my $self = shift;
+ my %options = @_;
- # start with a fresh, empty directory
- if ( -d $self->dirname ) {
- warn "Warning: Removing existing directory '@{[$self->dirname]}'\n";
- $self->remove;
- }
- File::Path::mkpath( $self->dirname );
+ $options{name} ||= 'Simple';
+ $options{dir} ||= MBTest->tmpdir( CLEANUP => 0 );
- $self->_gen_default_filedata();
+ my %data = (
+ no_manifest => 0,
+ xs => 0,
+ %options,
+ );
+ %$self = %data;
+ # So we can clean up later even if the caller chdir()s
+ $self->{dir} = File::Spec->rel2abs($self->{dir});
+ push @CLEANUP_DIRS, $self->{dir};
+
+ tie %{$self->{filedata}}, 'Tie::CPHash';
+
+ tie %{$self->{pending}{change}}, 'Tie::CPHash';
+
+ # start with a fresh, empty directory
+ if ( -d $self->dirname ) {
+ warn "Warning: Removing existing directory '@{[$self->dirname]}'\n";
+ File::Path::rmtree( $self->dirname );
+ }
+ File::Path::mkpath( $self->dirname );
+
+ $self->_gen_default_filedata();
+
+ return $self;
+ }
+}
+
+sub remove {
+ my $self = shift;
+ $self->chdir_original if($self->did_chdir);
+ File::Path::rmtree( $self->dirname );
return $self;
}
-sub DESTROY {
- my ($self) = @_;
- $self->chdir_original;
- $self->remove;
+sub revert {
+ my ($self, $file) = @_;
+ if ( defined $file ) {
+ delete $self->{filedata}{$file};
+ delete $self->{pending}{$_}{$file} for qw/change remove/;
+ }
+ else {
+ delete $self->{filedata}{$_} for keys %{ $self->{filedata} };
+ for my $pend ( qw/change remove/ ) {
+ delete $self->{pending}{$pend}{$_} for keys %{ $self->{pending}{$pend}
};
+ }
+ }
+ $self->_gen_default_filedata;
}
sub _gen_default_filedata {
@@ -259,7 +289,6 @@
my $manifest = shift;
my $fh = IO::File->new( ">$manifest" ) or do {
- $self->remove();
die "Can't write '$manifest'\n";
};
@@ -322,7 +351,6 @@
my $dirname = File::Basename::dirname( $fullname );
unless ( -d $dirname ) {
File::Path::mkpath( $dirname ) or do {
- $self->remove();
die "Can't create '$dirname'\n";
};
}
@@ -332,7 +360,6 @@
}
my $fh = IO::File->new(">$fullname") or do {
- $self->remove();
die "Can't write '$fullname'\n";
};
print $fh $self->{filedata}{$file};
@@ -410,21 +437,6 @@
return $self;
}
-sub remove {
- my $self = shift;
- 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);
- return $self;
-}
-
-sub revert {
- my $self = shift;
- die "Unimplemented.\n";
-}
-
sub add_file {
my $self = shift;
$self->change_file( @_ );
@@ -484,21 +496,21 @@
sub chdir_in {
my $self = shift;
- $self->{did_chdir} = 1;
+ $self->{original_dir} ||= Cwd::cwd; # only once!
my $dir = $self->dirname;
chdir($dir) or die "Can't chdir to '$dir': $!";
return $self;
}
########################################################################
-sub did_chdir { shift()->{did_chdir} }
+sub did_chdir { exists shift()->{original_dir} }
########################################################################
sub chdir_original {
my $self = shift;
- my $dir = $self->{original_dir};
+ my $dir = delete $self->{original_dir};
chdir_all($dir) or die "Can't chdir to '$dir': $!";
return $self;
}
@@ -546,15 +558,17 @@
$dist->remove_file('t/some_test.t');
$dist->regen;
- # clean up extraneous files
+ # undo changes and clean up extraneous files
+ $dist->revert;
$dist->clean;
# exercise the command-line interface
$dist->run_build_pl();
$dist->run_build('test');
- # destructor returns to original dir and removes $dist dir
- undef $dist
+ # start over as a new distribution
+ $dist->reset( name => 'Foo::Bar', xs => 1 );
+ $dist->chdir_in;
=head1 USAGE
@@ -562,7 +576,9 @@
The C<new()> constructor initializes the object and creates an empty
directory for the distribution. It does not create files or chdir into
-the directory.
+the directory. The C<reset()> method re-initializes the object in a
+new directory with new parameters. It also does not create files or change
+the current directory.
Some methods only define the target state of the distribution. They do B<not>
make any changes to the filesystem:
@@ -571,12 +587,13 @@
change_file
change_build_pl
remove_file
+ revert
Other methods then change the filesystem to match the target state of
-the distribution (or to remove it entirely):
+the distribution:
- regen
clean
+ regen
remove
Other methods are provided for a convenience during testing. The
@@ -591,7 +608,7 @@
=head1 API
-=head2 Constructor
+=head2 Constructors
=head3 new()
@@ -601,10 +618,9 @@
The C<new> method does not write any files -- see L</regen()> below.
- my $tmp = MBTest->tmpdir;
my $dist = DistGen->new(
name => 'Foo::Bar',
- dir => $tmp,
+ dir => MBTest->tmpdir,
xs => 1,
no_manifest => 0,
);
@@ -652,6 +668,13 @@
typemap
lib/Simple.xs # based on name parameter
+=head3 reset()
+
+The C<reset> method re-initializes the object as if it were generated
+from a fresh call to C<new>. It takes the same optional parameters as C<new>.
+
+ $dist->reset( name => 'Foo::Bar', xs => 0 );
+
=head2 Adding and editing files
Note that C<$filename> should always be specified with unix-style paths,
@@ -699,6 +722,14 @@
$dist->remove_file( $filename );
+=head3 revert()
+
+Returns the object to its initial state, or given a $filename it returns that
+file to its initial state if it is one of the built-in files.
+
+ $dist->revert;
+ $dist->revert($filename);
+
=head2 Changing the distribution directory
These methods immediately affect the filesystem.
@@ -710,8 +741,10 @@
$dist->regen(clean => 1);
-If the optional C<clean> argument is given, it also removes any
-extraneous files that do not belong to the distribution.
+If the optional C<clean> argument is given, it also calls C<clean>. These
+can also be chained like this, instead:
+
+ $dist->clean->regen;
=head3 clean()
@@ -719,22 +752,19 @@
$dist->clean;
-=begin TODO
-
-=head3 revert()
-
-[Unimplemented] Returns the object to its initial state, or given a
-$filename it returns that file to it's initial state if it is one of
-the built-in files.
-
- $dist->revert;
- $dist->revert($filename);
+=head3 remove()
-=end TODO
+Changes back to the original directory and removes the distribution
+directory (but not the temporary directory set during C<new()>).
-=head3 remove()
+ $dist = DistGen->new->chdir->regen;
+ # ... do some testing ...
+
+ $dist->remove->chdir_in->regen;
+ # ... do more testing ...
-Removes the entire distribution directory.
+This is like a more aggressive form of C<clean>. Generally, calling C<clean>
+and C<regen> should be sufficient.
=head2 Changing directories
Modified: Module-Build/trunk/t/manifypods.t
==============================================================================
--- Module-Build/trunk/t/manifypods.t (original)
+++ Module-Build/trunk/t/manifypods.t Wed Sep 2 20:31:35 2009
@@ -138,11 +138,7 @@
# revert to a pristine state
-$dist->remove;
-$dist = DistGen->new( dir => $tmp );
-$dist->regen;
-$dist->chdir_in;
-
+$dist->regen( clean => 1 );
my $mb2 = Module::Build->new(
module_name => $dist->name,
@@ -162,6 +158,3 @@
unlike $docs, qr/\n=/, $docs;
}
-
-# cleanup
-$dist->remove;
Modified: Module-Build/trunk/t/metadata.t
==============================================================================
--- Module-Build/trunk/t/metadata.t (original)
+++ Module-Build/trunk/t/metadata.t Wed Sep 2 20:31:35 2009
@@ -601,6 +601,3 @@
$mb = new_build();
is_deeply($mb->find_dist_packages, {});
-############################################################
-# cleanup
-$dist->remove;
Modified: Module-Build/trunk/t/metadata2.t
==============================================================================
--- Module-Build/trunk/t/metadata2.t (original)
+++ Module-Build/trunk/t/metadata2.t Wed Sep 2 20:31:35 2009
@@ -7,7 +7,6 @@
blib_load('Module::Build');
blib_load('Module::Build::ConfigData');
-my $tmp = MBTest->tmpdir;
use DistGen;
@@ -17,10 +16,7 @@
skip( 'YAML_support feature is not enabled', 4 )
unless Module::Build::ConfigData->feature('YAML_support');
- my $dist = DistGen->new( dir => $tmp, no_manifest => 1 );
- $dist->regen;
-
- $dist->chdir_in;
+ my $dist = DistGen->new( no_manifest => 1 )->chdir_in->regen;
ok ! -e 'MANIFEST';
@@ -35,7 +31,6 @@
ok -e 'META.yml';
- $dist->remove;
}
@@ -61,7 +56,7 @@
=cut
---
-my $dist = DistGen->new( dir => $tmp );
+my $dist = DistGen->new->chdir_in;
$dist->change_build_pl
({
@@ -70,10 +65,6 @@
license => 'perl',
create_readme => 1,
});
-$dist->regen;
-
-$dist->chdir_in;
-
# .pm File with pod
#
@@ -138,7 +129,3 @@
is( $mb->dist_abstract, "A simple module",
"Extracting abstract from .pod over .pm");
-
-############################################################
-# cleanup
-$dist->remove;
Modified: Module-Build/trunk/t/moduleinfo.t
==============================================================================
--- Module-Build/trunk/t/moduleinfo.t (original)
+++ Module-Build/trunk/t/moduleinfo.t Wed Sep 2 20:31:35 2009
@@ -198,11 +198,7 @@
}
# revert to pristine state
-$dist->remove;
-$dist = DistGen->new( dir => $tmp );
-$dist->regen;
-$dist->chdir_in;
-
+$dist->regen( clean => 1 );
# Find each package only once
$dist->change_file( 'lib/Simple.pm', <<'---' );
@@ -256,11 +252,7 @@
ok( $pm_info->version > 1.23, 'alpha version greater than non');
# revert to pristine state
-$dist->remove;
-$dist = DistGen->new( dir => $tmp );
-$dist->regen;
-$dist->chdir_in;
-
+$dist->regen( clean => 1 );
# parse $VERSION lines scripts for package main
my @scripts = (
@@ -422,6 +414,3 @@
is( $pm_info->version('Simple::Simon'), '0.61.129', 'version for embedded
package' );
}
-
-# cleanup
-$dist->remove;
Modified: Module-Build/trunk/t/mymeta.t
==============================================================================
--- Module-Build/trunk/t/mymeta.t (original)
+++ Module-Build/trunk/t/mymeta.t Wed Sep 2 20:31:35 2009
@@ -11,8 +11,6 @@
use DistGen;
my $dist = DistGen->new( dir => $tmp );
$dist->regen;
-END{ $dist->remove }
-
$dist->chdir_in;
#########################
Modified: Module-Build/trunk/t/new_from_context.t
==============================================================================
--- Module-Build/trunk/t/new_from_context.t (original)
+++ Module-Build/trunk/t/new_from_context.t Wed Sep 2 20:31:35 2009
@@ -24,7 +24,4 @@
ok(! $@, 'dodged the bullet') or die;
ok($mb);
-# cleanup
-$dist->remove;
-
# vim:ts=2:sw=2:et:sta
Modified: Module-Build/trunk/t/notes.t
==============================================================================
--- Module-Build/trunk/t/notes.t (original)
+++ Module-Build/trunk/t/notes.t Wed Sep 2 20:31:35 2009
@@ -64,6 +64,3 @@
ok $mb;
is $mb->notes('foo'), 'bar';
-
-# cleanup
-$dist->remove;
Modified: Module-Build/trunk/t/par.t
==============================================================================
--- Module-Build/trunk/t/par.t (original)
+++ Module-Build/trunk/t/par.t Wed Sep 2 20:31:35 2009
@@ -94,4 +94,3 @@
);
}
-$dist->remove;
Modified: Module-Build/trunk/t/ppm.t
==============================================================================
--- Module-Build/trunk/t/ppm.t (original)
+++ Module-Build/trunk/t/ppm.t Wed Sep 2 20:31:35 2009
@@ -181,9 +181,6 @@
}
-$dist->remove;
-
-
########################################
sub exists_ok {
Modified: Module-Build/trunk/t/properties/needs_compiler.t
==============================================================================
--- Module-Build/trunk/t/properties/needs_compiler.t (original)
+++ Module-Build/trunk/t/properties/needs_compiler.t Wed Sep 2 20:31:35 2009
@@ -10,16 +10,7 @@
# Ensure any Module::Build modules are loaded from correct directory
blib_load('Module::Build');
-# create dist object in a temp directory
-# MBTest uses different dirs for Perl core vs CPAN testing
-my $dist = DistGen->new( dir => MBTest->tmpdir );
-
-# generate the skeleton files and also schedule cleanup
-$dist->regen;
-END{ $dist->remove }
-
-# enter the test distribution directory before further testing
-$dist->chdir_in;
+my $dist = DistGen->new->regen->chdir_in;
# get a Module::Build object and test with it
my $mb;
Modified: Module-Build/trunk/t/properties/share_dir.t
==============================================================================
--- Module-Build/trunk/t/properties/share_dir.t (original)
+++ Module-Build/trunk/t/properties/share_dir.t Wed Sep 2 20:31:35 2009
@@ -21,10 +21,7 @@
use DistGen;
my $dist = DistGen->new( dir => $tmp, name => 'Simple::Share' );
-
$dist->regen;
-END{ $dist->remove }
-
$dist->chdir_in;
#--------------------------------------------------------------------------#
Modified: Module-Build/trunk/t/runthrough.t
==============================================================================
--- Module-Build/trunk/t/runthrough.t (original)
+++ Module-Build/trunk/t/runthrough.t Wed Sep 2 20:31:35 2009
@@ -190,8 +190,6 @@
ok ! -e $mb->config_dir;
ok ! -e $mb->dist_dir;
-$dist->remove;
-
SKIP: {
skip( 'Windows-only test', 4 ) unless $^O =~ /^MSWin/;
@@ -224,8 +222,5 @@
my $out = slurp( $script_file );
is $out, $script_data, ' unmodified by pl2bat';
- $dist->remove;
}
-# cleanup
-$dist->remove;
Modified: Module-Build/trunk/t/signature.t
==============================================================================
--- Module-Build/trunk/t/signature.t (original)
+++ Module-Build/trunk/t/signature.t Wed Sep 2 20:31:35 2009
@@ -6,7 +6,7 @@
if ( $ENV{TEST_SIGNATURE} ) {
if ( have_module( 'Module::Signature' ) ) {
- plan tests => 14;
+ plan tests => 13;
} else {
plan skip_all => '$ENV{TEST_SIGNATURE} is set, but Module::Signature not
found';
}
@@ -98,5 +98,3 @@
ok -e 'SIGNATURE', 'Build.PL --sign=1 signs';
}
-# cleanup
-$dist->remove;
Modified: Module-Build/trunk/t/test_file_exts.t
==============================================================================
--- Module-Build/trunk/t/test_file_exts.t (original)
+++ Module-Build/trunk/t/test_file_exts.t Wed Sep 2 20:31:35 2009
@@ -38,7 +38,4 @@
like $out, qr/^OK 1 - FIRST MYTEST[.]S/m, 'Should see first test output';
like $out, qr/^OK 2 - SECOND MYTEST[.]S/m, 'Should see second test output';
-# Cleanup.
-$dist->remove;
-
# vim:ts=4:sw=4:et:sta
Modified: Module-Build/trunk/t/test_type.t
==============================================================================
--- Module-Build/trunk/t/test_type.t (original)
+++ Module-Build/trunk/t/test_type.t Wed Sep 2 20:31:35 2009
@@ -71,6 +71,4 @@
is($::x, 3, "called a third time");
-$dist->remove;
-
# vim:ts=4:sw=4:et:sta
Modified: Module-Build/trunk/t/test_types.t
==============================================================================
--- Module-Build/trunk/t/test_types.t (original)
+++ Module-Build/trunk/t/test_types.t Wed Sep 2 20:31:35 2009
@@ -6,11 +6,9 @@
blib_load('Module::Build');
-my $tmp = MBTest->tmpdir;
-
use DistGen;
-my $dist = DistGen->new(dir => $tmp);
+my $dist = DistGen->new()->chdir_in;
$dist->add_file('t/special_ext.st', <<'---');
#!perl
@@ -33,7 +31,6 @@
---
$dist->regen;
-$dist->chdir_in;
#########################
my $mb = Module::Build->subclass(
@@ -97,10 +94,10 @@
is(scalar(@{[$all_output =~ m/OK/mg]}), 8 );
is(scalar(@{[$all_output =~ m/ALL TESTS SUCCESSFUL\./mg]}), 1);
-$dist->remove;
-
{ # once-again
+$dist->revert;
+
$dist->add_file('t/foo/special.st', <<'---');
#!perl
use Test::More tests => 2;
@@ -113,7 +110,6 @@
ok 1;
---
$dist->regen;
-$dist->chdir_in;
my $mb = Module::Build->subclass(
code => q#
@@ -173,7 +169,6 @@
is(scalar(@{[$all_output =~ m/(OK 1)/mg]}), 5 );
is(scalar(@{[$all_output =~ m/(OK)/mg]}), 13 );
-$dist->remove;
} # end once-again
# vim:ts=4:sw=4:et:sta
Modified: Module-Build/trunk/t/tilde.t
==============================================================================
--- Module-Build/trunk/t/tilde.t (original)
+++ Module-Build/trunk/t/tilde.t Wed Sep 2 20:31:35 2009
@@ -110,6 +110,3 @@
like( run_sample( $p => "~$me/foo")->$p(), qr($expected)i );
}
-
-# cleanup
-$dist->remove;
Modified: Module-Build/trunk/t/use_tap_harness.t
==============================================================================
--- Module-Build/trunk/t/use_tap_harness.t (original)
+++ Module-Build/trunk/t/use_tap_harness.t Wed Sep 2 20:31:35 2009
@@ -91,7 +91,4 @@
"Saw emulated Test::Harness die() message"
);
-
-$dist->remove;
-
# vim:ts=4:sw=4:et:sta
Modified: Module-Build/trunk/t/versions.t
==============================================================================
--- Module-Build/trunk/t/versions.t (original)
+++ Module-Build/trunk/t/versions.t Wed Sep 2 20:31:35 2009
@@ -19,7 +19,3 @@
is( Module::Build->version_from_file( $file ), '0.01', 'version_from_file' );
ok( Module::Build->compare_versions( '1.01_01', '>', '1.01' ), 'compare:
1.0_01 > 1.0' );
-
-
-# cleanup
-$dist->remove;
Modified: Module-Build/trunk/t/xs.t
==============================================================================
--- Module-Build/trunk/t/xs.t (original)
+++ Module-Build/trunk/t/xs.t Wed Sep 2 20:31:35 2009
@@ -32,12 +32,9 @@
#########################
use DistGen;
-my $dist = DistGen->new( dir => $tmp, xs => 1 );
-$dist->regen;
-
-$dist->chdir_in;
-my $mb = Module::Build->new_from_context;
+my $dist = DistGen->new( dir => $tmp, xs => 1 )->chdir_in->regen;
+my $mb = $dist->new_from_context;
eval {$mb->dispatch('clean')};
is $@, '';
@@ -106,19 +103,13 @@
# Make sure blib/ is gone after 'realclean'
ok ! -e 'blib';
-
-# cleanup
-$dist->remove;
-
-
########################################
# Try a XS distro with a deep namespace
-$dist = DistGen->new( name => 'Simple::With::Deep::Name',
- dir => $tmp, xs => 1 );
-$dist->regen;
-$dist->chdir_in;
+
+$dist->reset( name => 'Simple::With::Deep::Name', dir => $tmp, xs => 1 );
+$dist->chdir_in->regen;
$mb = Module::Build->new_from_context;
is $@, '';
@@ -132,16 +123,12 @@
$mb->dispatch('realclean');
is $@, '';
-# cleanup
-$dist->remove;
-
-
########################################
# Try a XS distro using a flat directory structure
# and a 'dist_name' instead of a 'module_name'
-$dist = DistGen->new( name => 'Dist-Name', dir => $tmp, xs => 1 );
+$dist->reset( name => 'Dist-Name', dir => $tmp, xs => 1 )->chdir_in;
$dist->remove_file('lib/Dist-Name.pm');
$dist->remove_file('lib/Dist-Name.xs');
@@ -211,10 +198,8 @@
---
$dist->regen;
-$dist->chdir_in;
-
-$mb = Module::Build->new_from_context;
+$mb = $dist->new_from_context;
is $@, '';
$mb->dispatch('build');
@@ -226,5 +211,3 @@
$mb->dispatch('realclean');
is $@, '';
-# cleanup
-$dist->remove;