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