Skip to content

When testing in parallel, orphaned grandchild pids cause problems with Test2. #113

@mvsjes2

Description

@mvsjes2

When running tests in parallel, if one of the test classes also creates forks, and any of those 'grandchild' forks dies, it can mess up Test2::ASync and possibly cause other follow-on problems duing global destruction.

To recreate:

Create a parent script to run tests:

use Test::Class::Moose::Load './t';
use Test::Class::Moose::Runner;
my $runner = Test::Class::Moose::Runner->new(jobs => 3);
$runner->runtests;

...and a child class in a 't' subfolder that is set up to die:

package Class1;

use Test::Class::Moose;
use Parallel::ForkManager;

sub test_process {
    my $pm = Parallel::ForkManager->new(1);
    if (!$pm->start) {
        pass;
        die 'grand child object died';
        $pm->finish;
    }
    $pm->wait_all_children;
}

1;

Produces "Attempt to detach from wrong child" from Test2::Async while the test suite is running, and "Subtest can only be finished in the process/thread that created it" during destruction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions