1Test2::Require::ThreadsU(s3e)r Contributed Perl DocumentaTteisotn2::Require::Threads(3)
2
3
4

NAME

6       Test2::Require::Threads - Skip a test file unless the system supports
7       threading
8

DESCRIPTION

10       It is fairly common to write tests that need to use threads. Not all
11       systems support threads. This library does the hard work of checking if
12       threading is supported on the current system. If threading is not
13       supported then this will skip all tests and exit true.
14

SYNOPSIS

16           use Test2::Require::Threads;
17
18           ... Code that uses threads ...
19

EXPLANATION

21       Checking if the current system supports threading is not simple, here
22       is an example of how to do it:
23
24           use Config;
25
26           sub CAN_THREAD {
27               # Threads are not reliable before 5.008001
28               return 0 unless $] >= 5.008001;
29               return 0 unless $Config{'useithreads'};
30
31               # Devel::Cover currently breaks with threads
32               return 0 if $INC{'Devel/Cover.pm'};
33               return 1;
34           }
35
36       Duplicating this non-trivial code in all tests that need to use threads
37       is error-prone. It is easy to forget bits, or get it wrong. On top of
38       these checks you also need to tell the harness that no tests should run
39       and why.
40

SEE ALSO

42       Test2::Require::CanFork
43           Skip the test file if the system does not support forking.
44
45       Test2
46           Test2::Require::Threads uses Test2 under the hood.
47

SOURCE

49       The source code repository for Test2-Suite can be found at
50       https://github.com/Test-More/Test2-Suite/.
51

MAINTAINERS

53       Chad Granum <exodist@cpan.org>
54

AUTHORS

56       Chad Granum <exodist@cpan.org>
57
59       Copyright 2018 Chad Granum <exodist@cpan.org>.
60
61       This program is free software; you can redistribute it and/or modify it
62       under the same terms as Perl itself.
63
64       See http://dev.perl.org/licenses/
65
66
67
68perl v5.30.1                      2020-01-31        Test2::Require::Threads(3)
Impressum