From 02c7f08fdf43732b977887887c7f94350e894831 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 10 Jun 2020 07:04:27 +0000 Subject: [PATCH] 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. --- lib/PublicInbox/TestCommon.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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; } -- 2.44.0