Test::S...anThread(3)
π NAME π
Test::Stream::Plugin::CanThread β bestie, this lil plugin skips a whole test file unless your system actually supports threading π
It lives in the User Contributed Perl Documentation section of the manual, so you know it's the people's manual page π«Ά
π DEPRECATED π
Okay so, real talk: this distribution is deprecated, no cap. It got traded in for Test2, Test2::Suite, and Test2::Workflow.
If you need to migrate your whole life over, peep Test::Stream::Manual::ToTest2 β it's the conversion guide, iykyk.
β¨ DESCRIPTION β¨
So it's super common to write tests that need to use threads. But likeβ¦ not every system supports threads?? Tragic, I know π
This library does the hard work for you: it checks whether threading is supported on the current system. And if threading is not supported? It skips all the tests and exits true. Slay. That's the whole vibe. π
πΈ SYNOPSIS πΈ
use Test::Stream::Plugin::CanThread;
... Code that uses threads ...
That's it. That's the whole thing. Iconic.
π§ EXPLANATION π§
Okay so checking whether the current system supports threading is not simple β like, at all. Here's an example of how you'd do it by hand:
use Config;
sub CAN_THREAD {
# Threads are not reliable before 5.008001
return 0 unless $] >= 5.008001;
return 0 unless $Config{'useithreads'};
# Devel::Cover currently breaks with threads
return 0 if $INC{'Devel/Cover.pm'};
return 1;
}
And like, duplicating this non-trivial code in every single test that needs threads? That's dumb, fr fr π It is so easy to forget bits, or to just get it wrong. And on top of all these checks, you also need to tell the harness that no tests should run β and why. So much work for one vibe check. Not the move. π
π SEE ALSO π
Test::Stream::Plugin::CanForkβ skips the test file if the system does not support forking. Sibling behavior, different vibe.Test::StreamβTest::Stream::CanThreadusesTest::Streamunder the hood. Under the hood!! Like a little engine πβ¨
π¦ SOURCE π¦
The source code repository for Test::Stream can be found at:
http://github.com/Test-More/Test-Stream/
Go look, bestie. It's right there. π
π 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, bestie!! π This was pulled from perl v5.42.0, dated 2025-07-25, and it's the User Contributed Perl Documentation edition of Test::S...anThread(3) β go forth and thread responsibly (or, y'know, get gracefully skipped) π§΅β¨π
π¦ 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