1Test::Stream::Plugin::CUasneFrorCko(n3t)ributed Perl DocTuemsetn:t:aSttiroenam::Plugin::CanFork(3)
2
3
4

NAME

6       Test::Stream::Plugin::CanFork - Skip a test file unless the system
7       supports forking
8

DEPRECATED

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

DESCRIPTION

16       It is fairly common to write tests that need to fork. Not all systems
17       support forking. This library does the hard work of checking if forking
18       is supported on the current system. If forking is not supported then
19       this will skip all tests and exit true.
20

SYNOPSIS

22           use Test::Stream::Plugin::CanFork;
23
24           ... Code that forks ...
25
26       or
27
28           use Test::Stream::Plugin::CanFork real => 1;
29
30           ... Code that requires true fork support (not emulated) ...
31

EXPLANATION

33       Checking if the current system supports forking is not simple, here is
34       an example of how to do it:
35
36           use Config;
37
38           sub CAN_FORK {
39               return 1 if $Config{d_fork};
40
41               # Some platforms use ithreads to mimick forking
42               return 0 unless $^O eq 'MSWin32' || $^O eq 'NetWare';
43               return 0 unless $Config{useithreads};
44               return 0 unless $Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/;
45
46               # Threads are not reliable before 5.008001
47               return 0 unless $] >= 5.008001;
48
49               # Devel::Cover currently breaks with threads
50               return 0 if $INC{'Devel/Cover.pm'};
51               return 1;
52           }
53
54       Duplicating this non-trivial code in all tests that need to fork is
55       dumb. It is easy to forget bits, or get it wrong. On top of these
56       checks you also need to tell the harness that no tests should run and
57       why.
58

SEE ALSO

60       Test::Stream::Plugin::CanThread
61           Skip the test file if the system does not support threads.
62
63       Test::Stream
64           Test::Stream::Plugin::CanFork uses Test::Stream under the hood.
65

SOURCE

67       The source code repository for Test::Stream can be found at
68       http://github.com/Test-More/Test-Stream/.
69

MAINTAINERS

71       Chad Granum <exodist@cpan.org>
72

AUTHORS

74       Chad Granum <exodist@cpan.org>
75
77       Copyright 2015 Chad Granum <exodist7@gmail.com>.
78
79       This program is free software; you can redistribute it and/or modify it
80       under the same terms as Perl itself.
81
82       See http://dev.perl.org/licenses/
83
84
85
86perl v5.34.0                      2022-01-21  Test::Stream::Plugin::CanFork(3)
Impressum