Commit | Line | Data |
fa994d3c |
1 | use strict; |
2 | use Test::More; |
3 | use lib qw(t/lib); |
3e3c3fc7 |
4 | use File::Path; |
fa994d3c |
5 | use make_dbictest_db; |
6 | |
3e3c3fc7 |
7 | my $dump_path = './t/_dump'; |
8 | |
fdd8ff16 |
9 | local $SIG{__WARN__} = sub { |
10 | warn $_[0] unless $_[0] =~ |
11 | /really_erase_my_files|Dumping manual schema|Schema dump completed/; |
12 | }; |
13 | |
3e3c3fc7 |
14 | { |
15 | package DBICTest::Schema::1; |
16 | use base qw/ DBIx::Class::Schema::Loader /; |
17 | __PACKAGE__->loader_options( |
3e3c3fc7 |
18 | dump_directory => $dump_path, |
19 | ); |
20 | } |
21 | |
fa994d3c |
22 | { |
3e3c3fc7 |
23 | package DBICTest::Schema::2; |
fa994d3c |
24 | use base qw/ DBIx::Class::Schema::Loader /; |
25 | __PACKAGE__->loader_options( |
3e3c3fc7 |
26 | dump_directory => $dump_path, |
28b4691d |
27 | really_erase_my_files => 1, |
fa994d3c |
28 | ); |
fa994d3c |
29 | } |
30 | |
7cab3ab7 |
31 | plan tests => 5; |
3e3c3fc7 |
32 | |
520107ef |
33 | rmtree($dump_path, 1, 1); |
3e3c3fc7 |
34 | |
35 | eval { DBICTest::Schema::1->connect($make_dbictest_db::dsn) }; |
36 | ok(!$@, 'no death with dump_directory set') or diag "Dump failed: $@"; |
37 | |
59cfa251 |
38 | DBICTest::Schema::1->_loader_invoked(undef); |
9395f33a |
39 | |
e682950b |
40 | SKIP: { |
2ffd6b4c |
41 | my @warnings_regexes = ( |
42 | qr|Dumping manual schema|, |
43 | qr|Schema dump completed|, |
44 | ); |
45 | |
46 | skip "ActiveState perl produces additional warnings", scalar @warnings_regexes |
e682950b |
47 | if ($^O eq 'MSWin32'); |
9395f33a |
48 | |
e682950b |
49 | my @warn_output; |
50 | { |
51 | local $SIG{__WARN__} = sub { push(@warn_output, @_) }; |
52 | DBICTest::Schema::1->connect($make_dbictest_db::dsn); |
53 | } |
3e3c3fc7 |
54 | |
e682950b |
55 | like(shift @warn_output, $_) foreach (@warnings_regexes); |
56 | |
57 | rmtree($dump_path, 1, 1); |
58 | } |
3e3c3fc7 |
59 | |
60 | eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) }; |
02356864 |
61 | ok(!$@, 'no death with dump_directory set (overwrite1)') |
62 | or diag "Dump failed: $@"; |
3e3c3fc7 |
63 | |
59cfa251 |
64 | DBICTest::Schema::2->_loader_invoked(undef); |
3e3c3fc7 |
65 | eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) }; |
02356864 |
66 | ok(!$@, 'no death with dump_directory set (overwrite2)') |
67 | or diag "Dump failed: $@"; |
fa994d3c |
68 | |
7e9ee6a4 |
69 | END { rmtree($dump_path, 1, 1); } |