Test::S...:CanFork(3)
π Test::Stream::Plugin::CanFork π
okay bestie, so this is Test::Stream::Plugin::CanFork, part of the Test::Stream era of Perl testing (rip, she's retired now, more on that in a sec), and it lives in the User Contributed Perl Documentation section of your man pages. π
β¨ NAME β¨
Test::Stream::Plugin::CanFork β skip a test file unless the system supports forking π΄
π DEPRECATED π
not me having to deliver this news butβ¦ this whole distribution is deprecated in favor ofTest2,Test2::Suite, andTest2::Workflow. it's giving "we don't do that here anymore" π
if you wanna make the switch, there's a conversion guide waiting for you over in Test::Stream::Manual::ToTest2. go read it, i'll wait π
πΈ DESCRIPTION πΈ
so here's the vibe: it's super common to write tests that need to fork. but likeβ¦ not every system can even do that?? π so instead of every single test file out here reinventing the fork-check wheel, this library does the hard work for you β it checks whether forking is supported on the current system. and if forking is not supported? it skips all the tests and exits true. iconic behavior honestly. π
β¨ SYNOPSIS β¨
the basic girlie setup:
use Test::Stream::Plugin::CanFork;
... Code that forks ...
or, if you need the real deal:
use Test::Stream::Plugin::CanFork real => 1;
... Code that requires true fork support (not emulated) ...
π¦ EXPLANATION π¦
okay so checking whether a system supports forking is genuinely not simple. like, the way that this is a whole ordeal?? here's literally how you'd have to do it by hand:
use Config;
sub CAN_FORK {
return 1 if $Config{d_fork};
# Some platforms use ithreads to mimick forking
return 0 unless $^O eq 'MSWin32' || $^O eq 'NetWare';
return 0 unless $Config{useithreads};
return 0 unless $Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/;
# Threads are not reliable before 5.008001
return 0 unless $] >= 5.008001;
# Devel::Cover currently breaks with threads
return 0 if $INC{'Devel/Cover.pm'};
return 1;
}
copy-pasting this non-trivial little monster into every single test that needs to fork is dumb. fr fr. it's so easy to forget a bit, or get it wrong entirely, and then your tests are lying to you π
and on top of all those checks?? you also have to tell the harness that no tests should run, and why. that's a whole extra thing. exhausting. this plugin handles it so you don't have to. π«Ά
π SEE ALSO π
Test::Stream::Plugin::CanThreadβ skips the test file if the system doesn't support threads. π§΅Test::StreamβTest::Stream::Plugin::CanForkusesTest::Streamunder the hood. iykyk π
π SOURCE π
the source code repo for Test::Stream is right here, bestie:
http://github.com/Test-More/Test-Stream/
π MAINTAINERS π
Chad Granum <exodist@cpan.org>
β AUTHORS β
Chad Granum <exodist@cpan.org>
π COPYRIGHT π
Copyright 2015 Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://dev.perl.org/licenses/
and that's the whole page, babe β¨ this one shipped as part of perl v5.42.0, dated 2025-07-25, straight from the User Contributed Perl Documentation β stay forkable, stay fabulous ππΈπ¦
π¦ where this page comes from
- fedora 43: perl-Test-Stream 1.302027-35.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms