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