[Bast-commits] r9480 - in
DBIx-Class/0.08/branches/dbicadmin-non-versioned/t: . admin
lib lib/testinclude var
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Mon May 31 16:03:08 GMT 2010
Author: ribasushi
Date: 2010-05-31 17:03:07 +0100 (Mon, 31 May 2010)
New Revision: 9480
Added:
DBIx-Class/0.08/branches/dbicadmin-non-versioned/t/lib/testinclude/
DBIx-Class/0.08/branches/dbicadmin-non-versioned/t/lib/testinclude/DBICTestAdminInc.pm
Removed:
DBIx-Class/0.08/branches/dbicadmin-non-versioned/t/dbicadmin-test-include/
DBIx-Class/0.08/branches/dbicadmin-non-versioned/t/dbicadmincrap/
DBIx-Class/0.08/branches/dbicadmin-non-versioned/t/var/dbicadmincrap/
Modified:
DBIx-Class/0.08/branches/dbicadmin-non-versioned/t/admin/04include.t
DBIx-Class/0.08/branches/dbicadmin-non-versioned/t/admin/10script.t
Log:
Simplify includedir testing
Modified: DBIx-Class/0.08/branches/dbicadmin-non-versioned/t/admin/04include.t
===================================================================
--- DBIx-Class/0.08/branches/dbicadmin-non-versioned/t/admin/04include.t 2010-05-31 15:26:47 UTC (rev 9479)
+++ DBIx-Class/0.08/branches/dbicadmin-non-versioned/t/admin/04include.t 2010-05-31 16:03:07 UTC (rev 9480)
@@ -12,15 +12,15 @@
if(use_ok 'DBIx::Class::Admin') {
my $admin = DBIx::Class::Admin->new(
- include_dirs => ['t/dbicadmin-test-include/lib'],
- schema_class => 'Foo',
- config => { Foo => {} },
- config_stanza => 'Foo'
+ include_dirs => ['t/lib/testinclude'],
+ schema_class => 'DBICTestAdminInc',
+ config => { DBICTestAdminInc => {} },
+ config_stanza => 'DBICTestAdminInc'
);
lives_ok { $admin->_build_schema } 'should survive attempt to load module located in include_dirs';
{
no warnings 'once';
- ok($Foo::loaded);
+ ok($DBICTestAdminInc::loaded);
}
}
Modified: DBIx-Class/0.08/branches/dbicadmin-non-versioned/t/admin/10script.t
===================================================================
--- DBIx-Class/0.08/branches/dbicadmin-non-versioned/t/admin/10script.t 2010-05-31 15:26:47 UTC (rev 9479)
+++ DBIx-Class/0.08/branches/dbicadmin-non-versioned/t/admin/10script.t 2010-05-31 16:03:07 UTC (rev 9480)
@@ -16,9 +16,9 @@
}
my @json_backends = qw/XS JSON DWIW/;
-my $tests_per_run = 6;
+my $tests_per_run = 5;
-plan tests => $tests_per_run * @json_backends;
+plan tests => ($tests_per_run * @json_backends) + 1;
for my $js (@json_backends) {
@@ -30,34 +30,34 @@
eval { test_dbicadmin () };
diag $@ if $@;
- # test the script is setting @INC properly
- like(`script/dbicadmin -It/dbicadmin-test-include/lib --schema=Foo --op=deploy --connect=[] --debug`,
- qr|Adding to \@INC:\nt/dbicadmin-test-include/lib|
- );
}
}
+# test the script is setting @INC properly
+test_exec (qw| -It/lib/testinclude --schema=DBICTestAdminInc --op=deploy --connect=[] |);
+cmp_ok ( $? >> 8, '==', 70, 'Correct exit code from deploying a custom INC schema' );
+
sub test_dbicadmin {
my $schema = DBICTest->init_schema( sqlite_use_file => 1 ); # reinit a fresh db for every run
my $employees = $schema->resultset('Employee');
- system( _prepare_system_args( qw|--op=insert --set={"name":"Matt"}| ) );
+ test_exec( default_args(), qw|--op=insert --set={"name":"Matt"}| );
ok( ($employees->count()==1), "$ENV{JSON_ANY_ORDER}: insert count" );
my $employee = $employees->find(1);
ok( ($employee->name() eq 'Matt'), "$ENV{JSON_ANY_ORDER}: insert valid" );
- system( _prepare_system_args( qw|--op=update --set={"name":"Trout"}| ) );
+ test_exec( default_args(), qw|--op=update --set={"name":"Trout"}| );
$employee = $employees->find(1);
ok( ($employee->name() eq 'Trout'), "$ENV{JSON_ANY_ORDER}: update" );
- system( _prepare_system_args( qw|--op=insert --set={"name":"Aran"}| ) );
+ test_exec( default_args(), qw|--op=insert --set={"name":"Aran"}| );
SKIP: {
skip ("MSWin32 doesn't support -| either", 1) if $^O eq 'MSWin32';
- open(my $fh, "-|", _prepare_system_args( qw|--op=select --attrs={"order_by":"name"}| ) ) or die $!;
+ open(my $fh, "-|", ( 'script/dbicadmin', default_args(), qw|--op=select --attrs={"order_by":"name"}| ) ) or die $!;
my $data = do { local $/; <$fh> };
close($fh);
if (!ok( ($data=~/Aran.*Trout/s), "$ENV{JSON_ANY_ORDER}: select with attrs" )) {
@@ -65,32 +65,35 @@
};
}
- system( _prepare_system_args( qw|--op=delete --where={"name":"Trout"}| ) );
+ test_exec( default_args(), qw|--op=delete --where={"name":"Trout"}| );
ok( ($employees->count()==1), "$ENV{JSON_ANY_ORDER}: delete" );
}
+sub default_args {
+ return (
+ qw|--quiet --schema=DBICTest::Schema --class=Employee|,
+ q|--connect=["dbi:SQLite:dbname=t/var/DBIxClass.db","","",{"AutoCommit":1}]|,
+ qw|--force|,
+ );
+}
+
# Why do we need this crap? Apparently MSWin32 can not pass through quotes properly
# (sometimes it will and sometimes not, depending on what compiler was used to build
# perl). So we go the extra mile to escape all the quotes. We can't also use ' instead
# of ", because JSON::XS (proudly) does not support "malformed JSON" as the author
# calls it. Bleh.
#
-sub _prepare_system_args {
- my $perl = $^X;
+sub test_exec {
+ my $perl = $^X;
- my @args = (
- qw|script/dbicadmin --quiet --schema=DBICTest::Schema --class=Employee|,
- q|--connect=["dbi:SQLite:dbname=t/var/DBIxClass.db","","",{"AutoCommit":1}]|,
- qw|--force|,
- @_,
- );
+ my @args = ('script/dbicadmin', @_);
- if ( $^O eq 'MSWin32' ) {
- $perl = qq|"$perl"|; # execution will fail if $^X contains paths
- for (@args) {
- $_ =~ s/"/\\"/g;
- }
+ if ( $^O eq 'MSWin32' ) {
+ $perl = qq|"$perl"|; # execution will fail if $^X contains paths
+ for (@args) {
+ $_ =~ s/"/\\"/g;
}
+ }
- return ($perl, @args);
+ system ($perl, @args);
}
Copied: DBIx-Class/0.08/branches/dbicadmin-non-versioned/t/lib/testinclude/DBICTestAdminInc.pm (from rev 9363, DBIx-Class/0.08/branches/dbicadmin-non-versioned/t/dbicadmin-test-include/lib/Foo.pm)
===================================================================
--- DBIx-Class/0.08/branches/dbicadmin-non-versioned/t/lib/testinclude/DBICTestAdminInc.pm (rev 0)
+++ DBIx-Class/0.08/branches/dbicadmin-non-versioned/t/lib/testinclude/DBICTestAdminInc.pm 2010-05-31 16:03:07 UTC (rev 9480)
@@ -0,0 +1,9 @@
+package DBICTestAdminInc;
+use base 'DBIx::Class::Schema';
+
+our $loaded = 1;
+sub connect { bless {}, __PACKAGE__ }
+
+sub deploy { exit 70 }
+
+1;
More information about the Bast-commits
mailing list