ExtUtils::Install and the don't-really-do-it switch
Slaven Rezic [Thu, 24 Apr 2003 00:42:11 +0000 (02:42 +0200)]
Message-Id: <200304232242.h3NMgBqD028515@vran.herceg.de>

p4raw-id: //depot/perl@19421

lib/ExtUtils/Install.pm
lib/ExtUtils/t/Install.t

index 5763f1b..68fe343 100644 (file)
@@ -108,13 +108,20 @@ sub install {
        for (readdir DIR) {
            next if $_ eq $Curdir || $_ eq $Updir || $_ eq ".exists";
             my $targetdir = install_rooted_dir($from_to{$source_dir_or_file});
-           if (-w $targetdir ||
-               mkpath($targetdir)) {
+           if ($nonono) {
+               if (!-w $targetdir) {
+                   print "mkpath($targetdir)\n" if $verbose>1;
+               }
                last;
            } else {
-               warn "Warning: You do not have permissions to " .
-                   "install into $from_to{$source_dir_or_file}"
-                   unless $warn_permissions++;
+               if (-w $targetdir ||
+                   mkpath($targetdir)) {
+                   last;
+               } else {
+                   warn "Warning: You do not have permissions to " .
+                       "install into $from_to{$source_dir_or_file}"
+                           unless $warn_permissions++;
+               }
            }
        }
        closedir DIR;
@@ -203,9 +210,9 @@ sub install {
     }
     if ($pack{'write'}) {
        $dir = install_rooted_dir(dirname($pack{'write'}));
-       mkpath($dir,0,0755);
+       mkpath($dir,0,0755) unless $nonono;
        print "Writing $pack{'write'}\n";
-       $packlist->write(install_rooted_file($pack{'write'}));
+       $packlist->write(install_rooted_file($pack{'write'})) unless $nonono;
     }
 }
 
index c9463e7..c628333 100644 (file)
@@ -17,7 +17,7 @@ use TieOut;
 use File::Path;
 use File::Spec;
 
-use Test::More tests => 18;
+use Test::More tests => 21;
 
 BEGIN { use_ok('ExtUtils::Install') }
 
@@ -46,6 +46,14 @@ ok( -r 'blib/lib/Big/Dummy.pm', '  .pm file still there' );
 ok( -r 'blib/lib/auto',         '  autosplit still there' );
 is( $stdout->read, "Skip blib/lib/Big/Dummy.pm (unchanged)\n" );
 
+install( { 'blib/lib' => 'install-test/lib/perl',
+           read   => 'install-test/packlist',
+           write  => 'install-test/packlist'
+         },
+       0, 1);
+ok( ! -d 'install-test/lib/perl',                 'install made dir - dry run' );
+ok( ! -r 'install-test/lib/perl/Big/Dummy.pm',    '  .pm file installed - dry run' );
+ok( ! -r 'install-test/packlist',                 '  packlist exists - dry run' );
 
 install( { 'blib/lib' => 'install-test/lib/perl',
            read   => 'install-test/packlist',