Commit | Line | Data |
406a97c2 |
1 | use DBIx::Class::Schema::Loader::Optional::Dependencies |
2 | -skip_all_without => 'test_backcompat'; |
3 | |
9a95164d |
4 | use strict; |
f8c2ca5e |
5 | use warnings; |
9a95164d |
6 | use Test::More; |
1c94fb11 |
7 | use lib qw(t/backcompat/0.04006/lib); |
9a95164d |
8 | use File::Path; |
9 | use make_dbictest_db; |
c213fd3d |
10 | use dbixcsl_test_dir qw/$tdir/; |
818c6a0c |
11 | |
c213fd3d |
12 | my $dump_path = "$tdir/dump"; |
9a95164d |
13 | |
8b7749d6 |
14 | local $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 | |
36 | plan tests => 5; |
37 | |
38 | rmtree($dump_path, 1, 1); |
39 | |
40 | eval { DBICTest::Schema::1->connect($make_dbictest_db::dsn) }; |
41 | ok(!$@, 'no death with dump_directory set') or diag "Dump failed: $@"; |
42 | |
43 | DBICTest::Schema::1->_loader_invoked(undef); |
44 | |
45 | SKIP: { |
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 | |
65 | eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) }; |
66 | ok(!$@, 'no death with dump_directory set (overwrite1)') |
67 | or diag "Dump failed: $@"; |
68 | |
69 | DBICTest::Schema::2->_loader_invoked(undef); |
70 | eval { DBICTest::Schema::2->connect($make_dbictest_db::dsn) }; |
71 | ok(!$@, 'no death with dump_directory set (overwrite2)') |
72 | or diag "Dump failed: $@"; |
73 | |
f22644d7 |
74 | END { rmtree($dump_path, 1, 1) if $ENV{SCHEMA_LOADER_TESTS_BACKCOMPAT}; } |