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