Re: pgbench: improve --help and --version parsing

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Andrei Korigodski <akorigod(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pgbench: improve --help and --version parsing
Date: 2018-07-26 22:22:16
Message-ID: alpine.DEB.2.21.1807261815320.9380@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hello Michaël,

>> Do you mean something like the attached?
>
> You basically have the idea, except that the number of tests in any TAP
> files calling program_help_ok and program_version_ok

Indeed. I wanted to outline the perl module part, really.

> needs to be updated, and that the test is too verbose :)
>
>> # Version
>> -pgbench('-V', 0, [qr{^pgbench .PostgreSQL. }], [qr{^$}], 'pgbench version');
>> +pgbench('-V', 0, [qr{^pgbench \(PostgreSQL\) \d+}], [qr{^$}], 'pgbench version');
>
> This could go away.

Indeed.

>> + is($stdout, $stdout2, "$cmd --help and -? have same output");
>> + like($stdout, qr{Usage:}, "$cmd --help is about usage");
>> + like($stdout, qr{\b$cmd\b}, "$cmd --help is about $cmd");
>> + like($stdout, qr{--help}, "$cmd --help is about option --help");
>> + like($stdout, qr{-\?}, "$cmd --help is about options -?");
>> + like($stdout, qr{--version}, "$cmd --help is about options --version");
>> + like($stdout, qr{-V}, "$cmd --help is about options -V");
>
> I would keep things a bit more simple by not parsing the output as you
> do, and it would be possible to reduce that to one single test with a
> text block as well, say using qq().

I do not understand what you mean by "reduce that to one single test". I
cannot see how to test stdouts equalities and contents' sanity in one
single test.

--
Fabien.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2018-07-26 22:27:29 Re: Upper limit arguments of pg_logical_slot_xxx_changes functions accept invalid values
Previous Message Brian Faherty 2018-07-26 22:05:45 Re: Upper limit arguments of pg_logical_slot_xxx_changes functions accept invalid values