[Bast-commits] r9546 - in DBIx-Class/0.08/trunk: . lib/DBIx/Class/Storage t/storage

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Wed Jun 2 11:22:20 GMT 2010


Author: ribasushi
Date: 2010-06-02 12:22:20 +0100 (Wed, 02 Jun 2010)
New Revision: 9546

Modified:
   DBIx-Class/0.08/trunk/Changes
   DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
   DBIx-Class/0.08/trunk/t/storage/deploy.t
Log:
Make sure ddl_dir is created even if a dir-object is supplied

Modified: DBIx-Class/0.08/trunk/Changes
===================================================================
--- DBIx-Class/0.08/trunk/Changes	2010-06-02 10:55:53 UTC (rev 9545)
+++ DBIx-Class/0.08/trunk/Changes	2010-06-02 11:22:20 UTC (rev 9546)
@@ -27,6 +27,8 @@
         - Sybase ASE driver now uses SET ROWCOUNT where possible, and
           Generic Subquery otherwise for limit support instead of always
           using software limit emulation
+        - create_ddl_dir (and derivatives) now attempt to create the given
+          $ddl_dir if it does not already exist
 
     * Fixes
         - Fix nasty potentially data-eating bug when deleting/updating

Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm	2010-06-02 10:55:53 UTC (rev 9545)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm	2010-06-02 11:22:20 UTC (rev 9546)
@@ -15,7 +15,7 @@
 use Data::Dumper::Concise 'Dumper';
 use Sub::Name 'subname';
 use Try::Tiny;
-use File::Path 'mkpath';
+use File::Path 'make_path';
 use namespace::clean;
 
 __PACKAGE__->mk_group_accessors('simple' => qw/
@@ -2331,8 +2331,13 @@
     carp "No directory given, using ./\n";
     $dir = './';
   } else {
-      -d $dir or mkpath $dir
-          or $self->throw_exception("create_ddl_dir: $! creating dir '$dir'");
+      -d $dir
+        or
+      make_path ("$dir")  # make_path does not like objects (i.e. Path::Class::Dir)
+        or
+      $self->throw_exception(
+        "Failed to create '$dir': " . ($! || $@ || 'error unknow')
+      );
   }
 
   $self->throw_exception ("Directory '$dir' does not exist\n") unless(-d $dir);

Modified: DBIx-Class/0.08/trunk/t/storage/deploy.t
===================================================================
--- DBIx-Class/0.08/trunk/t/storage/deploy.t	2010-06-02 10:55:53 UTC (rev 9545)
+++ DBIx-Class/0.08/trunk/t/storage/deploy.t	2010-06-02 11:22:20 UTC (rev 9546)
@@ -14,20 +14,20 @@
 }
 
 use File::Spec;
-use File::Path qw/ mkpath rmtree /;
-
+use Path::Class qw/dir/;
+use File::Path qw/make_path remove_tree/;
 my $schema = DBICTest->init_schema();
 
-my $var = File::Spec->catfile(qw| t var create_ddl_dir |);
+my $var = dir (qw| t var create_ddl_dir |);
 -d $var
-    or mkpath($var)
-    or die "can't create $var";
+    or make_path( "$var" )
+    or die "can't create $var: $!";
 
-my $test_dir_1 =  File::Spec->catdir( $var, 'test1', 'foo', 'bar' );
-rmtree( $test_dir_1 ) if -d $test_dir_1;
+my $test_dir_1 = $var->subdir ('test1', 'foo', 'bar' );
+remove_tree( "$test_dir_1" ) if -d $test_dir_1;
 $schema->create_ddl_dir( undef, undef, $test_dir_1 );
 
-ok( -d $test_dir_1, 'create_ddl_dir did a mkpath on its target dir' );
+ok( -d $test_dir_1, 'create_ddl_dir did a make_path on its target dir' );
 ok( scalar( glob $test_dir_1.'/*.sql' ), 'there are sql files in there' );
 
 TODO: {




More information about the Bast-commits mailing list