From: Eric Wong Date: Wed, 10 Jun 2020 07:04:27 +0000 (+0000) Subject: testcommon: tcp_(server|connect): BAIL_OUT on failure X-Git-Tag: v1.6.0~437 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=02c7f08fdf43732b977887887c7f94350e894831;p=public-inbox.git testcommon: tcp_(server|connect): BAIL_OUT on failure None of our tests rely on this failing, so just bail out if the system is out of resources. --- diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm index 246047b1..5e7dc8b0 100644 --- a/lib/PublicInbox/TestCommon.pm +++ b/lib/PublicInbox/TestCommon.pm @@ -37,17 +37,18 @@ sub tcp_server () { Type => Socket::SOCK_STREAM(), Listen => 1024, Blocking => 0, - ) + ) or Test::More::BAIL_OUT("failed to create TCP server: $!"); } sub tcp_connect { my ($dest, %opt) = @_; + my $addr = $dest->sockhost . ':' . $dest->sockport; my $s = IO::Socket::INET->new( Proto => 'tcp', Type => Socket::SOCK_STREAM(), - PeerAddr => $dest->sockhost . ':' . $dest->sockport, + PeerAddr => $addr, %opt, - ); + ) or Test::More::BAIL_OUT("failed to connect to $addr: $!"); $s->autoflush(1); $s; }