1Test::Stream::Plugin::CUasneTrhrCeoandt(r3i)buted Perl DToecsutm:e:nSttarteiaomn::Plugin::CanThread(3)
2
3
4
6 Test::Stream::Plugin::CanThread - Skip a test file unless the system
7 supports threading
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 It is fairly common to write tests that need to use threads. Not all
17 systems support threads. This library does the hard work of checking if
18 threading is supported on the current system. If threading is not
19 supported then this will skip all tests and exit true.
20
22 use Test::Stream::Plugin::CanThread;
23
24 ... Code that uses threads ...
25
27 Checking if the current system supports threading is not simple, here
28 is an example of how to do it:
29
30 use Config;
31
32 sub CAN_THREAD {
33 # Threads are not reliable before 5.008001
34 return 0 unless $] >= 5.008001;
35 return 0 unless $Config{'useithreads'};
36
37 # Devel::Cover currently breaks with threads
38 return 0 if $INC{'Devel/Cover.pm'};
39 return 1;
40 }
41
42 Duplicating this non-trivial code in all tests that need to use threads
43 is dumb. It is easy to forget bits, or get it wrong. On top of these
44 checks you also need to tell the harness that no tests should run and
45 why.
46
48 Test::Stream::Plugin::CanFork
49 Skip the test file if the system does not support forking.
50
51 Test::Stream
52 Test::Stream::CanThread uses Test::Stream under the hood.
53
55 The source code repository for Test::Stream can be found at
56 http://github.com/Test-More/Test-Stream/.
57
59 Chad Granum <exodist@cpan.org>
60
62 Chad Granum <exodist@cpan.org>
63
65 Copyright 2015 Chad Granum <exodist7@gmail.com>.
66
67 This program is free software; you can redistribute it and/or modify it
68 under the same terms as Perl itself.
69
70 See http://dev.perl.org/licenses/
71
72
73
74perl v5.34.0 2021-07-27Test::Stream::Plugin::CanThread(3)