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 1plFJH-0002Mw-BK for pgsql-committers@arkaria.postgresql.org; Sat, 08 Apr 2023 20:37:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1plFJG-0005Cz-5Z for pgsql-committers@arkaria.postgresql.org; Sat, 08 Apr 2023 20:37:18 +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 1plFJF-0005Cp-UZ for pgsql-committers@lists.postgresql.org; Sat, 08 Apr 2023 20:37:17 +0000 Received: from relay9-d.mail.gandi.net ([2001:4b98:dc4:8::229]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1plFJC-0004mi-P2 for pgsql-committers@lists.postgresql.org; Sat, 08 Apr 2023 20:37:16 +0000 Received: (Authenticated sender: adsend@dunslane.net) by mail.gandi.net (Postfix) with ESMTPSA id 8FD95FF803; Sat, 8 Apr 2023 20:37:07 +0000 (UTC) Content-Type: multipart/alternative; boundary="------------XZkmqXV5qgsg82KIGGznQmJs" Message-ID: <7f08ff50-d749-4881-5523-480b478845ca@dunslane.net> Date: Sat, 8 Apr 2023 16:37:04 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: pgsql: Skip \password TAP test on old IPC::Run versions Content-Language: en-US To: Daniel Gustafsson , Tom Lane Cc: pgsql-committers@lists.postgresql.org References: <6d880ea2-f8ca-f458-4dcd-a7a3e6d6cd7c@dunslane.net> <3588535.1680971029@sss.pgh.pa.us> <627E6024-7803-473C-91AF-E8D76C3D99E0@yesql.se> From: Andrew Dunstan In-Reply-To: <627E6024-7803-473C-91AF-E8D76C3D99E0@yesql.se> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------XZkmqXV5qgsg82KIGGznQmJs Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2023-04-08 Sa 16:20, Daniel Gustafsson wrote: >> On 8 Apr 2023, at 18:23, Tom Lane wrote: >> >> Andrew Dunstan writes: >>> Stylistic nitpick: It's not necessary to have 2 evals here: >>> + skip "IO::Pty and IPC::Run >= 0.98 required", 1 unless >>> + (eval { require IO::Pty; } && eval { $IPC::Run::VERSION >= >>> '0.98' }); >>> just say "eval { require IO::Pty; return $IPC::Run::VERSION >= '0.98'; }" >> What I was wondering about was if it's safe to depend on the VERSION >> being fully numeric. > 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. > >> Can't we write "use IPC::Run 0.98;" and let >> some other code manage the version comparison? > We can, but that AFAIK (Andrew might have a better answer) requires the below > diff which I think leaves some readability to be desired: > > - (eval { require IO::Pty; } && eval { $IPC::Run::VERSION >= '0.98' }); > + (eval { require IO::Pty; } && !!eval { IPC::Run->VERSION('0.98'); 1 }); > > 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. I still don't understand why you're using two evals here. This should be sufficient and seems simpler to me:   unless eval { require IO:Pty; IPC::Run->VERSION('0.98'); } cheers andrew -- Andrew Dunstan EDB:https://www.enterprisedb.com --------------XZkmqXV5qgsg82KIGGznQmJs Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


On 2023-04-08 Sa 16:20, Daniel Gustafsson wrote:
On 8 Apr 2023, at 18:23, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Andrew Dunstan <andrew@dunslane.net> writes:
Stylistic nitpick: It's not necessary to have 2 evals here:

        
+   skip "IO::Pty and IPC::Run >= 0.98 required", 1 unless
+       (eval { require IO::Pty; } && eval { $IPC::Run::VERSION >= 
'0.98' });

        
just say "eval { require IO::Pty; return $IPC::Run::VERSION >= '0.98'; }"
What I was wondering about was if it's safe to depend on the VERSION
being fully numeric.  
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. 

Can't we write "use IPC::Run 0.98;" and let
some other code manage the version comparison?
We can, but that AFAIK (Andrew might have a better answer) requires the below
diff which I think leaves some readability to be desired:

-   (eval { require IO::Pty; } && eval { $IPC::Run::VERSION >= '0.98' });
+   (eval { require IO::Pty; } && !!eval { IPC::Run->VERSION('0.98'); 1 });

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.



I still don't understand why you're using two evals here. This should be sufficient and seems simpler to me:


  unless eval { require IO:Pty; IPC::Run->VERSION('0.98'); }


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com
--------------XZkmqXV5qgsg82KIGGznQmJs--