[PATCH] Add tests for psql tab completion

Started by Matheus Alcantaraover 4 years ago3 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t45502
psql -h localhost -U postgres

Built from patchset v1 (message #1), July 27, 2026 at 03:21 PM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t45502_1 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t45502_1 && git checkout t45502_1

Patchset v1 (message #1) is on t45502_1

Jump to latest
#1Matheus Alcantara
mths.dev@pm.me

Hi hackers.

I'm attaching a patch that add some new test cases for tab completion of psql.

This is my first patch that I'm sending here so let me know if I'm doing something wrong.

--
Matheus Alcantara

Attachments:

t45502_1
0001-psql-Add-tests-for-tab-completion.patchtext/x-patch; name=0001-psql-Add-tests-for-tab-completion.patchDownload+92-1
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Matheus Alcantara (#1)
Re: [PATCH] Add tests for psql tab completion

Matheus Alcantara <mths.dev@pm.me> writes:

I'm attaching a patch that add some new test cases for tab completion of psql.

What exactly is the motivation for these particular tests?

I believe that most of tab-complete.c is already covered, outside
of the giant if-else chain at the heart of psql_completion().
It's hard to summon interest in trying to cover every branch of
that chain; but if we're to add coverage of just a few more,
which ones and why? The ones you've chosen to hit in this
patch don't seem especially interesting.

regards, tom lane

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Matheus Alcantara (#1)
Re: [PATCH] Add tests for psql tab completion

[ Please keep the mailing list cc'd ]

Matheus Alcantara <mths.dev@pm.me> writes:

On Monday, February 14th, 2022 at 17:01, Tom Lane <tgl@sss.pgh.pa.us> wrote:

What exactly is the motivation for these particular tests?

I was studying the source code and looking for projects that I could contribute so I decided
to start with tests, so I ran coverage and started with files that had little coverage, realized
that psql tab completion ones had little coverage so I decided to add some tests, I tried to
start with the simplest.

I understand that the patch may not be as much of a need, I just wanted to try and help with something.
Do you think there would be other tests that should be done? I would like to try to contribute.

There's certainly lots of places that could use more test coverage.
But I think that making a meaningful difference in tab-complete.c
would require writing test cases to hit most of the if-else branches,
which doesn't seem very profitable either in terms of test-writing
effort or in terms of the cycles that'd be spent on running those
tests forevermore. We try to be thrifty about how much work is
done by check-world, because it's a real advantage for development
that that takes a small number of minutes and not hours. I'm not
really seeing that covering more of tab-complete would buy much.

As for areas that *do* need more coverage, the first one that
I come across in looking through the coverage report is GIST
index build: gistbuild.c is only showing 45% coverage, and
gistbuildbuffers.c a fat zero [1]https://coverage.postgresql.org/src/backend/access/gist/index.html. We've looked at that before [2]/messages/by-id/10261.1588705157@sss.pgh.pa.us
but not made much progress on developing an adequately cheap test
case. Maybe you could pick up where that thread left off? Or if that
doesn't seem interesting to you, there's lots of other possibilities.
I'd suggest getting some buy-in from this list on what to work on
before you start, though.

regards, tom lane

[1]: https://coverage.postgresql.org/src/backend/access/gist/index.html

[2]: /messages/by-id/10261.1588705157@sss.pgh.pa.us