Re: TAP testing for psql's tab completion code

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: TAP testing for psql's tab completion code
Date: 2019-12-29 07:11:07
Message-ID: alpine.DEB.2.21.1912290748020.889@pseudo
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hello Tom,

>>> We've often talked about the problem that we have no regression test
>>> coverage for psql's tab completion code. I got interested in this
>>> issue while messing with the filename completion logic therein [1],
>>> so here is a draft patch that adds some testing for that code.
>
>> After you raised the issue, I submitted something last August, which did
>> not attract much attention.
>> https://commitfest.postgresql.org/26/2262/
>> It covers some tab-completion stuff. It uses Expect for the interactive
>> stuff (tab completion, \h, ...).
>
> Now that you mention it, I seem to recall looking at that and not being
> happy with the additional dependency on Expect.

Possibly. You did not say it out very loud.

> Expect is *not* a standard module;

Somehow. It is an old one, though.

> on the machines I have handy, the only one in which it appears in the
> default Perl installation is macOS. (Huh, what's Apple doing out ahead
> of the pack?) I'm pretty sure that Expect also relies on IO::Pty,

Indeed, it does.

> so it's a strictly worse dependency than what I've got here.

If you have to install IO::Pty anyway, ISTM you can also install Expect.

IO::Pty documentation says that it is "mainly used by Expect", which is a
clue that IO::Pty is not much better than Expect as a dependency.

For installation, "apt install libexpect-perl" did the trick for me. "cpan
install Expect" should work as well on most setup.

I guess it is possible to check whether Expect is available and to skip
the corresponding tests if not.

> Can we recast what you did into something like this patch's methods?

Basically it means reimplementing some expect functionality in the script,
including new bugs. Modules were invented to avert that, so I cannot say
I'm happy with the prospect of re-inventing the wheel. Note that Expect is
a pure-perl 1600-LOC module.

Anyway, I'll have a look. At least I used a very limited subset of Expect
capabilities which should help matters along.

--
Fabien.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2019-12-29 07:30:26 Re: Greatest Common Divisor
Previous Message Noah Misch 2019-12-29 07:02:21 Re: Consolidate 'unique array values' logic into a reusable function?