I realize it maybe shouldn't fully do so since the additional test are still running and it could be pretty confusing if they have side effects or something. But on the other hand the user did choose fork_subtest(), and if they took the trouble to parallel things they likely want to run all the tests as much as possible and not fall back to SUBTEST_FILTER or the like.
Maybe the answer is don't call finish() on subtests after the first failure, but then you get a big noisy warning on STDOUT and STDERR showing left-over data.
So right now I have:
foreach ( @forked_subtests ) {
if ( not $_->finish ) {
warn "finish() on a handle returned by fork_subtest failed";
# The seems to suppress the big message showing left-over data from
# (un-finish()ed) children (which gets send to both STDOUT and
# STDERR, but not the message about "IPC is waiting for children
# to finish..." which I suppose comes from an END block in Test2
# somwhere. I'm not sure why that latter message is still showing,
# maybe it's running in a supervisor process or something (and so has
# it's own copies of STDOUT and STDERR). This seems like a decent
# compromise between easily viewable output and remembering that
# additional tests are still running and giving them a chance to
# finish, but if the output is still too noisy see the comment below.
STDOUT->flush();
STDERR->flush();
open(STDOUT, '>/dev/null');
open(STDERR, '>/dev/null');
# Can use POSIX::_exit 1 here instead to prevent END {} block to remove
# some more noise output, at the cost of having children still floating
# around running tests...
exit 1;
}
}
which works but seems sort of fragile and weird. I don't know if there's something fully general that could be done here, but maybe a message about "Suppressing additional child output due to Test2::Plugin::BailOnFail" or something would
be a reasonable convenience.
I realize it maybe shouldn't fully do so since the additional test are still running and it could be pretty confusing if they have side effects or something. But on the other hand the user did choose fork_subtest(), and if they took the trouble to parallel things they likely want to run all the tests as much as possible and not fall back to SUBTEST_FILTER or the like.
Maybe the answer is don't call finish() on subtests after the first failure, but then you get a big noisy warning on STDOUT and STDERR showing left-over data.
So right now I have:
which works but seems sort of fragile and weird. I don't know if there's something fully general that could be done here, but maybe a message about "Suppressing additional child output due to Test2::Plugin::BailOnFail" or something would
be a reasonable convenience.