Test::Stream::Sync(3)
๐ Test::Stream::Sync ๐
okay bestie, welcome to Test::Stream::Sync, straight outta the User Contributed Perl Documentation section of your friendly neighbourhood man page ๐
this is THE spot where all the global stuff lives, the group chat of your test suite, the one place everybody syncs up before the show starts ๐
โจ NAME โจ
Test::Stream::Sync โ primary synchronization point, this is where global stuff lives. no cap, that's literally the whole job ๐ซถ
๐ญ DEPRECATED ๐ญ
not me having to tell you this... this distribution is deprecated in favor of Test2, Test2::Suite, and Test2::Workflow. it's giving "the old era was iconic but we're moving on" ๐
for the conversion guide, go peek at Test::Stream::Manual::ToTest2 โ she'll walk you through it ๐ธ
๐จ INTERNALS NOTE ๐จ
the internals of this package are subject to change at any time!! the public methods provided will not change in backwards incompatible ways, but the underlying implementation details might. do not break encapsulation here! like... hands off the vibes, bestie ๐
๐ DESCRIPTION ๐
so here's the thing โ there's a real need to synchronize some details for all the tests that run. this package stores those global objects. and the way she stays slay is by keeping as little in here as possible: when possible, things should not be global. minimalism is the aesthetic, periodt โจ
๐ฆ SYNOPSIS ๐ฆ
use Test::Stream::Sync; # No Exports
my $init = Test::Stream::Sync->init_done;
my $stack = Test::Stream::Sync->stack;
my $ipc = Test::Stream::Sync->ipc;
Test::Stream::Sync->set_formatter($FORMATTER)
my $formatter = Test::Stream::Sync->formatter;
look at that. no exports, just vibes ๐
๐ CLASS METHODS ๐
this class stores global instances of things. and listen โ this package is NOT an object. everything that uses it will get the same stuff. one for all, all for one, main character energy for the entire process ๐
$bool = Test::Stream::Sync->init_doneโ returns true if the stack and ipc instances have already been initialized. returns false if they have not. it's the "are we there yet" check ๐$stack = Test::Stream::Sync->stackโ hands you the globalTest::Stream::Stackinstance. if it hasn't been initialized yet... it gets initialized right now, on the spot, no waiting โจ$ipc = Test::Stream::Sync->ipcโ hands you the globalTest::Stream::IPCinstance. same deal: not initialized yet? congrats, it's initialized now ๐$formatter = Test::Stream::Sync->formatterโ returns the global formatter class. important, bestie: this is not an instance. by default the formatter is set toTest::Stream::Formatter::TAP.
you can override that default using the TS_FORMATTER environment variable ๐
normally, 'Test::Stream::Formatter::' is prefixed to the value in the environment variable:
$ TS_FORMATTER='TAP' perl test.t # Use the Test::Stream::Formatter::TAP formatter
$ TS_FORMATTER='Foo' perl test.t # Use the Test::Stream::Formatter::Foo formatter
and if you wanna specify a full module name you use the '+' prefix:
$ TS_FORMATTER='+Foo::Bar' perl test.t # Use the Foo::Bar formatter
Test::Stream::Sync->set_formatter($class)โ sets the global formatter class. this can only be set once. note: this will override anything specified in the'TS_FORMATTER'environment variable. sorry env var, she said what she said ๐$bool = Test::Stream::Sync->no_waitTest::Stream::Sync->no_wait($bool)โ get/set the no_wait status. waiting is turned on by default. waiting will cause the parent process/thread to wait until all child processes and threads are finished before exiting. you will almost never want to turn this off โ fr fr, leave it alone ๐Test::Stream::Sync->add_hook(sub { ... })โ adds a hook that gets called after all testing is done. heads up: it's too late to add additional results at that point. the main use of this hook is to set the exit code ๐ช
Test::Stream::Sync->add_hook(
sub {
my ($context, $exit, \$new_exit) = @_;
...
}
);
the $context passed in will be an instance of Test::Stream::Context. the $exit argument will be the original exit code before anything modified it. $$new_exit is a reference to the new exit code โ you may modify this to change the exit code. please note that $$new_exit may already be different from $exit ๐ no assumptions, bestie.
Test::Stream::Sync->post_load(sub { ... })โ add a callback that will be called whenTest::Streamis finished loading. that means the callback runs whenTest::Streamis done loading all the plugins in yourusestatement. and ifTest::Streamhas already finished loading? the callback runs immedietly ๐ธ$bool = Test::Stream::Sync->loadedTest::Stream::Sync->loaded($true)โ with no arguments this simply returns the boolean value of the loaded flag. ifTest::Streamhas finished loading this will be true, otherwise false. if a true value is provided as an argument, then this sets the flag to true and runs all"post_load"callbacks. the second form should ONLY ever be used inTest::Streamor alternative loader modules. like, only-touch-if-you-know-why energy ๐ซฃ
๐ฎ MAGIC ๐ฎ
this package has an END block. that END block is responsible for setting the exit code based on the test results. and this end block also calls the hooks that can be added to this package. it's giving behind-the-scenes sorcery โจ๐ง
๐ฆ SOURCE ๐ฆ
the source code repository for Test::Stream can be found at http://github.com/Test-More/Test-Stream/ โ go say hi to the code ๐
๐ซถ 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 perl v5.42.0, dated 2025-07-25, filed under Test::Stream::Sync(3) โ thanks for reading, you ate that ๐๐ฆ๐
๐ฆ 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