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