Skip to content

Instantly share code, notes, and snippets.

@autarch
Created February 24, 2016 20:51
Show Gist options
  • Select an option

  • Save autarch/f024d4d3de94332bc02a to your computer and use it in GitHub Desktop.

Select an option

Save autarch/f024d4d3de94332bc02a to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use Test2::IPC;
use Test2::Tools::AsyncSubtest qw( subtest_start subtest_run subtest_finish );
use Test2::API qw( context_do test2_stack );
foo($_) for 1, 2;
test2_stack()->top->cull;
sub foo {
my $num = shift;
my $subtest = subtest_start($num);
if ( my $pid = fork ) {
waitpid( $pid, 0 );
subtest_finish($subtest);
return;
}
subtest_run(
$subtest,
sub {
context_do {
my $ctx = shift;
if ( $num == 1 ) {
$ctx->plan( 0, SKIP => 'skipping all' );
}
else {
$ctx->ok( 1, 'foo' );
}
};
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment