From: Peter Rabbitson Date: Wed, 8 Sep 2010 11:21:48 +0000 (+0200) Subject: Restructure handling of the test scratch-dir, move all activity X-Git-Tag: 0.07002~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class-Schema-Loader.git;a=commitdiff_plain;h=c213fd3d7802c6d46dceae4e371476de14c43c56 Restructure handling of the test scratch-dir, move all activity to t/var, adjust .gitignore --- diff --git a/.gitignore b/.gitignore index e60fdfd..8bdec1c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,8 +10,5 @@ /MANIFEST /META.yml /README -t/_dump -t/sqlite_test -t/sqlite_test-journal lib/DBIx/Class/Schema/Loader/Optional/Dependencies.pod - +t/var diff --git a/t/10sqlite_common.t b/t/10sqlite_common.t index e3d52dc..e588ded 100644 --- a/t/10sqlite_common.t +++ b/t/10sqlite_common.t @@ -2,6 +2,7 @@ use strict; use Test::More; use lib qw(t/lib); use dbixcsl_common_tests; +use dbixcsl_test_dir qw/$tdir/; eval { require DBD::SQLite }; my $class = $@ ? 'SQLite2' : 'SQLite'; @@ -9,7 +10,7 @@ my $class = $@ ? 'SQLite2' : 'SQLite'; my $tester = dbixcsl_common_tests->new( vendor => 'SQLite', auto_inc_pk => 'INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT', - dsn => "dbi:$class:dbname=./t/sqlite_test", + dsn => "dbi:$class:dbname=$tdir/sqlite_test", user => '', password => '', connect_info_opts => { @@ -158,5 +159,5 @@ my $tester = dbixcsl_common_tests->new( $tester->run_tests(); END { - unlink './t/sqlite_test'; + unlink "$tdir/sqlite_test"; } diff --git a/t/20invocations.t b/t/20invocations.t index 170dd77..c74892a 100644 --- a/t/20invocations.t +++ b/t/20invocations.t @@ -108,7 +108,7 @@ my @invocations = ( DBICTest::Schema::_make_schema_at_explicit->clone; }, 'no_skip_load_external' => sub { - # By default we should pull in t/lib/DBICTest/Schema/13/Foo.pm $skip_me since t/lib is in @INC + # By default we should pull in t/lib/DBICTest/Schema/_no_skip_load_external/Foo.pm $skip_me since t/lib is in @INC use DBIx::Class::Schema::Loader; DBIx::Class::Schema::Loader::make_schema_at( 'DBICTest::Schema::_no_skip_load_external', @@ -118,7 +118,7 @@ my @invocations = ( DBICTest::Schema::_no_skip_load_external->clone; }, 'skip_load_external' => sub { - # When we explicitly skip_load_external t/lib/DBICTest/Schema/14/Foo.pm should be ignored + # When we explicitly skip_load_external t/lib/DBICTest/Schema/_skip_load_external/Foo.pm should be ignored use DBIx::Class::Schema::Loader; DBIx::Class::Schema::Loader::make_schema_at( 'DBICTest::Schema::_skip_load_external', diff --git a/t/22dump.t b/t/22dump.t index 671021e..0b3a2f8 100644 --- a/t/22dump.t +++ b/t/22dump.t @@ -3,8 +3,9 @@ use Test::More; use lib qw(t/lib); use File::Path; use make_dbictest_db; +use dbixcsl_test_dir qw/$tdir/; -my $dump_path = './t/_dump'; +my $dump_path = "$tdir/dump"; local $SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ diff --git a/t/25backcompat.t b/t/25backcompat.t index cc4a755..7a92fbe 100644 --- a/t/25backcompat.t +++ b/t/25backcompat.t @@ -11,8 +11,9 @@ use DBIx::Class::Schema::Loader (); use Lingua::EN::Inflect::Number (); use lib qw(t/lib); use make_dbictest_db_with_unique; +use dbixcsl_test_dir qw/$tdir/; -my $DUMP_DIR = './t/_common_dump'; +my $DUMP_DIR = "$tdir/common_dump"; rmtree $DUMP_DIR; my $SCHEMA_CLASS = 'DBIXCSL_Test::Schema'; diff --git a/t/backcompat/0.04006/10sqlite_common.t b/t/backcompat/0.04006/10sqlite_common.t index c6d52f3..446614f 100644 --- a/t/backcompat/0.04006/10sqlite_common.t +++ b/t/backcompat/0.04006/10sqlite_common.t @@ -1,6 +1,8 @@ use strict; use lib qw(t/backcompat/0.04006/lib); use dbixcsl_common_tests; +use dbixcsl_test_dir qw/$tdir/; + use Test::More; plan skip_all => 'set SCHEMA_LOADER_TESTS_BACKCOMPAT to enable these tests' unless $ENV{SCHEMA_LOADER_TESTS_BACKCOMPAT}; @@ -12,7 +14,7 @@ my $class = $@ ? 'SQLite2' : 'SQLite'; my $tester = dbixcsl_common_tests->new( vendor => 'SQLite', auto_inc_pk => 'INTEGER NOT NULL PRIMARY KEY', - dsn => "dbi:$class:dbname=./t/sqlite_test", + dsn => "dbi:$class:dbname=$tdir/sqlite_test", user => '', password => '', ); @@ -21,5 +23,5 @@ my $class = $@ ? 'SQLite2' : 'SQLite'; } END { - unlink './t/sqlite_test' if $ENV{SCHEMA_LOADER_TESTS_BACKCOMPAT}; + unlink "$tdir/sqlite_test" if $ENV{SCHEMA_LOADER_TESTS_BACKCOMPAT}; } diff --git a/t/backcompat/0.04006/22dump.t b/t/backcompat/0.04006/22dump.t index 9a53f7d..4279455 100644 --- a/t/backcompat/0.04006/22dump.t +++ b/t/backcompat/0.04006/22dump.t @@ -3,11 +3,12 @@ use Test::More; use lib qw(t/backcompat/0.04006/lib); use File::Path; use make_dbictest_db; +use dbixcsl_test_dir qw/$tdir/; plan skip_all => 'set SCHEMA_LOADER_TESTS_BACKCOMPAT to enable these tests' unless $ENV{SCHEMA_LOADER_TESTS_BACKCOMPAT}; -my $dump_path = './t/_dump'; +my $dump_path = "$tdir/dump"; local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ diff --git a/t/backcompat/0.04006/23dumpmore.t b/t/backcompat/0.04006/23dumpmore.t index d513de7..bb0d2fb 100644 --- a/t/backcompat/0.04006/23dumpmore.t +++ b/t/backcompat/0.04006/23dumpmore.t @@ -3,12 +3,14 @@ use Test::More; use lib qw(t/backcompat/0.04006/lib); use File::Path; use make_dbictest_db; +use dbixcsl_test_dir qw/$tdir/; + require DBIx::Class::Schema::Loader; plan skip_all => 'set SCHEMA_LOADER_TESTS_BACKCOMPAT to enable these tests' unless $ENV{SCHEMA_LOADER_TESTS_BACKCOMPAT}; -my $DUMP_PATH = './t/_dump'; +my $DUMP_PATH = "$tdir/dump"; sub do_dump_test { my %tdata = @_; diff --git a/t/backcompat/0.04006/lib/dbixcsl_test_dir.pm b/t/backcompat/0.04006/lib/dbixcsl_test_dir.pm new file mode 100644 index 0000000..d1b3992 --- /dev/null +++ b/t/backcompat/0.04006/lib/dbixcsl_test_dir.pm @@ -0,0 +1,18 @@ +package dbixcsl_test_dir; + +use warnings; +use strict; + +our $tdir = 't/var'; + +use base qw/Exporter/; +our @EXPORT_OK = '$tdir'; + +die "/t does not exist, this can't be right...\n" + unless -d 't'; + +unless (-d $tdir) { + mkdir $tdir or die "Unable to create $tdir: $!\n"; +} + +1; diff --git a/t/backcompat/0.04006/lib/make_dbictest_db.pm b/t/backcompat/0.04006/lib/make_dbictest_db.pm index d9a8083..0aba796 100644 --- a/t/backcompat/0.04006/lib/make_dbictest_db.pm +++ b/t/backcompat/0.04006/lib/make_dbictest_db.pm @@ -3,11 +3,12 @@ package make_dbictest_db; use strict; use warnings; use DBI; +use dbixcsl_test_dir qw/$tdir/; eval { require DBD::SQLite }; my $class = $@ ? 'SQLite2' : 'SQLite'; -my $fn = './t/dbictest.db'; +my $fn = "$tdir/dbictest.db"; unlink($fn); our $dsn = "dbi:$class:dbname=$fn"; diff --git a/t/lib/dbixcsl_common_tests.pm b/t/lib/dbixcsl_common_tests.pm index 3da90d2..2a48570 100644 --- a/t/lib/dbixcsl_common_tests.pm +++ b/t/lib/dbixcsl_common_tests.pm @@ -17,7 +17,9 @@ use List::MoreUtils 'apply'; use DBIx::Class::Schema::Loader::Optional::Dependencies (); use namespace::clean; -my $DUMP_DIR = './t/_common_dump'; +use dbixcsl_test_dir qw/$tdir/; + +my $DUMP_DIR = "$tdir/common_dump"; rmtree $DUMP_DIR; sub new { @@ -928,7 +930,7 @@ sub test_schema { find $find_cb, $DUMP_DIR; # system "rm -f /tmp/before_rescan/* /tmp/after_rescan/*"; -# system "cp t/_common_dump/DBIXCSL_Test/Schema/*.pm /tmp/before_rescan"; +# system "cp $tdir/common_dump/DBIXCSL_Test/Schema/*.pm /tmp/before_rescan"; my $before_digest = $digest->b64digest; diff --git a/t/lib/dbixcsl_dumper_tests.pm b/t/lib/dbixcsl_dumper_tests.pm index 35ed4b8..ff0cd06 100644 --- a/t/lib/dbixcsl_dumper_tests.pm +++ b/t/lib/dbixcsl_dumper_tests.pm @@ -7,7 +7,9 @@ use IPC::Open3; use DBIx::Class::Schema::Loader::Utils 'dumper_squashed'; use DBIx::Class::Schema::Loader (); -my $DUMP_PATH = 't/_dump'; +use dbixcsl_test_dir qw/$tdir/; + +my $DUMP_PATH = "$tdir/dump"; sub cleanup { rmtree($DUMP_PATH, 1, 1); } diff --git a/t/lib/dbixcsl_test_dir.pm b/t/lib/dbixcsl_test_dir.pm new file mode 100644 index 0000000..d1b3992 --- /dev/null +++ b/t/lib/dbixcsl_test_dir.pm @@ -0,0 +1,18 @@ +package dbixcsl_test_dir; + +use warnings; +use strict; + +our $tdir = 't/var'; + +use base qw/Exporter/; +our @EXPORT_OK = '$tdir'; + +die "/t does not exist, this can't be right...\n" + unless -d 't'; + +unless (-d $tdir) { + mkdir $tdir or die "Unable to create $tdir: $!\n"; +} + +1; diff --git a/t/lib/make_dbictest_db.pm b/t/lib/make_dbictest_db.pm index 118800b..d87dd01 100644 --- a/t/lib/make_dbictest_db.pm +++ b/t/lib/make_dbictest_db.pm @@ -3,11 +3,12 @@ package make_dbictest_db; use strict; use warnings; use DBI; +use dbixcsl_test_dir qw/$tdir/; eval { require DBD::SQLite }; my $class = $@ ? 'SQLite2' : 'SQLite'; -my $fn = './t/dbictest.db'; +my $fn = "$tdir/dbictest.db"; unlink($fn); our $dsn = "dbi:$class:dbname=$fn"; diff --git a/t/lib/make_dbictest_db_clashing_monikers.pm b/t/lib/make_dbictest_db_clashing_monikers.pm index 37741bb..e1c82b3 100644 --- a/t/lib/make_dbictest_db_clashing_monikers.pm +++ b/t/lib/make_dbictest_db_clashing_monikers.pm @@ -3,11 +3,12 @@ package make_dbictest_db_clashing_monikers; use strict; use warnings; use DBI; +use dbixcsl_test_dir qw/$tdir/; eval { require DBD::SQLite }; my $class = $@ ? 'SQLite2' : 'SQLite'; -my $fn = './t/dbictest_clashing_tables.db'; +my $fn = "$tdir/dbictest_clashing_tables.db"; unlink($fn); our $dsn = "dbi:$class:dbname=$fn"; diff --git a/t/lib/make_dbictest_db_with_unique.pm b/t/lib/make_dbictest_db_with_unique.pm index 6f75ad3..a0b47bf 100644 --- a/t/lib/make_dbictest_db_with_unique.pm +++ b/t/lib/make_dbictest_db_with_unique.pm @@ -3,11 +3,13 @@ package make_dbictest_db_with_unique; use strict; use warnings; use DBI; +use dbixcsl_test_dir qw/$tdir/; + eval { require DBD::SQLite }; my $class = $@ ? 'SQLite2' : 'SQLite'; -my $fn = './t/dbictest_with_unique.db'; +my $fn = "$tdir/dbictest_with_unique.db"; unlink($fn); our $dsn = "dbi:$class:dbname=$fn";