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

From Sadhuprasad Patro
Subject Re: Improved TAP tests by replacing sub-optimal uses of ok() with better Test::More functions
Date
Msg-id CAFF0-CEUy6MC96oQbOvtmixrMmBoFSY5O26d5wjL5BpXpe1CZg@mail.gmail.com
Whole thread Raw
In response to Re: Improved TAP tests by replacing sub-optimal uses of ok() with better Test::More functions  (Michael Paquier <michael@paquier.xyz>)
Responses Re: Improved TAP tests by replacing sub-optimal uses of ok() with better Test::More functions
List pgsql-hackers
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

pgsql-hackers by date:

Previous
From: Chao Li
Date:
Subject: Re: Improve pg_sync_replication_slots() to wait for primary to advance
Next
From: Mircea Cadariu
Date:
Subject: Re: [BUG] temporary file usage report with extended protocol and unnamed portals