pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Daniel Gustafsson <daniel@yesql.se>
To: Andrew Dunstan <andrew@dunslane.net>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Skip \password TAP test on old IPC::Run versions
Date: Sat, 8 Apr 2023 22:46:08 +0200
Message-ID: <B05CB1A2-4AB9-484D-9B5D-A492349E208C@yesql.se> (raw)
In-Reply-To: <7f08ff50-d749-4881-5523-480b478845ca@dunslane.net>
References: <E1pl943-0023OF-Ol@gemulon.postgresql.org>
	<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>

> On 8 Apr 2023, at 22:37, Andrew Dunstan <andrew@dunslane.net> wrote:
> 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'); }

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 >= '0.98' });
+   eval { require IO::Pty; IPC::Run->VERSION('0.98'); };

--
Daniel Gustafsson






view thread (8+ messages)

Message-ID: <B05CB1A2-4AB9-484D-9B5D-A492349E208C@yesql.se>
Permalink:  ../B05CB1A2-4AB9-484D-9B5D-A492349E208C@yesql.se/
Also on:    postgresql.org/message-id/B05CB1A2-4AB9-484D-9B5D-A492349E208C@yesql.se

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: daniel@yesql.se, andrew@dunslane.net, tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Skip \password TAP test on old IPC::Run versions
  In-Reply-To: <B05CB1A2-4AB9-484D-9B5D-A492349E208C@yesql.se>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox