From: Peter Rabbitson Date: Tue, 1 Mar 2016 20:49:56 +0000 (+0100) Subject: Several cosmetic fixups, making next commit easier to read X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=aff5e9c14f7ad7453a4a2a7d04dc4e85fa0d661c;p=dbsrgits%2FDBIx-Class.git Several cosmetic fixups, making next commit easier to read No notable functional changes, mostly de-File::Spec-ing spots that do not need it ( '/' works on Win32 just fine, and VMS is a looooong way off ) --- diff --git a/Makefile.PL b/Makefile.PL index 0be14e8..c6b5273 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -236,11 +236,10 @@ sub invoke_author_mode { "\t" . $mm_proto->oneliner( qq(\$ENV{PERLIO}='unix' and system( \$^X, qw( -MExtUtils::Command -e dos2unix -- ), $targets ) ) ); }; - require File::Spec; # string-eval, not do(), because we need to provide the # $mm_proto, $reqs and $*_requires lexicals to the included file # (some includes *do* modify $reqs above) - for my $inc (sort glob ( File::Spec->catfile('maint', 'Makefile.PL.inc', '*') ) ) { + for my $inc (sort glob ( 'maint/Makefile.PL.inc/*' ) ) { my $src = do { local (@ARGV, $/) = $inc; <> } or die $!; eval "use warnings; use strict; $src" or die sprintf "Failed execution of %s: %s\n", diff --git a/lib/DBIx/Class/Admin.pm b/lib/DBIx/Class/Admin.pm index 60d8c9e..f3e6b58 100644 --- a/lib/DBIx/Class/Admin.pm +++ b/lib/DBIx/Class/Admin.pm @@ -340,7 +340,13 @@ sub create { my $schema = $self->schema(); - $schema->create_ddl_dir( $sqlt_type, (defined $schema->schema_version ? $schema->schema_version : ""), $self->sql_dir->stringify, $preversion, $sqlt_args ); + $schema->create_ddl_dir( + $sqlt_type, + (defined $schema->schema_version ? $schema->schema_version : ""), + $self->sql_dir, + $preversion, + $sqlt_args, + ); } diff --git a/lib/DBIx/Class/InflateColumn/File.pm b/lib/DBIx/Class/InflateColumn/File.pm index 3a515a8..b983985 100644 --- a/lib/DBIx/Class/InflateColumn/File.pm +++ b/lib/DBIx/Class/InflateColumn/File.pm @@ -3,7 +3,6 @@ package DBIx::Class::InflateColumn::File; use strict; use warnings; use base 'DBIx::Class'; -use File::Path; use File::Copy; use Path::Class; use DBIx::Class::Carp; @@ -20,7 +19,6 @@ carp 'InflateColumn::File has entered a deprecation cycle. This component ' unless $ENV{DBIC_IC_FILE_NOWARN}; - __PACKAGE__->load_components(qw/InflateColumn/); sub register_column { @@ -68,7 +66,7 @@ sub delete { for ( keys %$colinfos ) { if ( $colinfos->{$_}{is_file_column} ) { - rmtree( [$self->_file_column_file($_)->dir], 0, 0 ); + $self->_file_column_file($_)->dir->rmtree; last; # if we've deleted one, we've deleted them all } } @@ -116,7 +114,7 @@ sub _save_file_column { return unless ref $value; my $fs_file = $self->_file_column_file($column, $value->{filename}); - mkpath [$fs_file->dir]; + $fs_file->dir->mkpath; # File::Copy doesn't like Path::Class (or any for that matter) objects, # thus ->stringify (http://rt.perl.org/rt3/Public/Bug/Display.html?id=59650) diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index 0be8919..1742705 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -1240,14 +1240,12 @@ format. sub ddl_filename { my ($self, $type, $version, $dir, $preversion) = @_; - require File::Spec; - $version = "$preversion-$version" if $preversion; my $class = blessed($self) || $self; $class =~ s/::/-/g; - return File::Spec->catfile($dir, "$class-$version-$type.sql"); + return "$dir/$class-$version-$type.sql"; } =head2 thaw diff --git a/maint/Makefile.PL.inc/11_authortests.pl b/maint/Makefile.PL.inc/11_authortests.pl index 77bb071..0643ca9 100644 --- a/maint/Makefile.PL.inc/11_authortests.pl +++ b/maint/Makefile.PL.inc/11_authortests.pl @@ -1,4 +1,3 @@ -require File::Spec; require File::Find; my $xt_dist_dirs; @@ -9,7 +8,7 @@ File::Find::find(sub { ); }, 'xt/dist'); -my @xt_dist_tests = map { File::Spec->catfile($_, '*.t') } sort keys %$xt_dist_dirs; +my @xt_dist_tests = map { "$_/*.t" } sort keys %$xt_dist_dirs; # inject an explicit xt test run, mainly to check the contents of # lib and the generated POD's *before* anything is copied around diff --git a/maint/Makefile.PL.inc/12_authordeps.pl b/maint/Makefile.PL.inc/12_authordeps.pl index e6d7f34..405bc1e 100644 --- a/maint/Makefile.PL.inc/12_authordeps.pl +++ b/maint/Makefile.PL.inc/12_authordeps.pl @@ -120,7 +120,7 @@ END { unlink 'Makefile'; exit 1; } - my $meta = do { local @ARGV = 'META.yml'; local $/; <> }; + my $meta = do { local (@ARGV, $/) = 'META.yml'; <> }; $meta =~ /^\Qname: DBIx-Class\E$/m or do { warn "Seemingly malformed META.yml...?\n"; diff --git a/maint/Makefile.PL.inc/53_autogen_pod.pl b/maint/Makefile.PL.inc/53_autogen_pod.pl index ff72fd9..c350734 100644 --- a/maint/Makefile.PL.inc/53_autogen_pod.pl +++ b/maint/Makefile.PL.inc/53_autogen_pod.pl @@ -4,7 +4,7 @@ use File::Glob(); # leftovers in old checkouts unlink 'lib/DBIx/Class/Optional/Dependencies.pod' if -f 'lib/DBIx/Class/Optional/Dependencies.pod'; -File::Path::rmtree( File::Glob::bsd_glob('.generated_pod'), { verbose => 0 } ) +File::Path::rmtree([ '.generated_pod' ]) if -d '.generated_pod'; my $pod_dir = 'maint/.Generated_Pod'; @@ -12,7 +12,7 @@ my $ver = Meta->version; # cleanup the generated pod dir (again - kill leftovers from old checkouts) if (-d $pod_dir) { - File::Path::rmtree( File::Glob::bsd_glob("$pod_dir/*"), { verbose => 0 } ); + File::Path::rmtree([ File::Glob::bsd_glob("$pod_dir/*") ]); } else { mkdir $pod_dir or die "Unable to create $pod_dir: $!"; @@ -95,7 +95,7 @@ EOP # generate the DBIx/Class.pod only during distdir { - my $dist_pod_fn = File::Spec->catfile($pod_dir, qw(lib DBIx Class.pod)); + my $dist_pod_fn = "$pod_dir/lib/DBIx/Class.pod"; postamble <<"EOP"; @@ -146,7 +146,7 @@ clonedir_post_generate_files : dbic_clonedir_copy_generated_pod dbic_clonedir_copy_generated_pod : \t\$(RM_F) $pod_dir.packlist \t@{[ - $mm_proto->oneliner("install([ from_to => {q($pod_dir) => File::Spec->curdir(), write => q($pod_dir.packlist)}, verbose => 0, uninstall_shadows => 0, skip => [] ])", ['-MExtUtils::Install']) + $mm_proto->oneliner("install([ from_to => {q($pod_dir) => './', write => q($pod_dir.packlist)}, verbose => 0, uninstall_shadows => 0, skip => [] ])", ['-MExtUtils::Install']) ]} EOP diff --git a/maint/Makefile.PL.inc/54_autogen_legalese_and_README.pl b/maint/Makefile.PL.inc/54_autogen_legalese_and_README.pl index 8b96f50..16259af 100644 --- a/maint/Makefile.PL.inc/54_autogen_legalese_and_README.pl +++ b/maint/Makefile.PL.inc/54_autogen_legalese_and_README.pl @@ -5,9 +5,8 @@ unlink 'README' if -f 'README'; # and simply appends them on *LAST*-come *FIRST*-serve basis. # This allows us to inject extra depenencies for standard EUMM targets -require File::Spec; -my $dir = File::Spec->catdir(qw(maint .Generated_Pod)); -my $r_fn = File::Spec->catfile($dir, 'README'); +my $dir = 'maint/.Generated_Pod'; +my $r_fn = "$dir/README"; my $start_file = sub { my $fn = $mm_proto->quote_literal(shift); @@ -32,7 +31,7 @@ dbic_clonedir_gen_readme : dbic_distdir_gen_dbic_pod create_distdir : dbic_distdir_regen_license dbic_distdir_regen_license : -@{[ $start_file->( File::Spec->catfile( Meta->name . '-' . Meta->version, 'LICENSE') ) ]} +@{[ $start_file->( Meta->name . '-' . Meta->version . '/LICENSE' ) ]} \t@{[ $mm_proto->oneliner('cat', ['-MExtUtils::Command']) ]} LICENSE >> \$(DISTVNAME)/LICENSE EOP diff --git a/maint/Makefile.PL.inc/56_autogen_schema_files.pl b/maint/Makefile.PL.inc/56_autogen_schema_files.pl index 0cd34a0..2e1efb9 100644 --- a/maint/Makefile.PL.inc/56_autogen_schema_files.pl +++ b/maint/Makefile.PL.inc/56_autogen_schema_files.pl @@ -1,9 +1,8 @@ -require File::Spec; -my $test_ddl_fn = File::Spec->catfile(qw( t lib sqlite.sql )); +my $test_ddl_fn = 't/lib/sqlite.sql'; my @test_ddl_cmd = qw( -I lib -Mt::lib::ANFANG -- maint/gen_sqlite_schema_files --schema-class DBICTest::Schema ); -my $example_ddl_fn = File::Spec->catfile(qw( examples Schema db example.sql )); -my $example_db_fn = File::Spec->catfile(qw( examples Schema db example.db )); +my $example_ddl_fn = 'examples/Schema/db/example.sql'; +my $example_db_fn = 'examples/Schema/db/example.db'; my @example_ddl_cmd = qw( -I lib -I examples/Schema -- maint/gen_sqlite_schema_files --schema-class MyApp::Schema ); my @example_pop_cmd = qw( -I lib -I examples/Schema -- examples/Schema/insertdb.pl ); @@ -23,6 +22,7 @@ if ( DBIx::Class::Optional::Dependencies->req_ok_for ('deploy') ) { # if we don't do it some git tools (e.g. gitk) get confused that the # ddl file is modified, when it clearly isn't + require File::Spec; system('git status --porcelain >' . File::Spec->devnull); } diff --git a/t/52leaks.t b/t/52leaks.t index cfeaadc..6298c98 100644 --- a/t/52leaks.t +++ b/t/52leaks.t @@ -538,6 +538,8 @@ SKIP: { local $ENV{DBICTEST_IN_PERSISTENT_ENV} = 1; + require File::Spec; + $persistence_tests = { PPerl => { cmd => [qw/pperl --prefork=1/, __FILE__], diff --git a/t/admin/02ddl.t b/t/admin/02ddl.t index 9b6d9e5..84a7381 100644 --- a/t/admin/02ddl.t +++ b/t/admin/02ddl.t @@ -31,7 +31,7 @@ my $ddl_dir = dir(qw/t var/, "admin_ddl-$$"); { # create the schema # make sure we are clean -clean_dir($ddl_dir); +cleanup(); my $admin = DBIx::Class::Admin->new( @@ -50,7 +50,7 @@ lives_ok { { # upgrade schema -clean_dir($ddl_dir); +cleanup(); require DBICVersion_v1; my $admin = DBIx::Class::Admin->new( @@ -92,7 +92,7 @@ is($schema->get_db_version, $DBICVersion::Schema::VERSION, 'Schema and db versio { # install -clean_dir($ddl_dir); +cleanup(); my $admin = DBIx::Class::Admin->new( schema_class => 'DBICVersion::Schema', @@ -115,14 +115,14 @@ warnings_exist ( sub { is($admin->schema->get_db_version, "4.0", 'db thinks its version 4.0'); } -sub clean_dir { +sub cleanup { my ($dir) = @_; - $dir->rmtree if -d $dir; + $ddl_dir->rmtree if -d $ddl_dir; unlink $db_fn; } END { - clean_dir($ddl_dir); + cleanup(); } done_testing; diff --git a/t/storage/reconnect.t b/t/storage/reconnect.t index 199213b..c19f44f 100644 --- a/t/storage/reconnect.t +++ b/t/storage/reconnect.t @@ -3,9 +3,7 @@ BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } use strict; use warnings; -use FindBin; use B::Deparse; -use File::Copy 'move'; use Scalar::Util 'weaken'; use Test::More; use Test::Exception; @@ -48,7 +46,7 @@ cmp_ok(@art_two, '==', 3, "Three artists returned"); ### Now, disconnect the dbh, and move the db file; # create a new one full of garbage, prevent SQLite from connecting. $schema->storage->_dbh->disconnect; -move( $db_orig, $db_tmp ) +rename( $db_orig, $db_tmp ) or die "failed to move $db_orig to $db_tmp: $!"; open my $db_file, '>', $db_orig; print $db_file 'THIS IS NOT A REAL DATABASE'; @@ -67,7 +65,7 @@ ok (! $schema->storage->connected, 'We are not connected' ); ### Now, move the db file back to the correct name unlink($db_orig) or die "could not delete $db_orig: $!"; -move( $db_tmp, $db_orig ) +rename( $db_tmp, $db_orig ) or die "could not move $db_tmp to $db_orig: $!"; ### Try the operation again... this time, it should succeed diff --git a/t/storage/replicated.t b/t/storage/replicated.t index 8696ba2..9ecc7e8 100644 --- a/t/storage/replicated.t +++ b/t/storage/replicated.t @@ -19,14 +19,12 @@ BEGIN { use Test::Moose; use Test::Exception; -use List::Util 'first'; use Scalar::Util 'reftype'; -use File::Spec; use Moose(); use MooseX::Types(); note "Using Moose version $Moose::VERSION and MooseX::Types version $MooseX::Types::VERSION"; -my $var_dir = quotemeta ( File::Spec->catdir(qw/t var/) ); +my $var_dir_re = qr{ t [\/\\] var [\/\\] }x; ## Add a connect_info option to test option merging. use DBIx::Class::Storage::DBI::Replicated; @@ -157,8 +155,8 @@ TESTSCHEMACLASSES: { $self->master_path( DBICTest->_sqlite_dbfilename ); $self->slave_paths([ - File::Spec->catfile(qw/t var DBIxClass_slave1.db/), - File::Spec->catfile(qw/t var DBIxClass_slave2.db/), + 't/var/DBIxClass_slave1.db', + 't/var/DBIxClass_slave2.db', ]); return $self; @@ -376,7 +374,7 @@ ok @replicant_names, "found replicant names @replicant_names"; ## Silence warning about not supporting the is_replicating method if using the ## sqlite dbs. $replicated->schema->storage->debugobj->silence(1) - if first { $_ =~ /$var_dir/ } @replicant_names; + if grep { $_ =~ $var_dir_re } @replicant_names; isa_ok $replicated->schema->storage->balancer->current_replicant => 'DBIx::Class::Storage::DBI'; @@ -424,7 +422,7 @@ $replicated->schema->storage->replicants->{$replicant_names[1]}->active(1); ## Silence warning about not supporting the is_replicating method if using the ## sqlite dbs. $replicated->schema->storage->debugobj->silence(1) - if first { $_ =~ /$var_dir/ } @replicant_names; + if grep { $_ =~ $var_dir_re } @replicant_names; $replicated->schema->storage->pool->validate_replicants; @@ -607,7 +605,7 @@ $replicated->schema->storage->replicants->{$replicant_names[1]}->active(1); ## Silence warning about not supporting the is_replicating method if using the ## sqlite dbs. $replicated->schema->storage->debugobj->silence(1) - if first { $_ =~ /$var_dir/ } @replicant_names; + if grep { $_ =~ $var_dir_re } @replicant_names; $replicated->schema->storage->pool->validate_replicants; diff --git a/xt/extra/dbicadmin.t b/xt/extra/dbicadmin.t index 3f05ac2..db254f8 100644 --- a/xt/extra/dbicadmin.t +++ b/xt/extra/dbicadmin.t @@ -13,7 +13,6 @@ use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_admin_script' use Test::More; use Config; -use File::Spec; use DBICTest; @@ -103,7 +102,7 @@ sub default_args { sub test_exec { my ($perl) = $^X =~ /(.*)/; - my @args = ($perl, '-MANFANG', File::Spec->catfile(qw(script dbicadmin)), @_); + my @args = ($perl, '-MANFANG', 'script/dbicadmin', @_); if ($^O eq 'MSWin32') { require Win32::ShellQuote; # included in test optdeps