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

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Sadhuprasad Patro <b(dot)sadhu(at)gmail(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Improved TAP tests by replacing sub-optimal uses of ok() with better Test::More functions
Date: 2025-10-17 05:41:07
Message-ID: aPHW8zMIcp59Jpuz@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chanukya SDS 2025-10-17 05:55:54 pg_running_stats - mergeable running statistics (Welford/Chan) extension for postgresql
Previous Message Steven Niu 2025-10-17 05:22:12 Re: Question for coverage report