1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
9 if( DBICTest::RunMode->is_plain ) {
10 print "1..0 # SKIP not running dangerous segfault-prone test on plain install\n";
15 use DBICTest::Util 'capture_stderr';
16 use DBIx::Class::Schema;
18 # Do not use T::B - the test is hard enough not to segfault as it is
21 # start with one failure, and decrement it at the end
25 printf STDOUT ("%s %u - %s\n",
26 ( $_[0] ? 'ok' : 'not ok' ),
33 printf STDERR ("# Failed test #%d at %s line %d\n",
42 # this is incredibly horrible...
43 # demonstrate utter breakage of the reconnection/retry logic
45 my $output = capture_stderr {
48 # yes, make it even dirtier
49 my $schema = 'DBIx::Class::Schema';
51 $schema->connection('dbi:SQLite::memory:');
52 $schema->storage->ensure_connected;
53 $schema->storage->_dbh->disconnect;
55 # silences "exitting sub via last"
56 local $SIG{__WARN__} = sub {};
58 $schema->exception_action(sub {
59 ok(1, 'exception_action invoked');
60 # essentially what Dancer2's redirect() does after https://github.com/PerlDancer/Dancer2/pull/485
61 # which "nicely" combines with: https://metacpan.org/source/MARKOV/Log-Report-1.12/lib/Dancer2/Plugin/LogReport.pm#L143
62 # as encouraged by: https://metacpan.org/pod/release/MARKOV/Log-Report-1.12/lib/Dancer2/Plugin/LogReport.pod#Logging-DBIC-database-queries-and-errors
66 # this *DOES* throw, but the exception will *NEVER SHOW UP*
67 $schema->storage->dbh_do(sub { $_[1]->selectall_arrayref("SELECT * FROM wfwqfdqefqef") } );
73 ok(1, "Post-escape reached");
76 !!( $output =~ /DBIx::Class INTERNAL PANIC.+FIX YOUR ERROR HANDLING/s ),
77 'Proper warning emitted on STDERR'
78 ) or print STDERR "Instead found:\n\n$output\n";
80 print "1..$test_count\n";
82 # this is our "done_testing"
85 # avoid tasty segfaults on 5.8.x