Skip to content

Commit 3c63c0c

Browse files
committed
do live test against example.com (GH #84)
www.neverssl.com is nowadays quite unreliable. The first precheck sometimes succeeds, but the real check fails afterwards, generating FAIL tests. example.com is not perfect, but seem to perform better. The test host can now be set by $host variable. The precheck is skipped during "perl -c", possibly reducing load on the test host (think of IDEs which do syntax checking using "perl -c").
1 parent f08b0dc commit 3c63c0c

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

t/live.t

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1+
my $host;
2+
BEGIN { $host = 'example.com' }
3+
#BEGIN { $host = 'www.neverssl.com' }
4+
15
BEGIN {
26
if ( $ENV{NO_NETWORK_TESTING} ) {
3-
print "1..0 # SKIP Live tests disabled due to NO_NETWORK_TESTING\n";
4-
exit;
7+
print "1..0 # SKIP Live tests disabled due to NO_NETWORK_TESTING\n";
8+
exit;
59
}
6-
eval {
7-
require IO::Socket::INET;
8-
my $s = IO::Socket::INET->new(
9-
PeerHost => "www.neverssl.com:80",
10-
Timeout => 5,
11-
);
12-
die "Can't connect: $@" unless $s;
13-
};
14-
if ($@) {
15-
print "1..0 # SKIP Can't connect to www.neverssl.com\n";
16-
print $@;
17-
exit;
10+
if ( !$^C ) { # avoid running the test connection with "perl -c"
11+
eval {
12+
require IO::Socket::INET;
13+
my $s = IO::Socket::INET->new(
14+
PeerHost => "$host:80",
15+
Timeout => 5,
16+
);
17+
die "Can't connect: $@" unless $s;
18+
};
19+
if ($@) {
20+
print "1..0 # SKIP Can't connect to $host\n";
21+
print $@;
22+
exit;
23+
}
1824
}
1925
}
2026

@@ -26,7 +32,7 @@ plan tests => 6;
2632
use Net::HTTP;
2733

2834
my $s = Net::HTTP->new(
29-
Host => "www.neverssl.com",
35+
Host => $host,
3036
KeepAlive => 1,
3137
Timeout => 15,
3238
PeerHTTPVersion => "1.1",

0 commit comments

Comments
 (0)