blob: c94614cbd839075ca9ecebdf51372b379b865035 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
package Test::CanFork;
use strict;
use warnings;
use Config;
my $Can_Fork = $Config{d_fork}
|| (($^O eq 'MSWin32' || $^O eq 'NetWare')
and $Config{useithreads}
and $Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/);
sub import {
my $class = shift;
if (!$Can_Fork) {
require Test::More;
Test::More::plan(skip_all => "This system cannot fork");
}
if ($^O eq 'MSWin32' && $] == 5.010000) {
require Test::More;
Test::More::plan('skip_all' => "5.10 has fork/threading issues that break fork on win32");
}
for my $var (@_) {
next if $ENV{$var};
require Test::More;
Test::More::plan(skip_all => "This forking test will only run when the '$var' environment variable is set.");
}
}
1;
__END__
=head1 NAME
Test::CanFork - Only run tests when forking is supported, optionally conditioned on ENV vars.
=head1 DESCRIPTION
Use this first thing in a test that should be skipped when forking is not
supported. You can also specify that the test should be skipped when specific
environment variables are not set.
=head1 SYNOPSYS
Skip the test if forking is unsupported:
use Test::CanFork;
use Test::More;
...
Skip the test if forking is unsupported, or any of the specified env vars are
not set:
use Test::CanFork qw/AUTHOR_TESTING RUN_PROBLEMATIC_TESTS .../;
use Test::More;
...
=head1 SOURCE
The source code repository for Test::More can be found at
F<http://github.com/Test-More/test-more/>.
=head1 MAINTAINER
=over 4
=item Chad Granum E<lt>exodist@cpan.orgE<gt>
=back
=head1 AUTHORS
=over 4
=item Chad Granum E<lt>exodist@cpan.orgE<gt>
=back
=head1 COPYRIGHT
Copyright 2014 Chad Granum E<lt>exodist7@gmail.comE<gt>.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
See F<http://www.perl.com/perl/misc/Artistic.html>
=cut
|