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",
43 # this is incredibly horrible...
44 # demonstrate utter breakage of the reconnection/retry logic
46 my $output = capture_stderr {
49 # yes, make it even dirtier
50 my $schema = 'DBIx::Class::Schema';
52 $schema->connection('dbi:SQLite::memory:');
53 $schema->storage->ensure_connected;
54 $schema->storage->_dbh->disconnect;
56 # silences "exitting sub via last"
57 local $SIG{__WARN__} = sub {};
59 $schema->exception_action(sub {
60 ok(1, 'exception_action invoked');
61 # essentially what Dancer2's redirect() does after https://github.com/PerlDancer/Dancer2/pull/485
62 # which "nicely" combines with: https://metacpan.org/source/MARKOV/Log-Report-1.12/lib/Dancer2/Plugin/LogReport.pm#L143
63 # as encouraged by: https://metacpan.org/pod/release/MARKOV/Log-Report-1.12/lib/Dancer2/Plugin/LogReport.pod#Logging-DBIC-database-queries-and-errors
67 # this *DOES* throw, but the exception will *NEVER SHOW UP*
68 $schema->storage->dbh_do(sub { $_[1]->selectall_arrayref("SELECT * FROM wfwqfdqefqef") } );
74 ok(1, "Post-escape reached");
77 !!( $output =~ /DBIx::Class INTERNAL PANIC.+FIX YOUR ERROR HANDLING/s ),
78 'Proper warning emitted on STDERR'
79 ) or print STDERR "Instead found:\n\n$output\n";
81 print "1..$test_count\n";
83 # this is our "done_testing"
86 # avoid tasty segfaults on 5.8.x