Commit | Line | Data |
66917da3 |
1 | # work around brain damage in PPerl (yes, it has to be a global) |
2 | $SIG{__WARN__} = sub { |
3 | warn @_ unless $_[0] =~ /\QUse of "goto" to jump into a construct is deprecated/ |
4 | } if ($ENV{DBICTEST_IN_PERSISTENT_ENV}); |
5 | |
6 | # the persistent environments run with this flag first to see if |
7 | # we will run at all (e.g. it will fail if $^X doesn't match) |
8 | exit 0 if $ENV{DBICTEST_PERSISTENT_ENV_BAIL_EARLY}; |
9 | |
f05edfd1 |
10 | # Do the override as early as possible so that CORE::bless doesn't get compiled away |
11 | # We will replace $bless_override only if we are in author mode |
12 | my $bless_override; |
13 | BEGIN { |
14 | $bless_override = sub { |
15 | CORE::bless( $_[0], (@_ > 1) ? $_[1] : caller() ); |
16 | }; |
17 | *CORE::GLOBAL::bless = sub { goto $bless_override }; |
18 | } |
19 | |
50261284 |
20 | use strict; |
21 | use warnings; |
a917fb06 |
22 | use Test::More; |
d5e5fb4b |
23 | |
66917da3 |
24 | my $TB = Test::More->builder; |
25 | if ($ENV{DBICTEST_IN_PERSISTENT_ENV}) { |
7be5717e |
26 | # without this explicit close older TBs warn in END after a ->reset |
27 | if ($TB->VERSION < 1.005) { |
28 | close ($TB->$_) for (qw/output failure_output todo_output/); |
29 | } |
66917da3 |
30 | |
7be5717e |
31 | # if I do not do this, I get happy sigpipes on new TB, no idea why |
32 | # (the above close-and-forget doesn't work - new TB does *not* reopen |
33 | # its handles automatically anymore) |
34 | else { |
35 | for (qw/failure_output todo_output/) { |
36 | close $TB->$_; |
37 | open ($TB->$_, '>&', *STDERR); |
38 | } |
66917da3 |
39 | |
7be5717e |
40 | close $TB->output; |
41 | open ($TB->output, '>&', *STDOUT); |
42 | } |
43 | |
44 | # so done_testing can work on every persistent pass |
45 | $TB->reset; |
66917da3 |
46 | } |
47 | |
d5e5fb4b |
48 | use lib qw(t/lib); |
49 | use DBICTest::RunMode; |
218b7c12 |
50 | use DBICTest::Util::LeakTracer qw/populate_weakregistry assert_empty_weakregistry/; |
51 | use Scalar::Util 'refaddr'; |
e0b2dc74 |
52 | use DBIx::Class; |
dee99c24 |
53 | use B 'svref_2object'; |
d12d8272 |
54 | BEGIN { |
d5e5fb4b |
55 | plan skip_all => "Your perl version $] appears to leak like a sieve - skipping test" |
dee99c24 |
56 | if DBIx::Class::_ENV_::PEEPEENESS; |
d12d8272 |
57 | } |
58 | |
a8c2c746 |
59 | # this is what holds all weakened refs to be checked for leakage |
60 | my $weak_registry = {}; |
61 | |
6a43bc0c |
62 | # whether or to invoke IC::DT |
63 | my $has_dt; |
64 | |
a8c2c746 |
65 | # Skip the heavy-duty leak tracing when just doing an install |
66 | unless (DBICTest::RunMode->is_plain) { |
f05edfd1 |
67 | |
eb7aa960 |
68 | # redefine the bless override so that we can catch each and every object created |
a8c2c746 |
69 | no warnings qw/redefine once/; |
70 | no strict qw/refs/; |
71 | |
f05edfd1 |
72 | $bless_override = sub { |
73 | |
a8c2c746 |
74 | my $obj = CORE::bless( |
75 | $_[0], (@_ > 1) ? $_[1] : do { |
76 | my ($class, $fn, $line) = caller(); |
77 | fail ("bless() of $_[0] into $class without explicit class specification at $fn line $line") |
78 | if $class =~ /^ (?: DBIx\:\:Class | DBICTest ) /x; |
79 | $class; |
80 | } |
81 | ); |
82 | |
8d6b1478 |
83 | # unicode is tricky, and now we happen to invoke it early via a |
84 | # regex in connection() |
85 | return $obj if (ref $obj) =~ /^utf8/; |
86 | |
7be5717e |
87 | # Test Builder is now making a new object for every pass/fail (que bloat?) |
88 | # and as such we can't really store any of its objects (since it will |
89 | # re-populate the registry while checking it, ewwww!) |
90 | return $obj if (ref $obj) =~ /^TB2::/; |
91 | |
a8c2c746 |
92 | # weaken immediately to avoid weird side effects |
65d35121 |
93 | return populate_weakregistry ($weak_registry, $obj ); |
a8c2c746 |
94 | }; |
95 | |
eb7aa960 |
96 | require Try::Tiny; |
a8c2c746 |
97 | for my $func (qw/try catch finally/) { |
98 | my $orig = \&{"Try::Tiny::$func"}; |
99 | *{"Try::Tiny::$func"} = sub (&;@) { |
65d35121 |
100 | populate_weakregistry( $weak_registry, $_[0] ); |
a8c2c746 |
101 | goto $orig; |
102 | } |
103 | } |
eb7aa960 |
104 | |
105 | # Some modules are known to install singletons on-load |
106 | # Load them and empty the registry |
107 | |
108 | # this loads the DT armada |
109 | $has_dt = DBIx::Class::Optional::Dependencies->req_ok_for('test_dt_sqlite'); |
110 | |
111 | require Errno; |
112 | require DBI; |
113 | require DBD::SQLite; |
114 | require FileHandle; |
e6ff3658 |
115 | require Moo; |
eb7aa960 |
116 | |
117 | %$weak_registry = (); |
a8c2c746 |
118 | } |
119 | |
dee99c24 |
120 | my @compose_ns_classes; |
a8c2c746 |
121 | { |
66917da3 |
122 | use_ok ('DBICTest'); |
a917fb06 |
123 | |
a8c2c746 |
124 | my $schema = DBICTest->init_schema; |
125 | my $rs = $schema->resultset ('Artist'); |
126 | my $storage = $schema->storage; |
a917fb06 |
127 | |
dee99c24 |
128 | @compose_ns_classes = map { "DBICTest::${_}" } keys %{$schema->source_registrations}; |
129 | |
a8c2c746 |
130 | ok ($storage->connected, 'we are connected'); |
a917fb06 |
131 | |
052b8ce2 |
132 | my $row_obj = $rs->search({}, { rows => 1})->next; # so that commits/rollbacks work |
a8c2c746 |
133 | ok ($row_obj, 'row from db'); |
134 | |
052b8ce2 |
135 | # txn_do to invoke more codepaths |
a8c2c746 |
136 | my ($mc_row_obj, $pager, $pager_explicit_count) = $schema->txn_do (sub { |
137 | |
9345b14c |
138 | my $artist = $schema->resultset('Artist')->create ({ |
a8c2c746 |
139 | name => 'foo artist', |
140 | cds => [{ |
141 | title => 'foo cd', |
142 | year => 1984, |
187ec69a |
143 | tracks => [ |
144 | { title => 't1' }, |
145 | { title => 't2' }, |
146 | ], |
147 | genre => { name => 'mauve' }, |
a8c2c746 |
148 | }], |
149 | }); |
150 | |
151 | my $pg = $rs->search({}, { rows => 1})->page(2)->pager; |
152 | |
153 | my $pg_wcount = $rs->page(4)->pager->total_entries (66); |
154 | |
155 | return ($artist, $pg, $pg_wcount); |
156 | }); |
157 | |
9345b14c |
158 | # more codepaths - error handling in txn_do |
159 | { |
160 | eval { $schema->txn_do ( sub { |
161 | $storage->_dbh->begin_work; |
162 | fail ('how did we get so far?!'); |
163 | } ) }; |
164 | |
165 | eval { $schema->txn_do ( sub { |
166 | $schema->txn_do ( sub { |
167 | die "It's called EXCEPTION"; |
168 | fail ('how did we get so far?!'); |
169 | } ); |
170 | fail ('how did we get so far?!'); |
171 | } ) }; |
172 | like( $@, qr/It\'s called EXCEPTION/, 'Exception correctly propagated in nested txn_do' ); |
173 | } |
174 | |
175 | # dbh_do codepath |
187ec69a |
176 | my ($rs_bind_circref, $cond_rowobj) = $schema->storage->dbh_do ( sub { |
177 | my $row = $_[0]->schema->resultset('Artist')->new({}); |
178 | my $rs = $_[0]->schema->resultset('Artist')->search({ |
179 | name => $row, # this is deliberately bogus, see FIXME below! |
180 | }); |
181 | return ($rs, $row); |
182 | }); |
183 | |
a8c2c746 |
184 | is ($pager->next_page, 3, 'There is one more page available'); |
185 | |
186 | # based on 66 per 10 pages |
187 | is ($pager_explicit_count->last_page, 7, 'Correct last page'); |
551e711a |
188 | |
052b8ce2 |
189 | # do some population (invokes some extra codepaths) |
190 | # also exercise the guard code and the manual txn control |
191 | { |
192 | my $guard = $schema->txn_scope_guard; |
193 | # populate with bindvars |
194 | $rs->populate([{ name => 'James Bound' }]); |
195 | $guard->commit; |
196 | |
197 | $schema->txn_begin; |
198 | # populate mixed |
199 | $rs->populate([{ name => 'James Rebound', rank => \ '11' }]); |
200 | $schema->txn_commit; |
201 | |
202 | $schema->txn_begin; |
203 | # and without bindvars |
204 | $rs->populate([{ name => \ '"James Unbound"' }]); |
205 | $schema->txn_rollback; |
206 | } |
207 | |
0a03206a |
208 | # prefetching |
209 | my $cds_rs = $schema->resultset('CD'); |
210 | my $cds_with_artist = $cds_rs->search({}, { prefetch => 'artist' }); |
211 | my $cds_with_tracks = $cds_rs->search({}, { prefetch => 'tracks' }); |
212 | my $cds_with_stuff = $cds_rs->search({}, { prefetch => [ 'genre', { artist => { cds => { tracks => 'cd_single' } } } ] }); |
213 | |
214 | # implicit pref |
215 | my $cds_with_impl_artist = $cds_rs->search({}, { columns => [qw/me.title artist.name/], join => 'artist' }); |
216 | |
217 | # get_column |
218 | my $getcol_rs = $cds_rs->get_column('me.cdid'); |
219 | my $pref_getcol_rs = $cds_with_stuff->get_column('me.cdid'); |
220 | |
221 | # fire the column getters |
222 | my @throwaway = $pref_getcol_rs->all; |
223 | |
a8c2c746 |
224 | my $base_collection = { |
a8c2c746 |
225 | resultset => $rs, |
307ab4c5 |
226 | |
0a03206a |
227 | pref_precursor => $cds_rs, |
228 | |
229 | pref_rs_single => $cds_with_artist, |
230 | pref_rs_multi => $cds_with_tracks, |
231 | pref_rs_nested => $cds_with_stuff, |
232 | |
233 | pref_rs_implicit => $cds_with_impl_artist, |
234 | |
235 | pref_row_single => $cds_with_artist->next, |
236 | pref_row_multi => $cds_with_tracks->next, |
237 | pref_row_nested => $cds_with_stuff->next, |
238 | |
239 | # even though this does not leak Storable croaks on it :((( |
240 | #pref_row_implicit => $cds_with_impl_artist->next, |
241 | |
242 | get_column_rs_plain => $getcol_rs, |
243 | get_column_rs_pref => $pref_getcol_rs, |
244 | |
37aafa2e |
245 | # twice so that we make sure only one H::M object spawned |
246 | chained_resultset => $rs->search_rs ({}, { '+columns' => [ 'foo' ] } ), |
247 | chained_resultset2 => $rs->search_rs ({}, { '+columns' => [ 'bar' ] } ), |
248 | |
a8c2c746 |
249 | row_object => $row_obj, |
551e711a |
250 | |
187ec69a |
251 | mc_row_object => $mc_row_obj, |
252 | |
a8c2c746 |
253 | result_source => $rs->result_source, |
551e711a |
254 | |
4376a157 |
255 | result_source_handle => $rs->result_source->handle, |
256 | |
a8c2c746 |
257 | pager_explicit_count => $pager_explicit_count, |
187ec69a |
258 | |
259 | leaky_resultset => $rs_bind_circref, |
260 | leaky_resultset_cond => $cond_rowobj, |
a8c2c746 |
261 | }; |
574d9b69 |
262 | |
218b7c12 |
263 | # this needs to fire, even if it can't find anything |
264 | # see FIXME below |
344f761c |
265 | # we run this only on smokers - trying to establish a pattern |
266 | $rs_bind_circref->next |
267 | if ( ($ENV{TRAVIS}||'') ne 'true' and DBICTest::RunMode->is_smoker); |
218b7c12 |
268 | |
eb7aa960 |
269 | require Storable; |
4376a157 |
270 | %$base_collection = ( |
271 | %$base_collection, |
272 | refrozen => Storable::dclone( $base_collection ), |
273 | rerefrozen => Storable::dclone( Storable::dclone( $base_collection ) ), |
0a03206a |
274 | pref_row_implicit => $cds_with_impl_artist->next, |
4376a157 |
275 | schema => $schema, |
276 | storage => $storage, |
277 | sql_maker => $storage->sql_maker, |
278 | dbh => $storage->_dbh, |
cd122820 |
279 | fresh_pager => $rs->page(5)->pager, |
280 | pager => $pager, |
4376a157 |
281 | ); |
282 | |
6a43bc0c |
283 | if ($has_dt) { |
284 | my $rs = $base_collection->{icdt_rs} = $schema->resultset('Event'); |
285 | |
286 | my $now = DateTime->now; |
287 | for (1..5) { |
288 | $base_collection->{"icdt_row_$_"} = $rs->create({ |
289 | created_on => DateTime->new(year => 2011, month => 1, day => $_, time_zone => "-0${_}00" ), |
290 | starts_at => $now->clone->add(days => $_), |
291 | }); |
292 | } |
293 | |
294 | # re-search |
295 | my @dummy = $rs->all; |
296 | } |
297 | |
eb7aa960 |
298 | # dbh's are created in XS space, so pull them separately |
299 | for ( grep { defined } map { @{$_->{ChildHandles}} } values %{ {DBI->installed_drivers()} } ) { |
300 | $base_collection->{"DBI handle $_"} = $_; |
301 | } |
302 | |
187ec69a |
303 | SKIP: { |
304 | if ( DBIx::Class::Optional::Dependencies->req_ok_for ('test_leaks') ) { |
85aaaac8 |
305 | my @w; |
306 | local $SIG{__WARN__} = sub { $_[0] =~ /\QUnhandled type: REGEXP/ ? push @w, @_ : warn @_ }; |
307 | |
308 | Test::Memory::Cycle::memory_cycle_ok ($base_collection, 'No cycles in the object collection'); |
309 | |
310 | if ( $] > 5.011 ) { |
311 | local $TODO = 'Silence warning due to RT56681'; |
312 | is (@w, 0, 'No Devel::Cycle emitted warnings'); |
313 | } |
187ec69a |
314 | } |
315 | else { |
316 | skip 'Circular ref test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_leaks'), 1; |
317 | } |
eb7aa960 |
318 | } |
574d9b69 |
319 | |
65d35121 |
320 | populate_weakregistry ($weak_registry, $base_collection->{$_}, "basic $_") |
321 | for keys %$base_collection; |
551e711a |
322 | } |
323 | |
50261284 |
324 | # check that "phantom-chaining" works - we never lose track of the original $schema |
325 | # and have access to the entire tree without leaking anything |
326 | { |
327 | my $phantom; |
328 | for ( |
39b80a73 |
329 | sub { DBICTest->init_schema( sqlite_use_file => 0 ) }, |
50261284 |
330 | sub { shift->source('Artist') }, |
331 | sub { shift->resultset }, |
332 | sub { shift->result_source }, |
333 | sub { shift->schema }, |
334 | sub { shift->resultset('Artist') }, |
335 | sub { shift->find_or_create({ name => 'detachable' }) }, |
336 | sub { shift->result_source }, |
337 | sub { shift->schema }, |
338 | sub { shift->clone }, |
187ec69a |
339 | sub { shift->resultset('CD') }, |
340 | sub { shift->next }, |
341 | sub { shift->artist }, |
342 | sub { shift->search_related('cds') }, |
50261284 |
343 | sub { shift->next }, |
187ec69a |
344 | sub { shift->search_related('artist') }, |
50261284 |
345 | sub { shift->result_source }, |
346 | sub { shift->resultset }, |
347 | sub { shift->create({ name => 'detached' }) }, |
348 | sub { shift->update({ name => 'reattached' }) }, |
349 | sub { shift->discard_changes }, |
350 | sub { shift->delete }, |
351 | sub { shift->insert }, |
352 | ) { |
65d35121 |
353 | $phantom = populate_weakregistry ( $weak_registry, scalar $_->($phantom) ); |
50261284 |
354 | } |
355 | |
356 | ok( $phantom->in_storage, 'Properly deleted/reinserted' ); |
357 | is( $phantom->name, 'reattached', 'Still correct name' ); |
358 | } |
a8c2c746 |
359 | |
307ab4c5 |
360 | # Naturally we have some exceptions |
361 | my $cleared; |
362 | for my $slot (keys %$weak_registry) { |
6a43bc0c |
363 | if ($slot =~ /^Test::Builder/) { |
c8194884 |
364 | # T::B 2.0 has result objects and other fancyness |
365 | delete $weak_registry->{$slot}; |
366 | } |
9345b14c |
367 | elsif ($slot =~ /^Method::Generate::(?:Accessor|Constructor)/) { |
368 | # Moo keeps globals around, this is normal |
369 | delete $weak_registry->{$slot}; |
370 | } |
7536c92b |
371 | elsif ($slot =~ /^SQL::Translator::Generator::DDL::SQLite/) { |
60fd7c30 |
372 | # SQLT::Producer::SQLite keeps global generators around for quoted |
373 | # and non-quoted DDL, allow one for each quoting style |
374 | delete $weak_registry->{$slot} |
375 | unless $cleared->{sqlt_ddl_sqlite}->{@{$weak_registry->{$slot}{weakref}->quote_chars}}++; |
307ab4c5 |
376 | } |
6a43bc0c |
377 | elsif ($slot =~ /^Hash::Merge/) { |
37aafa2e |
378 | # only clear one object of a specific behavior - more would indicate trouble |
307ab4c5 |
379 | delete $weak_registry->{$slot} |
380 | unless $cleared->{hash_merge_singleton}{$weak_registry->{$slot}{weakref}{behavior}}++; |
381 | } |
eb7aa960 |
382 | elsif ($slot =~ /^DateTime::TimeZone/) { |
383 | # DT is going through a refactor it seems - let it leak zones for now |
384 | delete $weak_registry->{$slot}; |
385 | } |
307ab4c5 |
386 | } |
387 | |
dee99c24 |
388 | # every result class has a result source instance as classdata |
389 | # make sure these are all present and distinct before ignoring |
390 | # (distinct means only 1 reference) |
391 | for my $rs_class ( |
a8c2c746 |
392 | 'DBICTest::BaseResult', |
dee99c24 |
393 | @compose_ns_classes, |
a8c2c746 |
394 | map { DBICTest::Schema->class ($_) } DBICTest::Schema->sources |
dee99c24 |
395 | ) { |
396 | # need to store the SVref and examine it separately, to push the rsrc instance off the pad |
397 | my $SV = svref_2object($rs_class->result_source_instance); |
398 | is( $SV->REFCNT, 1, "Source instance of $rs_class referenced exactly once" ); |
399 | |
400 | # ignore it |
401 | delete $weak_registry->{$rs_class->result_source_instance}; |
fa442fd5 |
402 | } |
a8c2c746 |
403 | |
dee99c24 |
404 | # Schema classes also hold sources, but these are clones, since |
405 | # each source contains the schema (or schema class name in this case) |
406 | # Hence the clone so that the same source can be registered with |
407 | # multiple schemas |
408 | for my $moniker ( keys %{DBICTest::Schema->source_registrations || {}} ) { |
409 | |
410 | my $SV = svref_2object(DBICTest::Schema->source($moniker)); |
411 | is( $SV->REFCNT, 1, "Source instance registered under DBICTest::Schema as $moniker referenced exactly once" ); |
412 | |
413 | delete $weak_registry->{DBICTest::Schema->source($moniker)}; |
fa442fd5 |
414 | } |
a8c2c746 |
415 | |
187ec69a |
416 | # FIXME !!! |
417 | # There is an actual strong circular reference taking place here, but because |
418 | # half of it is in XS no leaktracer sees it, and Devel::FindRef is equally |
419 | # stumped when trying to trace the origin. The problem is: |
420 | # |
728f32b5 |
421 | # $cond_object --> result_source --> schema --> storage --> $dbh --> {CachedKids} |
187ec69a |
422 | # ^ / |
423 | # \-------- bound value on prepared/cached STH <-----------/ |
424 | # |
728f32b5 |
425 | { |
426 | local $TODO = 'This fails intermittently - see RT#82942'; |
427 | if ( my $r = $weak_registry->{'basic leaky_resultset_cond'}{weakref} ) { |
428 | ok(! defined $r, 'Self-referential RS conditions no longer leak!') |
429 | or $r->result_source(undef); |
430 | } |
187ec69a |
431 | } |
432 | |
65d35121 |
433 | assert_empty_weakregistry ($weak_registry); |
551e711a |
434 | |
66917da3 |
435 | # we got so far without a failure - this is a good thing |
436 | # now let's try to rerun this script under a "persistent" environment |
437 | # this is ugly and dirty but we do not yet have a Test::Embedded or |
438 | # similar |
439 | |
f3ec358e |
440 | # set up -I |
441 | require Config; |
442 | $ENV{PERL5LIB} = join ($Config::Config{path_sep}, @INC); |
443 | ($ENV{PATH}) = $ENV{PATH} =~ /(.+)/; |
444 | |
445 | |
7be5717e |
446 | my $persistence_tests = { |
447 | PPerl => { |
448 | cmd => [qw/pperl --prefork=1/, __FILE__], |
449 | }, |
450 | 'CGI::SpeedyCGI' => { |
451 | cmd => [qw/speedy -- -t5/, __FILE__], |
452 | }, |
453 | }; |
66917da3 |
454 | |
455 | # scgi is smart and will auto-reap after -t amount of seconds |
7be5717e |
456 | # pperl needs an actual killer :( |
457 | $persistence_tests->{PPerl}{termcmd} = [ |
458 | $persistence_tests->{PPerl}{cmd}[0], |
459 | '--kill', |
460 | @{$persistence_tests->{PPerl}{cmd}}[ 1 .. $#{$persistence_tests->{PPerl}{cmd}} ], |
461 | ]; |
66917da3 |
462 | |
463 | SKIP: { |
464 | skip 'Test already in a persistent loop', 1 |
465 | if $ENV{DBICTEST_IN_PERSISTENT_ENV}; |
466 | |
66917da3 |
467 | skip 'Main test failed - skipping persistent env tests', 1 |
468 | unless $TB->is_passing; |
469 | |
66917da3 |
470 | local $ENV{DBICTEST_IN_PERSISTENT_ENV} = 1; |
471 | |
7be5717e |
472 | require IPC::Open2; |
473 | |
474 | for my $type (keys %$persistence_tests) { SKIP: { |
53a5200d |
475 | unless (eval "require $type") { |
476 | # Don't terminate what we didn't start |
477 | delete $persistence_tests->{$type}{termcmd}; |
478 | skip "$type module not found", 1; |
479 | } |
7be5717e |
480 | |
481 | my @cmd = @{$persistence_tests->{$type}{cmd}}; |
66917da3 |
482 | |
483 | # since PPerl is racy and sucks - just prime the "server" |
484 | { |
485 | local $ENV{DBICTEST_PERSISTENT_ENV_BAIL_EARLY} = 1; |
7be5717e |
486 | system(@cmd); |
66917da3 |
487 | sleep 1; |
488 | |
7be5717e |
489 | # see if the thing actually runs, if not - might as well bail now |
490 | skip "Something is wrong with $type ($!)", 1 |
491 | if system(@cmd); |
66917da3 |
492 | } |
493 | |
494 | for (1,2,3) { |
7be5717e |
495 | note ("Starting run in persistent env ($type pass $_)"); |
496 | IPC::Open2::open2(my $out, undef, @cmd); |
497 | my @out_lines; |
498 | while (my $ln = <$out>) { |
499 | next if $ln =~ /^\s*$/; |
500 | push @out_lines, " $ln"; |
501 | last if $ln =~ /^\d+\.\.\d+$/; # this is persistence, we need to terminate reading on our end |
502 | } |
503 | print $_ for @out_lines; |
504 | close $out; |
505 | wait; |
506 | ok (!$?, "Run in persistent env ($type pass $_): exit $?"); |
507 | ok (scalar @out_lines, "Run in persistent env ($type pass $_): got output"); |
66917da3 |
508 | } |
509 | |
7be5717e |
510 | ok (! system (@{$persistence_tests->{$type}{termcmd}}), "killed $type server instance") |
511 | if $persistence_tests->{$type}{termcmd}; |
512 | }} |
66917da3 |
513 | } |
514 | |
551e711a |
515 | done_testing; |
66917da3 |
516 | |
517 | # just an extra precaution in case we blew away from the SKIP - since there are no |
518 | # PID files to go by (man does pperl really suck :( |
519 | END { |
520 | unless ($ENV{DBICTEST_IN_PERSISTENT_ENV}) { |
7be5717e |
521 | close $_ for (*STDIN, *STDOUT, *STDERR); |
66917da3 |
522 | local $?; # otherwise test will inherit $? of the system() |
53a5200d |
523 | system (@{$persistence_tests->{PPerl}{termcmd}}) |
524 | if $persistence_tests->{PPerl}{termcmd}; |
66917da3 |
525 | } |
526 | } |