[Bast-commits] r8355 - in DBIx-Class/0.08/branches/dbicadmin_refactor/t: . admin

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Sun Jan 17 22:33:10 GMT 2010


Author: ribasushi
Date: 2010-01-17 22:33:10 +0000 (Sun, 17 Jan 2010)
New Revision: 8355

Added:
   DBIx-Class/0.08/branches/dbicadmin_refactor/t/admin/10script.t
Removed:
   DBIx-Class/0.08/branches/dbicadmin_refactor/t/89dbicadmin.t
Log:
Move script-test

Deleted: DBIx-Class/0.08/branches/dbicadmin_refactor/t/89dbicadmin.t
===================================================================
--- DBIx-Class/0.08/branches/dbicadmin_refactor/t/89dbicadmin.t	2010-01-17 22:27:49 UTC (rev 8354)
+++ DBIx-Class/0.08/branches/dbicadmin_refactor/t/89dbicadmin.t	2010-01-17 22:33:10 UTC (rev 8355)
@@ -1,103 +0,0 @@
-# vim: filetype=perl
-use strict;
-use warnings;
-
-use Test::More;
-use Config;
-use lib qw(t/lib);
-$ENV{PERL5LIB} = join ($Config{path_sep}, @INC);
-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 ($@);
-    }
-}
-my @json_backends = qw/XS JSON DWIW/;
-my $tests_per_run = 5;
-
-plan tests => $tests_per_run * @json_backends;
-
-for my $js (@json_backends) {
-
-    eval {JSON::Any->import ($js) };
-    SKIP: {
-        skip ("Json backend $js is not available, skip testing", $tests_per_run) if $@;
-
-        $ENV{JSON_ANY_ORDER} = $js;
-        eval { test_dbicadmin () };
-        diag $@ if $@;
-    }
-}
-
-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');
-
-    system( _prepare_system_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"}| ) );
-    $employee = $employees->find(1);
-    ok( ($employee->name() eq 'Trout'), "$ENV{JSON_ANY_ORDER}: update" );
-
-    system( _prepare_system_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 $!;
-        my $data = do { local $/; <$fh> };
-        close($fh);
-        if (!ok( ($data=~/Aran.*Trout/s), "$ENV{JSON_ANY_ORDER}: select with attrs" )) {
-          diag ("data from select is $data")
-        };
-    }
-
-    system( _prepare_system_args( qw|--op=delete --where={"name":"Trout"}| ) );
-    ok( ($employees->count()==1), "$ENV{JSON_ANY_ORDER}: delete" );
-}
-
-# 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;
-
-    my @args = (
-        qw|script/dbicadmin --quiet --schema=DBICTest::Schema --class=Employee|,
-        q|--connect=["dbi:SQLite:dbname=t/var/DBIxClass.db","","",{"AutoCommit":1}]|,
-        qw|--force|,
-        @_,
-    );
-
-    if ( $^O eq 'MSWin32' ) {
-        $perl = qq|"$perl"|;    # execution will fail if $^X contains paths
-        for (@args) {
-            $_ =~ s/"/\\"/g;
-        }
-    }
-
-    return ($perl, @args);
-}

Copied: DBIx-Class/0.08/branches/dbicadmin_refactor/t/admin/10script.t (from rev 8354, DBIx-Class/0.08/branches/dbicadmin_refactor/t/89dbicadmin.t)
===================================================================
--- DBIx-Class/0.08/branches/dbicadmin_refactor/t/admin/10script.t	                        (rev 0)
+++ DBIx-Class/0.08/branches/dbicadmin_refactor/t/admin/10script.t	2010-01-17 22:33:10 UTC (rev 8355)
@@ -0,0 +1,103 @@
+# vim: filetype=perl
+use strict;
+use warnings;
+
+use Test::More;
+use Config;
+use lib qw(t/lib);
+$ENV{PERL5LIB} = join ($Config{path_sep}, @INC);
+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 ($@);
+    }
+}
+my @json_backends = qw/XS JSON DWIW/;
+my $tests_per_run = 5;
+
+plan tests => $tests_per_run * @json_backends;
+
+for my $js (@json_backends) {
+
+    eval {JSON::Any->import ($js) };
+    SKIP: {
+        skip ("Json backend $js is not available, skip testing", $tests_per_run) if $@;
+
+        $ENV{JSON_ANY_ORDER} = $js;
+        eval { test_dbicadmin () };
+        diag $@ if $@;
+    }
+}
+
+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');
+
+    system( _prepare_system_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"}| ) );
+    $employee = $employees->find(1);
+    ok( ($employee->name() eq 'Trout'), "$ENV{JSON_ANY_ORDER}: update" );
+
+    system( _prepare_system_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 $!;
+        my $data = do { local $/; <$fh> };
+        close($fh);
+        if (!ok( ($data=~/Aran.*Trout/s), "$ENV{JSON_ANY_ORDER}: select with attrs" )) {
+          diag ("data from select is $data")
+        };
+    }
+
+    system( _prepare_system_args( qw|--op=delete --where={"name":"Trout"}| ) );
+    ok( ($employees->count()==1), "$ENV{JSON_ANY_ORDER}: delete" );
+}
+
+# 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;
+
+    my @args = (
+        qw|script/dbicadmin --quiet --schema=DBICTest::Schema --class=Employee|,
+        q|--connect=["dbi:SQLite:dbname=t/var/DBIxClass.db","","",{"AutoCommit":1}]|,
+        qw|--force|,
+        @_,
+    );
+
+    if ( $^O eq 'MSWin32' ) {
+        $perl = qq|"$perl"|;    # execution will fail if $^X contains paths
+        for (@args) {
+            $_ =~ s/"/\\"/g;
+        }
+    }
+
+    return ($perl, @args);
+}




More information about the Bast-commits mailing list