Author: kwilliams
Date: Mon Jan 28 16:01:11 2008
New Revision: 10663

Modified:
   Module-Build/trunk/t/basic.t
   Module-Build/trunk/t/compat.t
   Module-Build/trunk/t/destinations.t
   Module-Build/trunk/t/extend.t
   Module-Build/trunk/t/files.t
   Module-Build/trunk/t/install.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/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/runthrough.t
   Module-Build/trunk/t/signature.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/versions.t
   Module-Build/trunk/t/xs.t

Log:
Simplify our cleanup code

Modified: Module-Build/trunk/t/basic.t
==============================================================================
--- Module-Build/trunk/t/basic.t        (original)
+++ Module-Build/trunk/t/basic.t        Mon Jan 28 16:01:11 2008
@@ -7,8 +7,6 @@
 use_ok 'Module::Build';
 ensure_blib('Module::Build');
 
-use Cwd ();
-my $cwd = Cwd::cwd;
 my $tmp = MBTest->tmpdir;
 
 use DistGen;
@@ -165,7 +163,6 @@
   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;
@@ -208,8 +205,4 @@
 
 
 # cleanup
-chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
 $dist->remove;
-
-use File::Path;
-rmtree( $tmp );

Modified: Module-Build/trunk/t/compat.t
==============================================================================
--- Module-Build/trunk/t/compat.t       (original)
+++ Module-Build/trunk/t/compat.t       Mon Jan 28 16:01:11 2008
@@ -374,8 +374,4 @@
 }
 
 # cleanup
-chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
 $dist->remove;
-
-use File::Path;
-rmtree( $tmp );

Modified: Module-Build/trunk/t/destinations.t
==============================================================================
--- Module-Build/trunk/t/destinations.t (original)
+++ Module-Build/trunk/t/destinations.t Mon Jan 28 16:01:11 2008
@@ -7,8 +7,6 @@
 use_ok 'Module::Build';
 ensure_blib('Module::Build');
 
-use Cwd ();
-my $cwd = Cwd::cwd;
 my $tmp = MBTest->tmpdir;
 
 use DistGen;
@@ -323,8 +321,4 @@
 }
 
 
-chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
 $dist->remove;
-
-use File::Path;
-rmtree( $tmp );

Modified: Module-Build/trunk/t/extend.t
==============================================================================
--- Module-Build/trunk/t/extend.t       (original)
+++ Module-Build/trunk/t/extend.t       Mon Jan 28 16:01:11 2008
@@ -7,8 +7,6 @@
 use_ok 'Module::Build';
 ensure_blib('Module::Build');
 
-use Cwd ();
-my $cwd = Cwd::cwd;
 my $tmp = MBTest->tmpdir;
 
 use DistGen;
@@ -276,8 +274,4 @@
 }
 
 # cleanup
-chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
 $dist->remove;
-
-use File::Path;
-rmtree( $tmp );

Modified: Module-Build/trunk/t/files.t
==============================================================================
--- Module-Build/trunk/t/files.t        (original)
+++ Module-Build/trunk/t/files.t        Mon Jan 28 16:01:11 2008
@@ -8,8 +8,6 @@
 ensure_blib('Module::Build');
 
 use IO::File;
-use Cwd ();
-my $cwd = Cwd::cwd;
 my $tmp = MBTest->tmpdir;
 
 use DistGen;
@@ -61,8 +59,4 @@
 }
 
 # cleanup
-chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
 $dist->remove;
-
-use File::Path;
-rmtree( $tmp );

Modified: Module-Build/trunk/t/install.t
==============================================================================
--- Module-Build/trunk/t/install.t      (original)
+++ Module-Build/trunk/t/install.t      Mon Jan 28 16:01:11 2008
@@ -226,7 +226,6 @@
   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;
@@ -247,8 +246,4 @@
 
 
 # cleanup
-chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
 $dist->remove;
-
-use File::Path;
-rmtree( $tmp );

Modified: Module-Build/trunk/t/lib/DistGen.pm
==============================================================================
--- Module-Build/trunk/t/lib/DistGen.pm (original)
+++ Module-Build/trunk/t/lib/DistGen.pm Mon Jan 28 16:01:11 2008
@@ -20,11 +20,11 @@
 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 {
   use Exporter 'import';
@@ -33,14 +33,6 @@
   );
 }
 
-# not methods
-*ScopeGuard::DESTROY = sub {
-  my $self = shift;
-  return unless($self and @$self);
-  $self->[0]->()
-};
-sub scoped { my ($sub) = @_; bless([$sub], 'ScopeGuard'); }
-
 sub undent {
   my ($string) = @_;
 
@@ -65,6 +57,9 @@
   );
   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';
@@ -368,7 +363,7 @@
 sub remove {
   my $self = shift;
   croak("invalid usage -- remove()") if(@_);
-  File::Path::rmtree( File::Spec->canonpath($self->dirname) );
+  File::Path::rmtree( $self->dirname );
 }
 
 sub revert {

Modified: Module-Build/trunk/t/manifypods.t
==============================================================================
--- Module-Build/trunk/t/manifypods.t   (original)
+++ Module-Build/trunk/t/manifypods.t   Mon Jan 28 16:01:11 2008
@@ -139,7 +139,6 @@
 
 
 # revert to a pristine state
-chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
 $dist->remove;
 $dist = DistGen->new( dir => $tmp );
 $dist->regen;
@@ -166,8 +165,4 @@
 
 
 # cleanup
-chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
 $dist->remove;
-
-use File::Path;
-rmtree( $tmp );

Modified: Module-Build/trunk/t/metadata.t
==============================================================================
--- Module-Build/trunk/t/metadata.t     (original)
+++ Module-Build/trunk/t/metadata.t     Mon Jan 28 16:01:11 2008
@@ -7,8 +7,6 @@
 use_ok 'Module::Build';
 ensure_blib('Module::Build');
 
-use Cwd ();
-my $cwd = Cwd::cwd;
 my $tmp = MBTest->tmpdir;
 
 use Module::Build::ConfigData;
@@ -583,8 +581,4 @@
 
 ############################################################
 # cleanup
-chdir( $cwd ) or die "Can't chdir to '$cwd': $!";
 $dist->remove;
-
-use File::Path;
-rmtree( $tmp );

Modified: Module-Build/trunk/t/metadata2.t
==============================================================================
--- Module-Build/trunk/t/metadata2.t    (original)
+++ Module-Build/trunk/t/metadata2.t    Mon Jan 28 16:01:11 2008
@@ -7,8 +7,6 @@
 use_ok 'Module::Build';
 ensure_blib('Module::Build');
 
-use Cwd ();
-my $cwd = Cwd::cwd;
 my $tmp = MBTest->tmpdir;
 
 use Module::Build::ConfigData;
@@ -38,7 +36,6 @@
 
   ok -e 'META.yml';
 
-  chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
   $dist->remove;
 }
 
@@ -145,8 +142,4 @@
 
 ############################################################
 # cleanup
-chdir( $cwd ) or die "Can't chdir to '$cwd': $!";
 $dist->remove;
-
-use File::Path;
-rmtree( $tmp );

Modified: Module-Build/trunk/t/moduleinfo.t
==============================================================================
--- Module-Build/trunk/t/moduleinfo.t   (original)
+++ Module-Build/trunk/t/moduleinfo.t   Mon Jan 28 16:01:11 2008
@@ -9,8 +9,6 @@
 use_ok 'Module::Build::ModuleInfo';
 ensure_blib('Module::Build::ModuleInfo');
 
-use Cwd ();
-my $cwd = Cwd::cwd;
 my $tmp = MBTest->tmpdir;
 
 use DistGen;
@@ -201,7 +199,6 @@
 }
 
 # revert to pristine state
-chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
 $dist->remove;
 $dist = DistGen->new( dir => $tmp );
 $dist->regen;
@@ -260,7 +257,6 @@
 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;
@@ -443,8 +439,4 @@
 
 
 # cleanup
-chdir( $cwd ) or die "Can't chdir to '$cwd': $!";
 $dist->remove;
-
-use File::Path;
-rmtree( $tmp );

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     Mon Jan 28 16:01:11 2008
@@ -8,8 +8,6 @@
 ensure_blib('Module::Build');
 
 use IO::File;
-use Cwd ();
-my $cwd = Cwd::cwd;
 my $tmp = MBTest->tmpdir;
 
 use DistGen;
@@ -28,10 +26,6 @@
 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

Modified: Module-Build/trunk/t/notes.t
==============================================================================
--- Module-Build/trunk/t/notes.t        (original)
+++ Module-Build/trunk/t/notes.t        Mon Jan 28 16:01:11 2008
@@ -7,8 +7,6 @@
 use_ok 'Module::Build';
 ensure_blib('Module::Build');
 
-use Cwd ();
-my $cwd = Cwd::cwd;
 my $tmp = MBTest->tmpdir;
 
 use DistGen;
@@ -69,8 +67,4 @@
 
 
 # cleanup
-chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
 $dist->remove;
-
-use File::Path;
-rmtree( $tmp );

Modified: Module-Build/trunk/t/par.t
==============================================================================
--- Module-Build/trunk/t/par.t  (original)
+++ Module-Build/trunk/t/par.t  Mon Jan 28 16:01:11 2008
@@ -23,8 +23,6 @@
 ensure_blib('Module::Build');
 
 
-use Cwd ();
-my $cwd = Cwd::cwd;
 my $tmp = MBTest->tmpdir;
 
 
@@ -83,9 +81,4 @@
   'Distribution contains META.yml'
 );
 
-$dist->clean();
-
-chdir( $cwd );
-use File::Path;
-rmtree( $tmp );
-
+$dist->remove;

Modified: Module-Build/trunk/t/ppm.t
==============================================================================
--- Module-Build/trunk/t/ppm.t  (original)
+++ Module-Build/trunk/t/ppm.t  Mon Jan 28 16:01:11 2008
@@ -27,8 +27,6 @@
 ensure_blib('Module::Build');
 
 
-use Cwd ();
-my $cwd = Cwd::cwd;
 my $tmp = MBTest->tmpdir;
 
 
@@ -182,12 +180,8 @@
 }
 
 
-chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
 $dist->remove;
 
-use File::Path;
-rmtree( $tmp );
-
 
 ########################################
 

Modified: Module-Build/trunk/t/runthrough.t
==============================================================================
--- Module-Build/trunk/t/runthrough.t   (original)
+++ Module-Build/trunk/t/runthrough.t   Mon Jan 28 16:01:11 2008
@@ -12,8 +12,6 @@
 
 #########################
 
-use Cwd ();
-my $cwd = Cwd::cwd;
 my $tmp = MBTest->tmpdir;
 
 use DistGen;
@@ -199,7 +197,6 @@
 ok ! -e $mb->config_dir;
 ok ! -e $mb->dist_dir;
 
-chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
 $dist->remove;
 
 SKIP: {
@@ -234,13 +231,8 @@
   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 );

Modified: Module-Build/trunk/t/signature.t
==============================================================================
--- Module-Build/trunk/t/signature.t    (original)
+++ Module-Build/trunk/t/signature.t    Mon Jan 28 16:01:11 2008
@@ -19,8 +19,6 @@
 
 #########################
 
-use Cwd ();
-my $cwd = Cwd::cwd;
 my $tmp = MBTest->tmpdir;
 
 use DistGen;
@@ -102,8 +100,4 @@
 }
 
 # cleanup
-chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
 $dist->remove;
-
-use File::Path;
-rmtree( $tmp );

Modified: Module-Build/trunk/t/test_type.t
==============================================================================
--- Module-Build/trunk/t/test_type.t    (original)
+++ Module-Build/trunk/t/test_type.t    Mon Jan 28 16:01:11 2008
@@ -7,8 +7,6 @@
 use_ok 'Module::Build';
 ensure_blib('Module::Build');
 
-use Cwd ();
-my $cwd = Cwd::cwd;
 my $tmp = MBTest->tmpdir;
 
 use DistGen;
@@ -67,7 +65,6 @@
 
 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

Modified: Module-Build/trunk/t/test_types.t
==============================================================================
--- Module-Build/trunk/t/test_types.t   (original)
+++ Module-Build/trunk/t/test_types.t   Mon Jan 28 16:01:11 2008
@@ -7,8 +7,6 @@
 use_ok 'Module::Build';
 ensure_blib('Module::Build');
 
-use Cwd ();
-my $cwd = Cwd::cwd();
 my $tmp = MBTest->tmpdir;
 
 use DistGen;
@@ -102,7 +100,6 @@
 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
@@ -180,7 +177,6 @@
 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
 

Modified: Module-Build/trunk/t/tilde.t
==============================================================================
--- Module-Build/trunk/t/tilde.t        (original)
+++ Module-Build/trunk/t/tilde.t        Mon Jan 28 16:01:11 2008
@@ -9,8 +9,6 @@
 use_ok 'Module::Build';
 ensure_blib('Module::Build');
 
-use Cwd ();
-my $cwd = Cwd::cwd;
 my $tmp = MBTest->tmpdir;
 
 use DistGen;
@@ -92,8 +90,4 @@
 
 
 # cleanup
-chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
 $dist->remove;
-
-use File::Path;
-rmtree( $tmp );

Modified: Module-Build/trunk/t/versions.t
==============================================================================
--- Module-Build/trunk/t/versions.t     (original)
+++ Module-Build/trunk/t/versions.t     Mon Jan 28 16:01:11 2008
@@ -7,8 +7,6 @@
 use_ok 'Module::Build';
 ensure_blib('Module::Build');
 
-use Cwd ();
-my $cwd = Cwd::cwd;
 my $tmp = MBTest->tmpdir;
 
 use DistGen;
@@ -26,6 +24,3 @@
 
 # cleanup
 $dist->remove;
-
-use File::Path;
-rmtree( $tmp );

Modified: Module-Build/trunk/t/xs.t
==============================================================================
--- Module-Build/trunk/t/xs.t   (original)
+++ Module-Build/trunk/t/xs.t   Mon Jan 28 16:01:11 2008
@@ -23,8 +23,6 @@
 #########################
 
 
-use Cwd ();
-my $cwd = Cwd::cwd;
 my $tmp = MBTest->tmpdir;
 
 use DistGen;
@@ -104,7 +102,6 @@
 
 
 # cleanup
-chdir( $cwd ) or die "Can't chdir to '$cwd': $!";
 $dist->remove;
 
 
@@ -130,7 +127,6 @@
 is $@, '';
 
 # cleanup
-chdir( $cwd ) or die "Can't chdir to '$cwd': $!";
 $dist->remove;
 
 
@@ -225,8 +221,4 @@
 is $@, '';
 
 # cleanup
-chdir( $cwd ) or die "Can't chdir to '$cwd': $!";
 $dist->remove;
-
-use File::Path;
-rmtree( $tmp );

Reply via email to