line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Require::Internet; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
227427
|
use strict; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
60
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
80
|
|
5
|
2
|
|
|
2
|
|
1002
|
use IO::Socket::INET; |
|
2
|
|
|
|
|
40342
|
|
|
2
|
|
|
|
|
12
|
|
6
|
2
|
|
|
2
|
|
2044
|
use parent qw( Test2::Require ); |
|
2
|
|
|
|
|
656
|
|
|
2
|
|
|
|
|
10
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: Skip tests if there is no internet access |
9
|
|
|
|
|
|
|
our $VERSION = '0.09'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub skip |
13
|
|
|
|
|
|
|
{ |
14
|
3
|
|
|
3
|
0
|
7087
|
my(undef, %args) = @_; |
15
|
3
|
100
|
|
|
|
18
|
return 'NO_NETWORK_TESTING' if $ENV{NO_NETWORK_TESTING}; |
16
|
|
|
|
|
|
|
|
17
|
2
|
50
|
|
|
|
3
|
my @pairs = @{ $args{'-tcp'} || [ 'httpbin.org', 80 ] }; |
|
2
|
|
|
|
|
11
|
|
18
|
2
|
|
|
|
|
7
|
while(@pairs) |
19
|
|
|
|
|
|
|
{ |
20
|
2
|
|
|
|
|
3
|
my $host = shift @pairs; |
21
|
2
|
|
|
|
|
4
|
my $port = shift @pairs; |
22
|
|
|
|
|
|
|
|
23
|
2
|
|
|
|
|
12
|
my $sock = IO::Socket::INET->new( |
24
|
|
|
|
|
|
|
PeerAddr => $host, |
25
|
|
|
|
|
|
|
PeerPort => $port, |
26
|
|
|
|
|
|
|
Proto => 'tcp', |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
2
|
100
|
|
|
|
936
|
return "Unable to connect to $host:$port/tcp" unless $sock; |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
21
|
$sock->close; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
141
|
undef; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__END__ |