1Test::Stream::Sync(3) User Contributed Perl DocumentationTest::Stream::Sync(3)
2
3
4
6 Test::Stream::Sync - Primary Synchronization point, this is where
7 global stuff lives.
8
10 This distribution is deprecated in favor of Test2, Test2::Suite, and
11 Test2::Workflow.
12
13 See Test::Stream::Manual::ToTest2 for a conversion guide.
14
16 The internals of this package are subject to change at any time! The
17 public methods provided will not change in backwords incompatible ways,
18 but the underlying implementation details might. Do not break
19 encapsulation here!
20
22 There is a need to synchronize some details for all tests that run.
23 This package stores these global objects. As little as possible is kept
24 here, when possible things should not be global.
25
27 use Test::Stream::Sync; # No Exports
28
29 my $init = Test::Stream::Sync->init_done;
30 my $stack = Test::Stream::Sync->stack;
31 my $ipc = Test::Stream::Sync->ipc;
32
33 Test::Stream::Sync->set_formatter($FORMATTER)
34 my $formatter = Test::Stream::Sync->formatter;
35
37 This class stores global instances of things. This package is NOT an
38 object, everything that uses it will get the same stuff.
39
40 $bool = Test::Stream::Sync->init_done
41 This will return true if the stack and ipc instances have already
42 been initialized. It will return false if they have not.
43
44 $stack = Test::Stream::Sync->stack
45 This will return the global Test::Stream::Stack instance. If this
46 has not yet been initialized it will be initialized now.
47
48 $ipc = Test::Stream::Sync->ipc
49 This will return the global Test::Stream::IPC instance. If this has
50 not yet been initialized it will be initialized now.
51
52 $formatter = Test::Stream::Sync->formatter
53 This will return the global formatter class. This is not an
54 instance. By default the formatter is set to
55 Test::Stream::Formatter::TAP.
56
57 You can override this default using the "TS_FORMATTER" environment
58 variable.
59
60 Normally 'Test::Stream::Formatter::' is prefixed to the value in
61 the environment variable:
62
63 $ TS_FORMATTER='TAP' perl test.t # Use the Test::Stream::Formatter::TAP formatter
64 $ TS_FORMATTER='Foo' perl test.t # Use the Test::Stream::Formatter::Foo formatter
65
66 If you want to specify a full module name you use the '+' prefix:
67
68 $ TS_FORMATTER='+Foo::Bar' perl test.t # Use the Foo::Bar formatter
69
70 Test::Stream::Sync->set_formatter($class)
71 Set the global formatter class. This can only be set once. Note:
72 This will override anything specified in the 'TS_FORMATTER'
73 environment variable.
74
75 $bool = Test::Stream::Sync->no_wait
76 Test::Stream::Sync->no_wait($bool)
77 This can be used to get/set the no_wait status. Waiting is turned
78 on by default. Waiting will cause the parent process/thread to wait
79 until all child processes and threads are finished before exiting.
80 You will almost never want to turn this off.
81
82 Test::Stream::Sync->add_hook(sub { ... })
83 This can be used to add a hook that is called after all testing is
84 done. This is too late to add additional results, the main use of
85 this hook is to set the exit code.
86
87 Test::Stream::Sync->add_hook(
88 sub {
89 my ($context, $exit, \$new_exit) = @_;
90 ...
91 }
92 );
93
94 The $context passed in will be an instance of
95 Test::Stream::Context. The $exit argument will be the original exit
96 code before anything modified it. $$new_exit is a reference to the
97 new exit code. You may modify this to change the exit code. Please
98 note that $$new_exit may already be different from $exit
99
100 Test::Stream::Sync->post_load(sub { ... })
101 Add a callback that will be called when Test::Stream is finished
102 loading. This means the callback will be run when Test::Stream is
103 done loading all the plugins in your use statement. If Test::Stream
104 has already finished loading then the callback will be run
105 immedietly.
106
107 $bool = Test::Stream::Sync->loaded
108 Test::Stream::Sync->loaded($true)
109 Without arguments this will simply return the boolean value of the
110 loaded flag. If Test::Stream has finished loading this will be
111 true, otherwise false. If a true value is provided as an argument
112 then this will set the flag to true, and run all "post_load"
113 callbacks. The second form should ONLY ever be used in Test::Stream
114 or alternative loader modules.
115
117 This package has an END block. This END block is responsible for
118 setting the exit code based on the test results. This end block also
119 calls the hooks that can be added to this package.
120
122 The source code repository for Test::Stream can be found at
123 http://github.com/Test-More/Test-Stream/.
124
126 Chad Granum <exodist@cpan.org>
127
129 Chad Granum <exodist@cpan.org>
130
132 Copyright 2015 Chad Granum <exodist7@gmail.com>.
133
134 This program is free software; you can redistribute it and/or modify it
135 under the same terms as Perl itself.
136
137 See http://dev.perl.org/licenses/
138
139
140
141perl v5.38.0 2023-07-21 Test::Stream::Sync(3)