Skip to content

Commit 50c32de

Browse files
committed
When testing in parallel, ignore orphaned child pids.
1 parent f263d2e commit 50c32de

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lib/Test/Class/Moose/Executor/Parallel.pm

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,27 @@ sub _run_test_classes_in_parallel {
116116
}
117117

118118
# This chunk of code only runs in child processes
119+
my $child_pid = $$;
120+
119121
my $class_report;
120122
$subtest->attach($id);
121123
$subtest->run(
122124
sub {
123125
$class_report = $self->run_test_class($test_class);
124126
}
125127
);
126-
$subtest->detach;
127-
$self->_fork_manager->finish( 0, \$class_report );
128+
129+
# if the test class also creates forks, and one of those forks dies,
130+
# the dead child ends up running here, and causes subsequent problems
131+
# with Test2::AsyncSubtest::detach, and can potentially cascade into
132+
# all kinds of other problems during global destruction. i have no
133+
# idea how a grandchild death can end up running this code...
134+
if ($$ == $child_pid) {
135+
$subtest->detach;
136+
$self->_fork_manager->finish( 0, \$class_report );
137+
} else {
138+
warn "Ignoring unknown child pid $$, did a grandchild pid die?";
139+
}
128140
}
129141

130142
$self->_fork_manager->wait_all_children;

0 commit comments

Comments
 (0)