Test::S...anThread(3)

πŸ“¦
version 1.302027 Β· 2 versions
, in fedora 43

πŸ‘‘ 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::CanThread uses Test::Stream under 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 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