Add author test for whitespace errors and make whitespace more consistent
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / backcompat / 0.04006 / 22dump.t
CommitLineData
406a97c2 1use DBIx::Class::Schema::Loader::Optional::Dependencies
2 -skip_all_without => 'test_backcompat';
3
9a95164d 4use strict;
f8c2ca5e 5use warnings;
9a95164d 6use Test::More;
1c94fb11 7use lib qw(t/backcompat/0.04006/lib);
9a95164d 8use File::Path;
9use make_dbictest_db;
c213fd3d 10use dbixcsl_test_dir qw/$tdir/;
818c6a0c 11
c213fd3d 12my $dump_path = "$tdir/dump";
9a95164d 13
8b7749d6 14local $SIG{__WARN__} = sub {
15 warn @_ unless $_[0] =~
16 /^Dumping manual schema|really_erase_my_files|^Schema dump complete/;
17};
18
9a95164d 19{
20 package DBICTest::Schema::1;
21 use base qw/ DBIx::Class::Schema::Loader /;
22 __PACKAGE__->loader_options(
23 dump_directory => $dump_path,
24 );
25}
26
27{
28 package DBICTest::Schema::2;
29 use base qw/ DBIx::Class::Schema::Loader /;
30 __PACKAGE__->loader_options(
31 dump_directory => $dump_path,
32 really_erase_my_files => 1,
33 );
34}
35
36plan tests => 5;
37
38rmtree($dump_path, 1, 1);
39
40eval { DBICTest::Schema::1->connect($make_dbictest_db::dsn) };
41ok(!$@, 'no death with dump_directory set') or diag "Dump failed: $@";
42
43DBICTest::Schema::1->_loader_invoked(undef);
44
45SKIP: {
494e0205 46 my @warnings_regexes = (
47 qr|Dumping manual schema|,
48 qr|Schema dump completed|,
49 );
9a95164d 50
494e0205 51 skip "ActiveState perl produces additional warnings", scalar @warnings_regexes
52 if ($^O eq 'MSWin32');
9a95164d 53
494e0205 54 my @warn_output;
55 {
56 local $SIG{__WARN__} = sub { push(@warn_output, @_) };
57 DBICTest::Schema::1->connect($make_dbictest_db::dsn);
58 }
9a95164d 59
494e0205 60 like(shift @warn_output, $_) foreach (@warnings_regexes);
9a95164d 61
494e0205 62 rmtree($dump_path, 1, 1);
9a95164d 63}
64
65eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) };
66ok(!$@, 'no death with dump_directory set (overwrite1)')
67 or diag "Dump failed: $@";
68
69DBICTest::Schema::2->_loader_invoked(undef);
70eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) };
71ok(!$@, 'no death with dump_directory set (overwrite2)')
72 or diag "Dump failed: $@";
73
f22644d7 74END { rmtree($dump_path, 1, 1) if $ENV{SCHEMA_LOADER_TESTS_BACKCOMPAT}; }