From: Justin Hunter Date: Tue, 14 Apr 2009 17:28:10 +0000 (+0000) Subject: * use $^X instead of assuming /usr/bin/perl X-Git-Tag: 0.04999_07~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=17ca645f6cdce7d820237ec8846e505b5c9a1efc;p=dbsrgits%2FDBIx-Class-Schema-Loader.git * use $^X instead of assuming /usr/bin/perl * give ./script/dbicdump the same @INC as tests * create My::ResultBaseClass and My::SchemaBaseClass for tests * make result_base_class and schema_base_class valid options * move the reading of custom content above the opening of the file for writing --- diff --git a/lib/DBIx/Class/Schema/Loader.pm b/lib/DBIx/Class/Schema/Loader.pm index 2d9a52f..0c3b2a5 100644 --- a/lib/DBIx/Class/Schema/Loader.pm +++ b/lib/DBIx/Class/Schema/Loader.pm @@ -168,7 +168,7 @@ sub connection { my $self = shift; if($_[-1] && ref $_[-1] eq 'HASH') { - for my $option (qw/ loader_class loader_options /) { + for my $option (qw/ loader_class loader_options result_base_class schema_base_class/) { if(my $value = delete $_[-1]->{$option}) { $self->$option($value); } diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index 35ccc20..f7e1051 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -529,6 +529,11 @@ sub _write_classfile { unlink($filename); } + my $custom_content = $self->_get_custom_content($class, $filename); + $custom_content ||= qq|\n\n# You can replace this text with custom| + . qq| content, and it will be preserved on regeneration| + . qq|\n1;\n|; + $text .= qq|$_\n| for @{$self->{_dump_storage}->{$class} || []}; @@ -548,12 +553,6 @@ sub _write_classfile { for @{$self->{_ext_storage}->{$class} || []}; # Write out any custom content the user has added - my $custom_content = $self->_get_custom_content($class, $filename); - - $custom_content ||= qq|\n\n# You can replace this text with custom| - . qq| content, and it will be preserved on regeneration| - . qq|\n1;\n|; - print $fh $custom_content; close($fh) diff --git a/t/23dumpmore.t b/t/23dumpmore.t index 8c0c5b0..3c9cf12 100644 --- a/t/23dumpmore.t +++ b/t/23dumpmore.t @@ -8,7 +8,7 @@ require DBIx::Class::Schema::Loader; $^O eq 'MSWin32' ? plan(skip_all => "ActiveState perl produces additional warnings, and this test uses unix paths") - : plan(tests => 143); + : plan(tests => 145); my $DUMP_PATH = './t/_dump'; @@ -38,7 +38,8 @@ sub dump_directly { sub dump_dbicdump { my %tdata = @_; - my @cmd = qw(./script/dbicdump); + # use $^X so we execute ./script/dbicdump with the same perl binary that the tests were executed with + my @cmd = ($^X, qw(./script/dbicdump)); while (my ($opt, $val) = each(%{ $tdata{options} })) { push @cmd, '-o', "$opt=$val"; @@ -46,6 +47,9 @@ sub dump_dbicdump { push @cmd, $tdata{classname}, $make_dbictest_db::dsn; + # make sure our current @INC gets used by dbicdump + local $ENV{PERL5LIB} = join ":", @INC, $ENV{PERL5LIB}; + my ($in, $out, $err); my $pid = open3($in, $out, $err, @cmd); diff --git a/t/lib/My/ResultBaseClass.pm b/t/lib/My/ResultBaseClass.pm new file mode 100644 index 0000000..1795bfb --- /dev/null +++ b/t/lib/My/ResultBaseClass.pm @@ -0,0 +1,3 @@ +package My::ResultBaseClass; +use base 'DBIx::Class'; +1; diff --git a/t/lib/My/SchemaBaseClass.pm b/t/lib/My/SchemaBaseClass.pm new file mode 100644 index 0000000..4d65380 --- /dev/null +++ b/t/lib/My/SchemaBaseClass.pm @@ -0,0 +1,3 @@ +package My::SchemaBaseClass; +use base 'DBIx::Class::Schema'; +1;