Re: Improved TAP tests by replacing sub-optimal uses of ok() with better Test::More functions

Sadhuprasad Patro <b.sadhu@gmail.com>

From: Sadhuprasad Patro <b.sadhu@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Andrew Dunstan <andrew@dunslane.net>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-10-30T11:30:27Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Improve TAP tests by replacing ok() with better Test::More functions

  2. Fix matching check in recovery test 042_low_level_backup

  3. pg_createsubscriber: Fix matching check in TAP test

Thank you Michael for committing the patch...

On Fri, Oct 17, 2025 at 11:11 AM Michael Paquier <michael@paquier.xyz>
wrote:

> On Thu, Oct 16, 2025 at 04:26:48PM +0900, Michael Paquier wrote:
> > -ok($node_s->safe_psql($db1, "SELECT COUNT(*) = 2 FROM pg_publication"),
> > -     'two pre-existing publications on subscriber');
> > +is($node_s->safe_psql($db1, "SELECT COUNT(*) = 2 FROM pg_publication"),
> > +   't',
> > +   'two pre-existing publications on subscriber');
>
> Note here: we can just compare the result with '2'.
>
> > -ok($node_replica->safe_psql('postgres', $canary_query) == 0,
> > -     'canary is missing');
> > +is($node_replica->safe_psql('postgres', $canary_query), 0,
> > +   'canary is missing');
> > [...]
> > -ok($node_replica->safe_psql('postgres', $canary_query) == 1,
> > +is($node_replica->safe_psql('postgres', $canary_query), 1,
> >       'canary is present');
>
> Fixed and backpatched these two at the end as they could mask bugs, on
> the branches where they matter.
>
> Not sure that the bits in 010_pg_basebackup were an improvement.  In
> 004_test_parser_perf, the result is indeed empty, but it's a matter of
> the result returned by IPC::run::run.
>
> -ok($node->log_contains(qr/no SSL error reported/) == 0,
> +is($node->log_contains(qr/no SSL error reported/), 0
>
> The CI was failing with the change in the SSL tests, as of:
> [05:03:12.647] #   at
> /tmp/cirrus-ci-build/src/test/ssl/t/001_ssltests.pl line 127.
> [05:03:12.647] #          got: ''
> [05:03:12.647] #     expected: '0'
>
> There was already a lot of content already.  So I have left this one
> out for the moment and applied a good chunk of the rest with some
> indentation.
> --
> Michael
>


-- 
thank u
               SADHU PRASAD