From: Peter Rabbitson Date: Sat, 13 Feb 2010 10:05:17 +0000 (+0000) Subject: Switch tests to Optional::Deps X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ebcd0e4f2fca6179af13aad39a1b0d36d73fbaff;p=dbsrgits%2FDBIx-Class-Historic.git Switch tests to Optional::Deps --- diff --git a/lib/DBIx/Class/Optional/Dependencies.pm b/lib/DBIx/Class/Optional/Dependencies.pm index 50f70a9..99ae149 100644 --- a/lib/DBIx/Class/Optional/Dependencies.pm +++ b/lib/DBIx/Class/Optional/Dependencies.pm @@ -16,6 +16,14 @@ my $moose_basic = { 'MooseX::Types' => '0.21', }; +my $admin_basic = { + %$moose_basic, + 'MooseX::Types::Path::Class' => '0.05', + 'MooseX::Types::JSON' => '0.02', + 'namespace::autoclean' => '0.09', + 'parent' => '0.223', +}; + my $reqs = { dist => { #'Module::Install::Pod::Inherit' => '0.01', @@ -35,11 +43,18 @@ my $reqs = { admin => { req => { + %$admin_basic, + }, + pod => { + title => 'DBIx::Class::Admin', + desc => 'Modules required for the DBIx::Class administrative library', + }, + }, + + dbicadmin => { + req => { %$moose_basic, - 'MooseX::Types::Path::Class'=> '0.05', - 'MooseX::Types::JSON' => '0.02', - 'namespace::autoclean' => '0.09', - 'parent' => '0.223', + %$admin_basic, 'Getopt::Long::Descriptive' => '0.081', 'JSON::Any' => '1.22', 'Text::CSV' => '1.16', diff --git a/t/admin/01load.t b/t/admin/01load.t index 0b5d802..2089607 100644 --- a/t/admin/01load.t +++ b/t/admin/01load.t @@ -3,10 +3,10 @@ use warnings; use Test::More; - BEGIN { - eval "use DBIx::Class::Admin"; - plan skip_all => "Deps not installed: $@" if $@; + require DBIx::Class; + plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for('admin') + unless DBIx::Class::Optional::Dependencies->req_ok_for('admin'); } use_ok 'DBIx::Class::Admin'; diff --git a/t/admin/02ddl.t b/t/admin/02ddl.t index fb0f74c..d7d9d28 100644 --- a/t/admin/02ddl.t +++ b/t/admin/02ddl.t @@ -5,12 +5,14 @@ use Test::More; use Test::Exception; use Test::Warn; - BEGIN { - eval "use DBIx::Class::Admin"; - plan skip_all => "Deps not installed: $@" if $@; -} + require DBIx::Class; + plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for('admin') + unless DBIx::Class::Optional::Dependencies->req_ok_for('admin'); + plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for('deploy') + unless DBIx::Class::Optional::Dependencies->req_ok_for('deploy'); +} use lib qw(t/lib); use DBICTest; @@ -51,7 +53,7 @@ lives_ok { $admin->create('SQLite'); } 'Can Create SQLite sql'; #); clean_dir($sql_dir); -require DBICVersionOrig; +require DBICVersion_v1; my $admin = DBIx::Class::Admin->new( schema_class => 'DBICVersion::Schema', @@ -70,7 +72,7 @@ lives_ok { $schema = DBICVersion::Schema->connect(@{$schema->storage->connect_in is($schema->get_db_version, $DBICVersion::Schema::VERSION, 'Schema deployed and versions match'); -require DBICVersionNew; +require DBICVersion_v2; $admin = DBIx::Class::Admin->new( schema_class => 'DBICVersion::Schema', @@ -79,9 +81,6 @@ $admin = DBIx::Class::Admin->new( ); lives_ok { $admin->create($schema->storage->sqlt_type(), {}, "1.0" ); } 'Can create diff for ' . $schema->storage->sqlt_type; -# sleep required for upgrade table to hold a distinct time of upgrade value -# otherwise the returned of get_db_version can be undeterministic -sleep 1; { local $SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /DB version .+? is lower than the schema version/ }; lives_ok {$admin->upgrade();} 'upgrade the schema'; @@ -106,7 +105,7 @@ $admin->version("3.0"); lives_ok { $admin->install(); } 'install schema version 3.0'; is($admin->schema->get_db_version, "3.0", 'db thinks its version 3.0'); dies_ok { $admin->install("4.0"); } 'cannot install to allready existing version'; -sleep 1; + $admin->force(1); warnings_exist ( sub { lives_ok { $admin->install("4.0") } 'can force install to allready existing version' diff --git a/t/admin/03data.t b/t/admin/03data.t index 3bbdcc5..8bdd562 100644 --- a/t/admin/03data.t +++ b/t/admin/03data.t @@ -7,8 +7,9 @@ use Test::Exception; use Test::Deep; BEGIN { - eval "use DBIx::Class::Admin"; - plan skip_all => "Deps not installed: $@" if $@; + require DBIx::Class; + plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for('admin') + unless DBIx::Class::Optional::Dependencies->req_ok_for('admin'); } use lib 't/lib'; diff --git a/t/admin/10script.t b/t/admin/10script.t index a53ecf1..d8ccbfc 100644 --- a/t/admin/10script.t +++ b/t/admin/10script.t @@ -10,21 +10,11 @@ use DBICTest; BEGIN { - eval "require DBIx::Class::Admin"; - plan skip_all => "Deps not installed: $@" if $@; - - eval "require Getopt::Long::Descriptive"; - plan skip_all => 'Install Getopt::Long::Descriptive to run this test' if ($@); - - eval 'require JSON::Any'; - plan skip_all => 'Install JSON::Any to run this test' if ($@); - - eval 'require Text::CSV_XS'; - if ($@) { - eval 'require Text::CSV_PP'; - plan skip_all => 'Install Text::CSV_XS or Text::CSV_PP to run this test' if ($@); - } + require DBIx::Class; + plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for('dbicadmin') + unless DBIx::Class::Optional::Dependencies->req_ok_for('dbicadmin'); } + my @json_backends = qw/XS JSON DWIW/; my $tests_per_run = 5; @@ -43,8 +33,6 @@ for my $js (@json_backends) { } sub test_dbicadmin { -# $ENV{PERL5LIB} = join ':', @INC; - my $schema = DBICTest->init_schema( sqlite_use_file => 1 ); # reinit a fresh db for every run my $employees = $schema->resultset('Employee');