X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=blobdiff_plain;f=t%2F50fork.t;h=8fea72f51e731450e7e276a26c393c62d73684b5;hp=df6957cc9a605319d309e4473ef2846074f12af2;hb=7d216b101775c472b012b257d848f50d78b193c8;hpb=f410ea47d00b415ebb9b277be6417d724c9a643f diff --git a/t/50fork.t b/t/50fork.t index df6957c..8fea72f 100644 --- a/t/50fork.t +++ b/t/50fork.t @@ -18,7 +18,7 @@ if($num_children !~ /^[0-9]+$/ || $num_children < 10) { $num_children = 10; } -plan tests => $num_children + 6; +plan tests => ($num_children*2) + 6; use lib qw(t/lib); @@ -76,18 +76,36 @@ while(@pids < $num_children) { $pid = $$; - my $child_rs = $schema->resultset('CD')->search({ year => 1901 }); - my $row = $parent_rs->next; - if($row && $row->get_column('artist') =~ /^(?:123|456)$/) { - $schema->resultset('CD')->create({ title => "test success $pid", artist => $pid, year => scalar(@pids) }); + my $work = sub { + my $child_rs = $schema->resultset('CD')->search({ year => 1901 }); + my $row = $parent_rs->next; + $schema->resultset('CD')->create({ title => "test success $pid", artist => $pid, year => scalar(@pids) }) + if($row && $row->get_column('artist') =~ /^(?:123|456)$/); + }; + + # try with and without transactions + if ((@pids % 3) == 1) { + my $guard = $schema->txn_scope_guard; + $work->(); + $guard->commit; } + elsif ((@pids % 3) == 2) { + $schema->txn_do ($work); + } + else { + $work->(); + } + sleep(3); - exit; + exit 0; } ok(1, "past forking"); -waitpid($_,0) for(@pids); +for (@pids) { + waitpid($_,0); + ok (! $?, "Child $_ exitted cleanly"); +}; ok(1, "past waiting");