From 50c32ded0000b8e85455efff424290b19c856f17 Mon Sep 17 00:00:00 2001 From: mvsjes2 Date: Mon, 1 Apr 2024 16:54:58 -0300 Subject: [PATCH 1/2] When testing in parallel, ignore orphaned child pids. --- lib/Test/Class/Moose/Executor/Parallel.pm | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/Test/Class/Moose/Executor/Parallel.pm b/lib/Test/Class/Moose/Executor/Parallel.pm index b5c5fce..e96f3e1 100755 --- a/lib/Test/Class/Moose/Executor/Parallel.pm +++ b/lib/Test/Class/Moose/Executor/Parallel.pm @@ -116,6 +116,8 @@ sub _run_test_classes_in_parallel { } # This chunk of code only runs in child processes + my $child_pid = $$; + my $class_report; $subtest->attach($id); $subtest->run( @@ -123,8 +125,18 @@ sub _run_test_classes_in_parallel { $class_report = $self->run_test_class($test_class); } ); - $subtest->detach; - $self->_fork_manager->finish( 0, \$class_report ); + + # if the test class also creates forks, and one of those forks dies, + # the dead child ends up running here, and causes subsequent problems + # with Test2::AsyncSubtest::detach, and can potentially cascade into + # all kinds of other problems during global destruction. i have no + # idea how a grandchild death can end up running this code... + if ($$ == $child_pid) { + $subtest->detach; + $self->_fork_manager->finish( 0, \$class_report ); + } else { + warn "Ignoring unknown child pid $$, did a grandchild pid die?"; + } } $self->_fork_manager->wait_all_children; From 20f3a16873487a8753457a7440bfa346a438f8ed Mon Sep 17 00:00:00 2001 From: mvsjes2 Date: Fri, 5 Apr 2024 17:04:17 -0300 Subject: [PATCH 2/2] Fix up precious failures. --- lib/Test/Class/Moose/Executor/Parallel.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Test/Class/Moose/Executor/Parallel.pm b/lib/Test/Class/Moose/Executor/Parallel.pm index e96f3e1..61ef902 100755 --- a/lib/Test/Class/Moose/Executor/Parallel.pm +++ b/lib/Test/Class/Moose/Executor/Parallel.pm @@ -96,8 +96,9 @@ sub _test_class_is_parallelizable { $_, 'noparallel' ); - } - $self->_test_methods_for($test_class); + } + + $self->_test_methods_for($test_class); } sub _run_test_classes_in_parallel { @@ -131,10 +132,11 @@ sub _run_test_classes_in_parallel { # with Test2::AsyncSubtest::detach, and can potentially cascade into # all kinds of other problems during global destruction. i have no # idea how a grandchild death can end up running this code... - if ($$ == $child_pid) { + if ( $$ == $child_pid ) { $subtest->detach; $self->_fork_manager->finish( 0, \$class_report ); - } else { + } + else { warn "Ignoring unknown child pid $$, did a grandchild pid die?"; } }