Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1plFRw-00032e-KJ for pgsql-committers@arkaria.postgresql.org; Sat, 08 Apr 2023 20:46:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1plFRu-00082e-NB for pgsql-committers@arkaria.postgresql.org; Sat, 08 Apr 2023 20:46:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1plFRu-00082V-Fi for pgsql-committers@lists.postgresql.org; Sat, 08 Apr 2023 20:46:14 +0000 Received: from smtp.outgoing.loopia.se ([93.188.3.37]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1plFRs-0004sC-2S for pgsql-committers@lists.postgresql.org; Sat, 08 Apr 2023 20:46:13 +0000 Received: from s807.loopia.se (localhost [127.0.0.1]) by s807.loopia.se (Postfix) with ESMTP id B2BC42F5F5B6 for ; Sat, 8 Apr 2023 22:46:09 +0200 (CEST) Received: from s899.loopia.se (unknown [172.22.191.6]) by s807.loopia.se (Postfix) with ESMTP id A3AF62E28FBF; Sat, 8 Apr 2023 22:46:09 +0200 (CEST) Received: from s473.loopia.se (unknown [172.22.191.6]) by s899.loopia.se (Postfix) with ESMTP id A189C2C8BA50; Sat, 8 Apr 2023 22:46:09 +0200 (CEST) X-Virus-Scanned: amavisd-new at amavis.loopia.se X-Spam-Flag: NO X-Spam-Score: -1 X-Spam-Level: X-Spam-Status: No, score=-1 tagged_above=-999 required=6.2 tests=[ALL_TRUSTED=-1] autolearn=disabled Received: from s980.loopia.se ([172.22.191.5]) by s473.loopia.se (s473.loopia.se [172.22.190.13]) (amavisd-new, port 10024) with LMTP id bi5i6C49AlMP; Sat, 8 Apr 2023 22:46:09 +0200 (CEST) X-Loopia-Auth: user X-Loopia-User: daniel@yesql.se X-Loopia-Originating-IP: 89.255.232.193 Received: from smtpclient.apple (customer-89-255-232-193.stosn.net [89.255.232.193]) (Authenticated sender: daniel@yesql.se) by s980.loopia.se (Postfix) with ESMTPSA id 25C3422015A1; Sat, 8 Apr 2023 22:46:09 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.2\)) Subject: Re: pgsql: Skip \password TAP test on old IPC::Run versions From: Daniel Gustafsson In-Reply-To: <7f08ff50-d749-4881-5523-480b478845ca@dunslane.net> Date: Sat, 8 Apr 2023 22:46:08 +0200 Cc: Tom Lane , pgsql-committers@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <6d880ea2-f8ca-f458-4dcd-a7a3e6d6cd7c@dunslane.net> <3588535.1680971029@sss.pgh.pa.us> <627E6024-7803-473C-91AF-E8D76C3D99E0@yesql.se> <7f08ff50-d749-4881-5523-480b478845ca@dunslane.net> To: Andrew Dunstan X-Mailer: Apple Mail (2.3696.120.41.1.2) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 8 Apr 2023, at 22:37, Andrew Dunstan wrote: > On 2023-04-08 Sa 16:20, Daniel Gustafsson wrote: >>> On 8 Apr 2023, at 18:23, Tom Lane >>> wrote: >>>=20 >>> Andrew Dunstan=20 >>> >>> writes: >>>=20 >>>> Stylistic nitpick: It's not necessary to have 2 evals here: >>>>=20 >>>> + skip "IO::Pty and IPC::Run >=3D 0.98 required", 1 unless >>>> + (eval { require IO::Pty; } && eval { $IPC::Run::VERSION >=3D=20= >>>> '0.98' }); >>>>=20 >>>> just say "eval { require IO::Pty; return $IPC::Run::VERSION >=3D = '0.98'; }" >>>>=20 >>> What I was wondering about was if it's safe to depend on the VERSION >>> being fully numeric. =20 >>>=20 >> Reading documentation online pointed at this being the established = way, and >> trying to read the Perl5 code it seems to essentially turn whatever = is set in >> $VERSION into a numeric.=20 >>=20 >>=20 >>> Can't we write "use IPC::Run 0.98;" and let >>> some other code manage the version comparison? >>>=20 >> We can, but that AFAIK (Andrew might have a better answer) requires = the below >> diff which I think leaves some readability to be desired: >>=20 >> - (eval { require IO::Pty; } && eval { $IPC::Run::VERSION >=3D = '0.98' }); >> + (eval { require IO::Pty; } && !!eval { IPC::Run->VERSION('0.98'); = 1 }); >>=20 >> This is needed since ->VERSION die()'s if the version isn't = satisfied. That >> seems to work fine though, and will ensure that the UNIVERSAL version = method >> does the version comparison. We can of course expand the comment on = why that >> construct is needed. >=20 > I still don't understand why you're using two evals here. This should = be sufficient and seems simpler to me: >=20 > unless eval { require IO:Pty; IPC::Run->VERSION('0.98'); } Because I was trying to get "use IPC::Run" to work and that required = multiple evals, and got stuck on that track. I agree that your version is better = and does indeed work (and offloads version comparison to the UNIVERSAL = class), so I'll go ahead with the below. - (eval { require IO::Pty; } && eval { $IPC::Run::VERSION >=3D '0.98' = }); + eval { require IO::Pty; IPC::Run->VERSION('0.98'); }; -- Daniel Gustafsson